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

perfah commented on SSHD-1350:
------------------------------

After posting this I realized there has been some recent updates to the library.

If it has already been patched, please let me know fix version.

> NPE when SftpFileSystem is closed (auto-closable)
> -------------------------------------------------
>
>                 Key: SSHD-1350
>                 URL: https://issues.apache.org/jira/browse/SSHD-1350
>             Project: MINA SSHD
>          Issue Type: Bug
>    Affects Versions: 2.15.0
>         Environment: Win 11 Pro 64
>            Reporter: perfah
>            Priority: Major
>
> Hi! We are doing a simple:
>  
> {code:java}
> try (var children = Files.list(path)) { ... }{code}
>  
> And find that an exception is thrown occasionally (see stacktrace below). It 
> appears that an NPE is triggered when the _close()_ method of the 
> auto-closable _SftpFileSystem_ class is called.
> Now according to my client, this exception is only seen in the log when there 
> are a lot of files on the server (e.g. 140 files), whereas all is working 
> smoothly with just a handful. Because the error is thrown repeatedly, our 
> service is malfunctioning in the former scenario.
> I believe this is a bug because of the following principles:
>  * Implementations of AutoClosable#close should remain idempotent: if it's 
> already closed, do nothing, don't throw an error the second time, for example.
>  * NPEs shouldn't surface to the user of the library.
>  * The success of NIO file operations shouldn't be contingent on the number 
> of files on the server.
> Highly appreciate feedback on the matter. Please let me know if you want some 
> more details, or if I am missing something is my analysis.
> --
> java.lang.NullPointerException: Cannot invoke 
> "org.apache.sshd.client.session.ClientSession.getAttribute(org.apache.sshd.common.AttributeRepository$AttributeKey)"
>  because the return value of 
> "org.apache.sshd.sftp.client.fs.SftpFileSystem.getClientSession()" is null
>     at 
> org.apache.sshd.sftp.client.fs.SftpFileSystem.close(SftpFileSystem.java:270)
>     at 
> org.apache.sshd.sftp.client.fs.SftpDirectoryStream.close(SftpDirectoryStream.java:142)
>     ... [CLASSIFIED]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to