Uploaded image for project: 'Commons VFS'
  1. Commons VFS
  2. VFS-753

NumberFormatException in SftpFileSystem::getUId

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 2.5.0
    • 2.7.0
    • None

    Description

      When calling FileSystemManager::resolveFile(...) connecting to a specific sftp server a NumberFormat exception is thrown and a FileObject is not returned.

      When the SftpFileSystem constructor is called there is a call to detectExecDisabled which in turn calls getUid. SftpFileSystem::getUId assumes that executeCommand(...) will always return non zero (the channel exit status) for execution failure.

      In the case of the sftp server that we are connecting to, the channel exit status remains zero however the returned buffer contains the string "This server does not provide shell access, only SFTP. Goodbye.". This causes a NumberFormatException in getUId.

      This behaviour does not occur in version 2.4.1

      Here is the relevent snippet from the stack trace:
      java.lang.NumberFormatException: For input string: "This server does not provide shell access, only SFTP. Goodbye."

             at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)

             at java.lang.Integer.parseInt(Integer.java:580)

             at java.lang.Integer.parseInt(Integer.java:615)

             at org.apache.commons.vfs2.provider.sftp.SftpFileSystem.getUId(SftpFileSystem.java:281)

             at org.apache.commons.vfs2.provider.sftp.SftpFileSystem.detectExecDisabled(SftpFileSystem.java:344)

             at org.apache.commons.vfs2.provider.sftp.SftpFileSystem.<init>(SftpFileSystem.java:94)

             at org.apache.commons.vfs2.provider.sftp.SftpFileProvider.doCreateFileSystem(SftpFileProvider.java:93)

             at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.getFileSystem(AbstractOriginatingFileProvider.java:93)

             at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:72)

             at org.apache.commons.vfs2.provider.AbstractOriginatingFileProvider.findFile(AbstractOriginatingFileProvider.java:56)

             at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:717)

             at org.apache.commons.vfs2.impl.DefaultFileSystemManager.resolveFile(DefaultFileSystemManager.java:654)

             at com.shortcuts.lambda.google_reserve_sftp.util.SFTPUtil.ls(SFTPUtil.java:68)

             at com.shortcuts.lambda.google_reserve_sftp.util.SFTPUtilTest.testConnectToGoogle(SFTPUtilTest.java:48)

             at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

      Attachments

        Activity

          People

            Unassigned Unassigned
            JohnWebb John Webb
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: