[ 
https://issues.apache.org/jira/browse/CAMEL-13069?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16743885#comment-16743885
 ] 

Dmitry Volodin commented on CAMEL-13069:
----------------------------------------

[~Broser], you are welcome to submit PR on github. As idea, the exception 
message can be current, but we can print detail message to the log with INFO 
level.

> Display proper FTP reply message in case of transfer error
> ----------------------------------------------------------
>
>                 Key: CAMEL-13069
>                 URL: https://issues.apache.org/jira/browse/CAMEL-13069
>             Project: Camel
>          Issue Type: Improvement
>          Components: camel-ftp
>    Affects Versions: 2.23.0
>         Environment: Any
>            Reporter: Gerold Broser
>            Priority: Major
>              Labels: FTP, FTP-Reply
>
> When trying to transfer a file to an FTP server on an IBM mainframe that's 
> too large for the allocated data set there I get the following log message:
> {code:java}
> ...
> 2019-01-16 10:10:22,368 WARN file.remote.RemoteFileProducer – Writing file 
> failed with: File operation failed: 125 Storing data set 
> TEST.TRANSFER.FB80.TXT
>  IOException caught while copying.. Code: 125
> ...{code}
> This is confusing since according to RFC 959 [reply codes {{1yz}} are 
> {{Positive Preliminary}} replies|https://tools.ietf.org/html/rfc959#page-37] 
> with:
> {quote}[{{125 Data connection already open; transfer 
> starting.}}|https://tools.ietf.org/html/rfc959#page-41]
> {quote}
> being more informational than exceptional.
> Performing the same transfer manually with FileZilla and Windows 7's command 
> line ftp client results in:
> FileZilla:
> {code:java}
> ...
> Command:      STOR TRANSFER.FB80.TXT
> Response:     125 Storing data set TEST.TRANSFER.FB80.TXT
> Response:     451-Error: Name=CkResults (Write) RC=-13
> Response:     451-System completion code and reason: B37-04
> Response:     451-Data set is out of space.
> Response:     451-Error (1013) closing the data set.
> Response:     451 Transfer aborted due to file error.
> ...{code}
> ftp:
> {code:java}
> ftp> send TRANSFER.FB80.TXT
> ---> PORT 10,100,113,251,254,235
> 200 Port request OK.
> ---> STOR TRANSFER.FB80.TXT
> 125 Storing data set TEST.TRANSFER.FB80.TXT
> 451-Error: Name=CkResults (Write) RC=-13
> 451-System completion code and reason: B37-04
> 451-Data set is out of space.
> 451-Error (1013) closing the data set.
> 451 Transfer aborted due to file error.
> ...{code}
> To get the real cause we can use Apache Commons Net's 
> [{{FTP.getReply()}}|https://commons.apache.org/proper/commons-net/javadocs/api-3.6/org/apache/commons/net/ftp/FTP.html#getReply()]:
> {quote}Fetches a reply from the FTP server and returns the integer reply 
> code. After calling this method, the actual reply text can be accessed from 
> either calling getReplyString or getReplyStrings . Only use this method if 
> you are implementing your own FTP client *or if you need to fetch a secondary 
> response from the FTP server*.
> {quote}
> in the {{catch (IOException e)}} block in 
> [{{FtpOperations.doStoreFile()}}|https://github.com/apache/camel/blob/master/components/camel-ftp/src/main/java/org/apache/camel/component/file/remote/FtpOperations.java#L717]
>  like:
> {code:java}
> ...
> catch (IOException e) {
>   final IOException primary = new IOException(client.getReplyString());
>   e = new IOException(e.getMessage(), primary);
>   client.getReply(); // get secondary reply
>   throw new GenericFileOperationFailedException(client.getReplyString(), e);
> }
> ...
> {code}
> which results in the following comprehensible stack trace in my test code:
> {code:java}
> org.apache.camel.component.file.GenericFileOperationFailedException: 
> 451-Error: Name=CkResults (Write) RC=-13
> 451-System completion code and reason: B37-04
> 451-Data set is out of space.
> 451-Error (1013) closing the data set.
> 451 Transfer aborted due to file error.
>     at my.FTPTransferTest.testMF_FTP((FTPTransferTest.java:74))
>     ...
> Caused by: java.io.IOException: IOException caught while copying.
>     at my.FTPTransferTest.testMF_FTP(FTPTransferTest.java:70)
>     ... 24 more
> Caused by: java.io.IOException: 125 Storing data set TEST.TRANSFER.FB80.TXT
>     at my.FTPTransferTest.testMF_FTP(FTPTransferTest.java:69)
>     ... 24 more
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to