Jonas Audenaert created CAMEL-16692:
---------------------------------------

             Summary: SFTP sometimes doesn't receive 1 file 
                 Key: CAMEL-16692
                 URL: https://issues.apache.org/jira/browse/CAMEL-16692
             Project: Camel
          Issue Type: Bug
          Components: camel-ftp
    Affects Versions: 3.7.3
         Environment: I'm reproducing this on my own computer and a SFTP server 
running on a Docker container locally.
            Reporter: Jonas Audenaert


I have following Camel route, created by a RoutingBuilder:
{code:java}
new org.apache.camel.builder.RouteBuilder() {
  void configure() {
    from("direct:myProgram")
      .routeId("${params.profile}")
      
.to("sftp://${params.hostname}:${params.port}/${params.directory}?username=RAW(${params.username})&password=RAW(${params.password})&fileName=RAW(\${header.fileName})&fileExist=Fail&disconnect=true&stepwise=false&useUserKnownHostsFile=false&serverAliveInterval=${params.serverAliveInterval}")
  }
}{code}
I'm doing a test on my local machine to send 50 files through this route to a 
remote SFTP server. Most of the time, all files arrive, but sometimes 1 file 
seems to be missing.

My program doesn't notice the failure of sending. But during debugging I found 
something interesting that happened.

That one specific file which is missing throws in the camel library an 
SFTPException at the method existsFile (SftpOperations.java:1046).

The exception contains only reason *4:* message but the exception contains 
another exception. The wrapped exception contain following exception message: 
*java.io.IOException: Pipe Closed.*

Camel wraps the exception in a GenericFileOperationFailedException and throws 
it to the method which called SftpOperations, GenericFileProducer 
(GenericFileProducer.java:135).
That exception arrives in the tr/catch block of it and goes to the generic 
catch block.

In that catch-block the exception is handled by the *handleWrite()* method 
(RemoteFileProducer.java:83) and there it gets interesting. 
In handleWrite() check is performed if the Camel Base Service is in stopping() 
or stopped() state. If that's the case, the exception is only logged but not 
thrown. But isStopped() returns true, so my exception is thrown, but my 
application doesn't receive it, so it thinks that the file is transferred 
succesfully to the SFTP server, but it never arrives.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to