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

John Webb commented on VFS-753:
-------------------------------

[~ggregory]

I suspect the fix has the side effect of telling the class that execution is 
enabled on the server when it isn't. detectExecDisabled relies on a throw to 
return true however the fix simply catches and logs. I obviously don't know the 
code as well as you but worry that a false negative from detectExecDisabled may 
lead to undesirable behaviour.

> NumberFormatException in SftpFileSystem::getUId
> -----------------------------------------------
>
>                 Key: VFS-753
>                 URL: https://issues.apache.org/jira/browse/VFS-753
>             Project: Commons VFS
>          Issue Type: Bug
>    Affects Versions: 2.5.0
>            Reporter: John Webb
>            Priority: Major
>             Fix For: 2.6.1
>
>
> 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)



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

Reply via email to