Discussion:
[1/2] mina-sshd git commit: [SSHD-858] Allow users to handle incoming un-implemented session messages via ReservedSessionMessagesHandler
l***@apache.org
2018-10-29 19:31:01 UTC
Permalink
Repository: mina-sshd
Updated Branches:
refs/heads/master 32e1877d0 -> 0241783b1


[SSHD-858] Allow users to handle incoming un-implemented session messages via ReservedSessionMessagesHandler


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/0241783b
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/0241783b
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/0241783b

Branch: refs/heads/master
Commit: 0241783b13c6dfa9b89f3ddcf318ff473ee35772
Parents: 9d17811
Author: Lyor Goldstein <***@apache.org>
Authored: Mon Oct 29 11:27:57 2018 +0200
Committer: Lyor Goldstein <***@apache.org>
Committed: Mon Oct 29 21:36:26 2018 +0200

----------------------------------------------------------------------
README.md | 20 +++++++++++++++-----
.../session/ReservedSessionMessagesHandler.java | 8 +++++---
.../helpers/AbstractConnectionService.java | 2 +-
.../common/session/helpers/AbstractSession.java | 12 +++++++++---
.../ReservedSessionMessagesHandlerAdapter.java | 17 ++++++++++-------
.../common/session/helpers/SessionHelper.java | 2 +-
.../session/helpers/AbstractSessionTest.java | 2 +-
7 files changed, 42 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/README.md
----------------------------------------------------------------------
diff --git a/README.md b/README.md
index 30d7922..dd17a91 100644
--- a/README.md
+++ b/README.md
@@ -1335,6 +1335,17 @@ configuration properties that can be used to configure said behavior - please be

#### `ReservedSessionMessagesHandler`

