jsch
jsch copied to clipboard
Session thread stays open forever
Using version 02.19 with Apache commons. In our application, we frequently connect to a third party SFTP server. Looks like, sometime, the server fails to retrieve a file. In this case, we close the connection (calling disconnect) after timeout, but there is a session thread that is never closed.
sun.nio.ch.SocketDispatcher.read0 ( native code )
sun.nio.ch.SocketDispatcher.read ( SocketDispatcher.java:47 )
sun.nio.ch.NioSocketImpl.tryRead ( NioSocketImpl.java:266 )
sun.nio.ch.NioSocketImpl.implRead ( NioSocketImpl.java:317 )
sun.nio.ch.NioSocketImpl.read ( NioSocketImpl.java:355 )
sun.nio.ch.NioSocketImpl$1.read ( NioSocketImpl.java:808 )
java.net.Socket$SocketInputStream.read ( Socket.java:966 )
com.jcraft.jsch.IO.getByte ( IO.java:95 )
com.jcraft.jsch.Session.read ( Session.java:1231 )
com.jcraft.jsch.Session.run ( Session.java:1783 )
com.jcraft.jsch.Session$$Lambda$3301/0x00007f4f8789e650.run ( unknown source )
java.lang.Thread.run ( Thread.java:840 )
After a while, we have thousands of these threads staying open forever until we restart the app. Looks like the InputStream returned from Socket must be checked isAvailable before trying to read.