diff --git a/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java b/src/main/java/com/cloudhopper/smpp/impl/DefaultSmppSession.java index 66ff11b7..03d331d3 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 { + 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);