mirror of
https://github.com/hierynomus/sshj.git
synced 2025-12-06 23:30:55 +03:00
Fixed race condition in global request response handling
This commit is contained in:
@@ -216,13 +216,15 @@ public class ConnectionImpl
|
|||||||
throws ConnectionException {
|
throws ConnectionException {
|
||||||
synchronized (globalReqPromises) {
|
synchronized (globalReqPromises) {
|
||||||
Promise<SSHPacket, ConnectionException> gr = globalReqPromises.poll();
|
Promise<SSHPacket, ConnectionException> gr = globalReqPromises.poll();
|
||||||
if (gr == null)
|
if (gr == null) {
|
||||||
throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR,
|
throw new ConnectionException(DisconnectReason.PROTOCOL_ERROR,
|
||||||
"Got a global request response when none was requested");
|
"Got a global request response when none was requested");
|
||||||
else if (response == null)
|
} else if (response == null) {
|
||||||
gr.deliverError(new ConnectionException("Global request [" + gr + "] failed"));
|
gr.deliverError(new ConnectionException("Global request [" + gr + "] failed"));
|
||||||
else
|
} else {
|
||||||
gr.deliver(response);
|
// To prevent a race condition, copy the packet before delivering, as it will be handled in a different thread.
|
||||||
|
gr.deliver(new SSHPacket(response));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
16
src/test/resources/logback-test.xml
Normal file
16
src/test/resources/logback-test.xml
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
<configuration>
|
||||||
|
|
||||||
|
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%.-20thread] %-5level %logger{36} - %msg%n</pattern>
|
||||||
|
</encoder>
|
||||||
|
</appender>
|
||||||
|
|
||||||
|
<root level="info">
|
||||||
|
<appender-ref ref="STDOUT"/>
|
||||||
|
</root>
|
||||||
|
|
||||||
|
<logger name="net.schmizz.sshj" level="debug"/>
|
||||||
|
<logger name="net.schmizz.sshj.transport" level="trace" />
|
||||||
|
|
||||||
|
</configuration>
|
||||||
Reference in New Issue
Block a user