seeseemelk opened a new issue, #774:
URL: https://github.com/apache/mina-sshd/issues/774
### Version
4160b6e3e394ff03f8439fb3202eb7cd7026a659
### Bug description
The following test results in the exception
`org.apache.sshd.common.io.WritePendingException: A write operation is already
pending; cannot write 29 bytes`.
This is regression is present since version
`4160b6e3e394ff03f8439fb3202eb7cd7026a659` and is still present in `2.15.0`.
(Note: I removed the actual keypair and passphrase that is being used in my
test.)
The test file is roughly eight megabytes in size.
```java
public final class MyTest {
private static final String FILENAME = "myfile.bin";
private static final String KEYPAIR
= "keypair_in_base64";
private static final String PASSPHRASE = "passphrase";
@Test
void myTest() throws IOException, GeneralSecurityException {
KeyPairResourceLoader loader =
SecurityUtils.getKeyPairResourceParser();
Collection<KeyPair> keys = loader.loadKeyPairs(null,
null,
FilePasswordProvider.of(PASSPHRASE),
new BufferedReader(new InputStreamReader(new
ByteArrayInputStream(Base64.getDecoder().decode(KEYPAIR)))));
KeyPair keypair = keys.iterator().next();
SshClient sshClient = ClientBuilder.builder()
.serverKeyVerifier((session, socketAddress, serverKey) ->
true)
.hostConfigEntryResolver(HostConfigEntryResolver.EMPTY)
.build();
SimpleClient client = SshClient.wrapAsSimpleClient(sshClient);
sshClient.start();
ClientSession session = client.sessionLogin("localhost", 8235,
"app", keypair);
String fromLocation = "/src/" + FILENAME;
String toLocation = "/dest/" + FILENAME;
try (SftpClient sftp =
SftpClientFactory.instance().createSftpClient(session).singleSessionInstance())
{
try (InputStream input = sftp.read(fromLocation);
OutputStream output = sftp.write(toLocation,
SftpClient.OpenMode.Create, SftpClient.OpenMode.Write)) {
IOUtils.copy(input, output);
}
}
}
}
```
### Actual behavior
It throws the following exception:
`org.apache.sshd.common.io.WritePendingException: A write operation is already
pending; cannot write 29 bytes`
### Expected behavior
The test should pass without errors.
### Relevant log output
```Shell
org.apache.sshd.common.io.WritePendingException: A write operation is
already pending; cannot write 29 bytes
at
org.apache.sshd.common.channel.ChannelAsyncOutputStream.writeBuffer(ChannelAsyncOutputStream.java:110)
at
org.apache.sshd.sftp.client.impl.DefaultSftpClient.write(DefaultSftpClient.java:308)
at
org.apache.sshd.sftp.client.impl.DefaultSftpClient.send(DefaultSftpClient.java:272)
at
org.apache.sshd.sftp.client.impl.SftpInputStreamAsync.sendRequests(SftpInputStreamAsync.java:255)
at
org.apache.sshd.sftp.client.impl.SftpInputStreamAsync.doRead(SftpInputStreamAsync.java:195)
at
org.apache.sshd.sftp.client.impl.SftpInputStreamAsync.read(SftpInputStreamAsync.java:137)
at java.base/java.io.InputStream.read(InputStream.java:220)
at
org.testcontainers.shaded.org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2314)
at
org.testcontainers.shaded.org.apache.commons.io.IOUtils.copy(IOUtils.java:2270)
at
org.testcontainers.shaded.org.apache.commons.io.IOUtils.copyLarge(IOUtils.java:2291)
at
org.testcontainers.shaded.org.apache.commons.io.IOUtils.copy(IOUtils.java:2246)
at org.apache.sshd.sftp.client.MyTest.myTest(MyTest.java:77)
```
### Other information
The test communicates with OpenSSH_9.2p1 Debian-2, OpenSSL 3.0.8 7 Feb 2023
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]