+Can be used to handle the following cases:
+
+* [SSH_MSG_IGNORE](https://tools.ietf.org/html/rfc4253#section-11.2)
+* [SSH_MSG_DEBUG](https://tools.ietf.org/html/rfc4253#section-11.3)
+* [SSH_MSG_UNIMPLEMENTED](https://tools.ietf.org/html/rfc4253#section-11.4)
+* Any other unrecognized message received in the session.
+
+**Note:** The `handleUnimplementedMessage` method serves both for handling `SSH_MSG_UNIMPLEMENTED` and any other unrecognized
+message received in the session as well.
+
+
```java

// client side
@@ -1386,11 +1397,10 @@ rather than being accumulated. However, one can use the `EventListenerUtils` and

### `RequestHandler`(s)

-The code supports both [global](https://tools.ietf.org/html/rfc4254#section-4) and [channel-specific](https://tools.ietf.org/html/rfc4254#section-5.4) requests via the registration of `RequestHandler`(s).
-The global handlers are derived from `ConnectionServiceRequestHandler`(s) whereas the channel-specific
-ones are derived from `ChannelRequestHandler`(s). In order to add a handler one need only register the correct
-implementation and handle the request when it is detected. For global request handlers this is done by registering
-them on the server:
+The code supports both [global](https://tools.ietf.org/html/rfc4254#section-4) and [channel-specific](https://tools.ietf.org/html/rfc4254#section-5.4)
+requests via the registration of `RequestHandler`(s). The global handlers are derived from `ConnectionServiceRequestHandler`(s) whereas the channel-specific
+ones are derived from `ChannelRequestHandler`(s). In order to add a handler one need only register the correct implementation and handle the request when
+it is detected. For global request handlers this is done by registering them on the server:

```java


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/main/java/org/apache/sshd/common/session/ReservedSessionMessagesHandler.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/ReservedSessionMessagesHandler.java b/sshd-core/src/main/java/org/apache/sshd/common/session/ReservedSessionMessagesHandler.java
index 08292ea..c7c6012 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/ReservedSessionMessagesHandler.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/ReservedSessionMessagesHandler.java
@@ -54,14 +54,16 @@ public interface ReservedSessionMessagesHandler extends SshdEventListener {
}

/**
- * Invoked when an {@code SSH_MSG_UNIMPLEMENTED} packet is received
+ * Invoked when a packet with an un-implemented message is received - including
+ * {@code SSH_MSG_UNIMPLEMENTED} itself
*
* @param session The {@code Session} through which the message was received
- * @param buffer The {@code Buffer} containing the data
+ * @param cmd The received (un-implemented) command
+ * @param buffer The {@code Buffer} containing the data - positioned just beyond the command
* @throws Exception If failed to handle the message
* @see <A HREF="https://tools.ietf.org/html/rfc4253#section-11.4">RFC 4253 - section 11.4</A>
*/
- default void handleUnimplementedMessage(Session session, Buffer buffer) throws Exception {
+ default void handleUnimplementedMessage(Session session, int cmd, Buffer buffer) throws Exception {
// ignored
}
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
index c66a7e3..fcac6f2 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractConnectionService.java
@@ -381,7 +381,7 @@ public abstract class AbstractConnectionService
log.debug("process({}) Unsupported command: {}",
session, SshConstants.getCommandMessageName(cmd));
}
- session.notImplemented();
+ session.notImplemented(cmd, buffer);
}
}
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 1862dc6..1f5efbb 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -64,6 +64,7 @@ import org.apache.sshd.common.kex.KeyExchange;
import org.apache.sshd.common.mac.Mac;
import org.apache.sshd.common.mac.MacInformation;
import org.apache.sshd.common.random.Random;
+import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
import org.apache.sshd.common.session.SessionListener;
import org.apache.sshd.common.session.SessionWorkBuffer;
import org.apache.sshd.common.util.EventListenerUtils;
@@ -408,7 +409,7 @@ public abstract class AbstractSession extends SessionHelper {
log.debug("process({}) Unsupported command: {}",
this, SshConstants.getCommandMessageName(cmd));
}
- notImplemented();
+ notImplemented(cmd, buffer);
}
break;
}
@@ -1346,11 +1347,16 @@ public abstract class AbstractSession extends SessionHelper {
* contain the sequence id of the unsupported packet: this number
* is assumed to be the last packet received.
*
+ * @param cmd The un-implemented command value
+ * @param buffer The {@link Buffer} that contains the command. <b>Note:</b> the
+ * buffer's read position is just beyond the command.
* @return An {@link IoWriteFuture} that can be used to wait for packet write completion
- * @throws IOException if an error occurred sending the packet
+ * @throws Exception if an error occurred while handling the packet.
* @see #sendNotImplemented(long)
*/
- protected IoWriteFuture notImplemented() throws IOException {
+ protected IoWriteFuture notImplemented(int cmd, Buffer buffer) throws Exception {
+ ReservedSessionMessagesHandler handler = resolveReservedSessionMessagesHandler();
+ handler.handleUnimplementedMessage(this, cmd, buffer);
return sendNotImplemented(seqi - 1L);
}


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/ReservedSessionMessagesHandlerAdapter.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/ReservedSessionMessagesHandlerAdapter.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/ReservedSessionMessagesHandlerAdapter.java
index bcc0a5f..6abd4b3 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/ReservedSessionMessagesHandlerAdapter.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/ReservedSessionMessagesHandlerAdapter.java
@@ -19,6 +19,7 @@

package org.apache.sshd.common.session.helpers;

+import org.apache.sshd.common.SshConstants;
import org.apache.sshd.common.session.ReservedSessionMessagesHandler;
import org.apache.sshd.common.session.Session;
import org.apache.sshd.common.util.buffer.Buffer;
@@ -68,13 +69,15 @@ public class ReservedSessionMessagesHandlerAdapter
}

@Override
- public void handleUnimplementedMessage(Session session, Buffer buffer) throws Exception {
- handleUnimplementedMessage(session, buffer, buffer.getUInt());
- }
-
- public void handleUnimplementedMessage(Session session, Buffer buffer, long seqNo) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("handleUnimplementedMessage({}) SSH_MSG_UNIMPLEMENTED - seqNo={}", session, seqNo);
+ public void handleUnimplementedMessage(Session session, int cmd, Buffer buffer) throws Exception {
+ boolean debugEnabled = log.isDebugEnabled();
+ if (debugEnabled) {
+ if (cmd == SshConstants.SSH_MSG_UNIMPLEMENTED) {
+ long seqNo = buffer.getUInt();
+ log.debug("handleUnimplementedMessage({}) SSH_MSG_UNIMPLEMENTED - seqNo={}", session, seqNo);
+ } else {
+ log.debug("handleUnimplementedMessage({}): {}", session, SshConstants.getCommandMessageName(cmd));
+ }
}
}
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 50ae49a..f4d4f30 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -347,7 +347,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
resetIdleTimeout();

ReservedSessionMessagesHandler handler = resolveReservedSessionMessagesHandler();
- handler.handleUnimplementedMessage(this, buffer);
+ handler.handleUnimplementedMessage(this, SshConstants.SSH_MSG_UNIMPLEMENTED, buffer);
}

