camel-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <>
Subject [jira] [Commented] (CAMEL-11437) Bug using file endpoint probeContentType and preMove attributes together causes Exchange.FILE_CONTENT_TYPE to get dropped. (2.19.0)
Date Fri, 23 Jun 2017 09:27:00 GMT


ASF GitHub Bot commented on CAMEL-11437:

GitHub user onders86 opened a pull request:

    CAMEL-11437 - probeContentType and preMove attributes causes Exchange…

    ….FILE_CONTENT_TYPE to get dropped
    This is a very specific fix for the issue.
    Better solution would be passing endpoint where bindToExchange method call done on GenericFile.
I guess the design may need such a change on GenericFile. because in populateHeaders method
there are specific conditions tied to FileEndpoint properties which are not set when concrete
instances of GenericFileProcessStrategy are created without the settings bound to endpoint
like GenericFileRenameProcessStrategy, GenericDeleteProcessStrategy etc. (where probeContentType
is lost)

You can merge this pull request into a Git repository by running:

    $ git pull CAMEL-11437

Alternatively you can review and apply these changes as the patch at:

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1781
commit 351c6d01585b25967e5a0100a87de4b6d20a5a2e
Author: onders86 <>
Date:   2017-06-23T09:17:22Z

    CAMEL-11437 - probeContentType and preMove attributes causes Exchange.FILE_CONTENT_TYPE
to get dropped


> Bug using file endpoint probeContentType and preMove attributes together causes Exchange.FILE_CONTENT_TYPE
to get dropped. (2.19.0) 
> ------------------------------------------------------------------------------------------------------------------------------------
>                 Key: CAMEL-11437
>                 URL:
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-core
>    Affects Versions: 2.19.0
>            Reporter: David R. Hoffman
>            Assignee: onder sezgin
>            Priority: Minor
>             Fix For: 2.19.2, 2.20.0
> We have a route:
> {quote}
> from("file:inbox?probeContentType=true&preMove=inprogress/$\{file:name}&renameUsingCopy=true")
>         .transacted()
>         .bean(MimeTypeParser.class, "populateFileTypeHeaderFields")
>         .to("seda:somewhere")
> {quote} 
> The probeContentType executes before preMove & renameUsingCopy and correctly sets
the Exchange.FILE_CONTENT_TYPE header.
> The problem happens during the preMove & renameUsingCopy part where GenericFileExpressionRenamer
calls the GenericFile method GenericFile<T> copyFrom(GenericFile<T> source).
> This "copy constructor" method does not copy the header Exchange.FILE_CONTENT_TYPE, nor
does it preserve the value of the GenericFile probeContentType field.
> The class GenericFileRenameProcessStrategy calls GenericFileExpressionRenamer from the
method begin() which in turn calls GenericFile.bindToExchange(Exchange exchange).
> GenericFile.bindToExchange() clears all "CamelFile*" headers and then calls GenericFile.populateHeaders(GenericFileMessage<T>
message) which would call Files.probeContentType(Path path) if the GenericFile probeContentType
field weren't now false.
> When our route gets to the MimeTypeParser bean the "CamelFileContentType" header is lost,
and that is what we are looking for.
> One work-around is to put something like this between .transacted() and the .bean():
> {quote}
> .process(exchange ->  \{
>      Path path = exchange.getIn().getBody(File.class).toPath();
>      exchange.getIn().setHeader(Exchange.FILE_CONTENT_TYPE, Files.probeContentType(path));
> })
> {quote}

This message was sent by Atlassian JIRA

View raw message