Uploaded image for project: 'Camel'
  1. Camel
  2. CAMEL-13069

Display proper FTP reply message in case of transfer error

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Major
    • Resolution: Abandoned
    • 2.23.0
    • Future
    • camel-ftp
    • Any

    • Unknown

    Description

      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:

      ...
      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
      ...

      This is confusing since according to RFC 959 reply codes 1yz are Positive Preliminary replies with:

      125 Data connection already open; transfer starting.

      being more informational than exceptional.

      Performing the same transfer manually with FileZilla and Windows 7's command line ftp client results in:

      FileZilla:

      ...
      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.
      ...

      ftp:

      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.
      ...

      To get the real cause we can use Apache Commons Net's FTP.getReply():

      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.

      in the catch (IOException e) block in FtpOperations.doStoreFile() like:

      ...
      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);
      }
      ...
      

      which results in the following comprehensible stack trace in my test code:

      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
      

      Attachments

        Activity

          People

            Unassigned Unassigned
            Broser Gerold Broser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: