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

Trying to create directory (FtpOperations.buildDirectory) without starting directory in ftps URI

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.24.0
    • 3.3.0
    • camel-ftp
    • None
    • mac/linux

    • Unknown

    Description

      Hi,

      I setup a route using this FTPS URI:

      ftps://filetransfer.bpost.be/?bridgeErrorHandler=true&connectTimeout=60000&delay=600000&disconnect=true&idempotent=true&idempotentKey=......&idempotentRepository=%23gfpIdempotentRepository&ignoreFileNotFoundOrPermissionError=true&localWorkDirectory=%2Ftmp%2F895c3952-e3f7-401f-b38f-055fcdf44301&maxMessagesPerPoll=0&move=archive&passiveMode=true&password=xxxxxx
      

      You can see we didn't specify starting directory which we assume it would be defaulted to "/", but actually inside the code it gets defaulted to "" empty.

      Upon debugging, I see this behavior from camel FtpConsumer.doStart():

                      try {
                          connectIfNecessary();
                          operations.buildDirectory(endpoint.getConfiguration().getDirectory(), true);
                      } catch (GenericFileOperationFailedException e) {
                          // log a WARN as we want to start the consumer.
                          LOG.warn("Error auto creating directory: " + endpoint.getConfiguration().getDirectory() + " due " + e.getMessage() + ". This exception is ignored.", e);
                      }
      

      Now my ftp URI doesn't have starting directory, (which is optional according to https://camel.apache.org/components/latest/ftps-component.html), so the `getDirector()` here returns "" empty string. And then inside FtpOperations.buildDirectory():

                  try {
                      // maybe the full directory already exists
                      success = client.changeWorkingDirectory(directory);
                      if (!success) {
                          log.trace("Trying to build remote directory: {}", directory);
                          success = client.makeDirectory(directory);
                          if (!success) {
                              // we are here if the server side doesn't create
                              // intermediate folders so create the folder one by one
                              success = buildDirectoryChunks(directory);
                          }
                      }
      
                      return success;
                  } finally {
      

      It tries first to enter the "" directory, which failed. Then it tried to makeDirectory(""), which failed as well, after a very long timeout.

       

      Of course we can use "autoCreate=false" to turn this behavior off. But my question is why do we want to try to autoCreate a directory when the directory string is actually "" empty?

      Attachments

        Activity

          People

            davsclaus Claus Ibsen
            jinfengnarvar Jin Feng
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: