TerraNibble commented on issue #427:
URL: https://github.com/apache/mina-sshd/issues/427#issuecomment-1934985712
This is also easily reproducible using the including unit test
`ScpTest.testStreamsUploadAndDownload`. Running it you can observe the 5 second
exit timeout being hit.
Moving the `handleCommandExitStatus` to after the I/O stream
try-with-resources resolves the timeout but introduces a new race-condition
with the channels not shutting down gracefully.
I am still not sure why only `upload` is susceptible to this and not
`runUpload` based on their slightly different use of the `ScpHelper`.
You can simulate the issue by introducing a 200ms delay between the IO
streams and the channel closing. Hopefully this information is helpful.
```
ClientSession session = getClientSession();
ChannelExec channel = openCommandChannel(session, cmd);
try {
try (InputStream invOut = channel.getInvertedOut();
OutputStream invIn = channel.getInvertedIn()) {
// NOTE: we use a mock file system since we expect no
invocations for it
ScpHelper helper = new ScpHelper(session, invOut, invIn, new
MockFileSystem(remote), opener, listener);
Path mockPath = new MockPath(remote);
helper.sendStream(new DefaultScpStreamResolver(name,
mockPath, perms, time, size, local, cmd),
options.contains(Option.PreserveAttributes),
ScpHelper.DEFAULT_SEND_BUFFER_SIZE);
// handleCommandExitStatus(cmd, channel);
}
Thread.sleep(200);
// handleCommandExitStatus(cmd, channel);
} catch (InterruptedException e) {
throw new RuntimeException(e);
} finally {
channel.close(false);
}
```
--
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]