From 0a2e5a7b3fb4d61ffe41bf191e6335b8dbfc589b Mon Sep 17 00:00:00 2001 From: Vojtech Krasa Date: Sun, 19 Apr 2015 01:34:53 +0200 Subject: [PATCH] #93 the session is closed when the channel is --- .../com/cloudhopper/smpp/impl/DefaultSmppSession.java | 1 + .../com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java | 8 ++++++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java b/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java index 66ff11b7..632f753e 100644 --- a/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java +++ b/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java @@ -708,6 +708,7 @@ public void fireChannelClosed() { // do nothing -- ignore it logger.debug("Unbind/close was requested, ignoring channelClosed event"); } else { + this.state.set(STATE_CLOSED); this.sessionHandler.fireChannelUnexpectedlyClosed(); } } diff --git a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java index 05edc849..3e764cc1 100644 --- a/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java +++ b/src/test/java/com/cloudhopper/smpp/impl/DefaultSmppSessionTest.java @@ -629,6 +629,7 @@ public void closeDoesNotTriggerUnexpectedlyClosedEvent() throws Exception { Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @@ -650,6 +651,7 @@ public void unbindWithNoResponseDoesNotTriggerUnexpectedlyClosedEvent() throws E Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @Test @@ -676,6 +678,7 @@ public boolean process(SmppSimulatorSessionHandler session, Channel channel, Pdu Assert.assertEquals(0, sessionHandler.getClosedCount()); Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); } @Test @@ -730,8 +733,9 @@ public void remoteCloseDoesTriggerUnexpectedlyClosedEvent() throws Exception { Thread.sleep(500); Assert.assertEquals(1, sessionHandler.getClosedCount()); - // DEFAULT handling is that we don't do anything special with this... - Assert.assertEquals(true, session.isBound()); + // the session is closed when the channel is + Assert.assertEquals(false, session.isBound()); + Assert.assertEquals(true, session.isClosed()); // unbind the session now -- this should work okay even though the channel is closed session.unbind(100);