@Override

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/0241783b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
index 682c11a..cf6779f 100644
--- a/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/common/session/helpers/AbstractSessionTest.java
@@ -202,7 +202,7 @@ public class AbstractSessionTest extends BaseTestSupport {
public void testMalformedUnimplementedMessage() throws Exception {
session.setReservedSessionMessagesHandler(new ReservedSessionMessagesHandler() {
@Override
- public void handleUnimplementedMessage(Session session, Buffer buffer) throws Exception {
+ public void handleUnimplementedMessage(Session session, int cmd, Buffer buffer) throws Exception {
fail("Unexpected invocation: available=" + buffer.available());
}
});
l***@apache.org
2018-10-29 19:31:02 UTC
Permalink
[SSHD-857] Add session disconnect event signalling to SessionListener


Project: http://git-wip-us.apache.org/repos/asf/mina-sshd/repo
Commit: http://git-wip-us.apache.org/repos/asf/mina-sshd/commit/9d17811c
Tree: http://git-wip-us.apache.org/repos/asf/mina-sshd/tree/9d17811c
Diff: http://git-wip-us.apache.org/repos/asf/mina-sshd/diff/9d17811c

Branch: refs/heads/master
Commit: 9d17811c57ea06b2280150540eb4b43b9c78463f
Parents: 32e1877
Author: Lyor Goldstein <***@apache.org>
Authored: Mon Oct 29 10:04:20 2018 +0200
Committer: Lyor Goldstein <***@apache.org>
Committed: Mon Oct 29 21:36:26 2018 +0200

----------------------------------------------------------------------
.../sshd/common/session/SessionListener.java | 15 +++++
.../common/session/helpers/AbstractSession.java | 23 -------
.../common/session/helpers/SessionHelper.java | 69 ++++++++++++++++++--
.../java/org/apache/sshd/client/ClientTest.java | 6 ++
.../java/org/apache/sshd/server/ServerTest.java | 13 +++-
5 files changed, 96 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d17811c/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
index f3280dd..544f89c 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/SessionListener.java
@@ -94,6 +94,21 @@ public interface SessionListener extends SshdEventListener {
}

/**
+ * Invoked when {@code SSH_MSG_DISCONNECT} message was sent/received
+ *
+ * @param session The referenced {@link Session}
+ * @param reason The signaled reason code
+ * @param msg The provided description message (may be empty)
+ * @param language The language tag indicator (may be empty)
+ * @param initiator Whether the session is the sender or recipient of the message
+ * @see <a href="https://tools.ietf.org/html/rfc4253#section-11.1">RFC 4253 - section 11.1</a>
+ */
+ default void sessionDisconnect(
+ Session session, int reason, String msg, String language, boolean initiator) {
+ // ignored
+ }
+
+ /**
* A session has been closed
*
* @param session The closed {@link Session}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d17811c/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
index 1b1217a..1862dc6 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/AbstractSession.java
@@ -467,29 +467,6 @@ public abstract class AbstractSession extends SessionHelper {
}
}

- protected void handleDisconnect(Buffer buffer) throws Exception {
- int code = buffer.getInt();
- String message = buffer.getString();
- String languageTag;
- // SSHD-738: avoid spamming the log with uninteresting
- // messages caused by buggy OpenSSH < 5.5
- if (buffer.available() > 0) {
- languageTag = buffer.getString();
- } else {
- languageTag = "";
- }
- handleDisconnect(code, message, languageTag, buffer);
- }
-
- protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception {
- if (log.isDebugEnabled()) {
- log.debug("handleDisconnect({}) SSH_MSG_DISCONNECT reason={}, [lang={}] msg={}",
- this, SshConstants.getDisconnectReasonName(code), lang, msg);
- }
-
- close(true);
- }
-
protected void handleServiceRequest(Buffer buffer) throws Exception {
String serviceName = buffer.getString();
handleServiceRequest(serviceName, buffer);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d17811c/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
index 9dcc58c..50ae49a 100644
--- a/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
+++ b/sshd-core/src/main/java/org/apache/sshd/common/session/helpers/SessionHelper.java
@@ -525,6 +525,7 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
(manager == null) ? null : manager.getSessionListenerProxy(),
getSessionListenerProxy()
};
+
Throwable err = null;
for (SessionListener l : listeners) {
if (l == null) {
@@ -853,16 +854,20 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
@Override
public void disconnect(int reason, String msg) throws IOException {
log.info("Disconnecting({}): {} - {}", this, SshConstants.getDisconnectReasonName(reason), msg);
+ String languageTag = ""; // TODO configure language...
+ signalDisconnect(reason, msg, languageTag, true);
+
Buffer buffer = createBuffer(SshConstants.SSH_MSG_DISCONNECT, msg.length() + Short.SIZE);
buffer.putInt(reason);
buffer.putString(msg);
- buffer.putString(""); // TODO configure language...
+ buffer.putString("");

// Write the packet with a timeout to ensure a timely close of the session
// in case the consumer does not read packets anymore.
long disconnectTimeoutMs = this.getLongProperty(
FactoryManager.DISCONNECT_TIMEOUT, FactoryManager.DEFAULT_DISCONNECT_TIMEOUT);
- writePacket(buffer, disconnectTimeoutMs, TimeUnit.MILLISECONDS).addListener(future -> {
+ IoWriteFuture packetFuture = writePacket(buffer, disconnectTimeoutMs, TimeUnit.MILLISECONDS);
+ packetFuture.addListener(future -> {
Throwable t = future.getException();
if (log.isDebugEnabled()) {
if (t == null) {
@@ -887,6 +892,62 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
});
}

+ protected void handleDisconnect(Buffer buffer) throws Exception {
+ int code = buffer.getInt();
+ String message = buffer.getString();
+ String languageTag;
+ // SSHD-738: avoid spamming the log with uninteresting
+ // messages caused by buggy OpenSSH < 5.5
+ if (buffer.available() > 0) {
+ languageTag = buffer.getString();
+ } else {
+ languageTag = "";
+ }
+ handleDisconnect(code, message, languageTag, buffer);
+ }
+
+ protected void handleDisconnect(int code, String msg, String lang, Buffer buffer) throws Exception {
+ if (log.isDebugEnabled()) {
+ log.debug("handleDisconnect({}) SSH_MSG_DISCONNECT reason={}, [lang={}] msg={}",
+ this, SshConstants.getDisconnectReasonName(code), lang, msg);
+ }
+
+ signalDisconnect(code, msg, lang, false);
+ close(true);
+ }
+
+ protected void signalDisconnect(int code, String msg, String lang, boolean initiator) {
+ try {
+ invokeSessionSignaller(l -> {
+ signalDisconnect(l, code, msg, lang, initiator);
+ return null;
+ });
+ } catch (Throwable err) {
+ Throwable e = GenericUtils.peelException(err);
+ if (log.isDebugEnabled()) {
+ log.debug("signalDisconnect(" + this + ") signal session disconnect details", e);
+ }
+
+ if (log.isTraceEnabled()) {
+ Throwable[] suppressed = e.getSuppressed();
+ if (GenericUtils.length(suppressed) > 0) {
+ for (Throwable s : suppressed) {
+ log.trace("signalDisconnect(" + this + ") suppressed session disconnect signalling", s);
+ }
+ }
+ }
+ }
+ }
+
+ protected void signalDisconnect(
+ SessionListener listener, int code, String msg, String lang, boolean initiator) {
+ if (listener == null) {
+ return;
+ }
+
+ listener.sessionDisconnect(this, code, msg, lang, initiator);
+ }
+
/**
* Handle any exceptions that occurred on this session.
* The session will be closed and a disconnect packet will be
@@ -946,14 +1007,14 @@ public abstract class SessionHelper extends AbstractKexFactoryManager implements
} catch (Throwable err) {
Throwable e = GenericUtils.peelException(err);
if (log.isDebugEnabled()) {
- log.debug("exceptionCaught(" + this + ") signal session exception details", e);
+ log.debug("signalExceptionCaught(" + this + ") signal session exception details", e);
}

if (log.isTraceEnabled()) {
Throwable[] suppressed = e.getSuppressed();
if (GenericUtils.length(suppressed) > 0) {
for (Throwable s : suppressed) {
- log.trace("exceptionCaught(" + this + ") suppressed session exception signalling", s);
+ log.trace("signalExceptionCaught(" + this + ") suppressed session exception signalling", s);
}
}
}

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d17811c/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
index 59c69e3..4fdfb1d 100644
--- a/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/client/ClientTest.java
@@ -156,6 +156,12 @@ public class ClientTest extends BaseTestSupport {
}

@Override
+ public void sessionDisconnect(Session session, int reason, String msg, String language, boolean initiator) {
+ assertObjectInstanceOf("Non client session exception notification", ClientSession.class, session);
+ assertTrue("Invalid reason code: " + reason, reason >= 0);
+ }
+
+ @Override
public void sessionClosed(Session session) {
assertObjectInstanceOf("Non client session closure notification", ClientSession.class, session);
assertSame("Mismatched client session closure instance", clientSessionHolder.getAndSet(null), session);

http://git-wip-us.apache.org/repos/asf/mina-sshd/blob/9d17811c/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
----------------------------------------------------------------------
diff --git a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
index ca4e282..9944cde 100644
--- a/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
+++ b/sshd-core/src/test/java/org/apache/sshd/server/ServerTest.java
@@ -228,7 +228,14 @@ public class ServerTest extends BaseTestSupport {

@Override
public void sessionException(Session session, Throwable t) {
- outputDebugMessage("Session %s exception %s caught: %s", session, t.getClass().getSimpleName(), t.getMessage());
+ outputDebugMessage("Session %s exception %s caught: %s",
+ session, t.getClass().getSimpleName(), t.getMessage());
+ }
+
+ @Override
+ public void sessionDisconnect(Session session, int reason, String msg, String language, boolean initiator) {
+ outputDebugMessage("Session %s disconnected (sender=%s): reason=%d, message=%s",
+ session, initiator, reason, msg);
}

@Override
@@ -255,9 +262,9 @@ public class ServerTest extends BaseTestSupport {
assertTrue("No changes in open channels", channelListener.waitForOpenChannelsChange(5L, TimeUnit.SECONDS));

Collection<ClientSession.ClientSessionEvent> res =
- s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testIdleTimeout);
+ s.waitFor(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED), 2L * testIdleTimeout);
assertTrue("Session should be closed and authenticated: " + res,
- res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED)));
+ res.containsAll(EnumSet.of(ClientSession.ClientSessionEvent.CLOSED, ClientSession.ClientSessionEvent.AUTHED)));
} finally {
client.stop();
}

Loading...