Closed
Description
Discussed in #8707
When we upgraded out application to Spring boot 3 we started getting issues like this:
Caused by: org.apache.sshd.common.io.WritePendingException: A write operation is already pending; cannot write 21 bytes
at org.apache.sshd.common.channel.ChannelAsyncOutputStream.writeBuffer(ChannelAsyncOutputStream.java:102)
at org.apache.sshd.sftp.client.impl.DefaultSftpClient.send(DefaultSftpClient.java:299)
at org.apache.sshd.sftp.client.impl.AbstractSftpClient.checkHandle(AbstractSftpClient.java:230)
at org.apache.sshd.sftp.client.impl.AbstractSftpClient.openDir(AbstractSftpClient.java:829)
at org.apache.sshd.sftp.client.impl.SftpDirEntryIterator.<init>(SftpDirEntryIterator.java:60)
at org.apache.sshd.sftp.client.impl.SftpIterableDirEntry.iterator(SftpIterableDirEntry.java:64)
at org.apache.sshd.sftp.client.impl.SftpIterableDirEntry.iterator(SftpIterableDirEntry.java:34)
at java.base/java.lang.Iterable.spliterator(Iterable.java:101)
at org.springframework.integration.sftp.session.SftpSession.doList(SftpSession.java:103)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:69)
at org.springframework.integration.sftp.session.SftpSession.list(SftpSession.java:52)
at org.springframework.integration.file.remote.session.CachingSessionFactory$CachedSession.list(CachingSessionFactory.java:227)
at org.springframework.integration.file.remote.RemoteFileTemplate.lambda$list$5(RemoteFileTemplate.java:422)
at org.springframework.integration.file.remote.RemoteFileTemplate.execute(RemoteFileTemplate.java:452)
... 18 common frames omitted
We found out that issues is when you call RemoteFileTemplate.list()
method concurrently. Since ChannelAsyncOutputStream.writeBuffer()
cannot be caller concurrently.
Before upgrading to SB3 we had no issues like this.
So my question is, is this a bug in new implementation in SB3 using apache mina SSHD or is this expected behaviour and we should not call this method from different threads?