Skip to content

Commit

Permalink
Fix for DIRMINA-999
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffmaury committed Dec 7, 2014
1 parent f59036b commit 244bc25
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
Expand Up @@ -326,6 +326,7 @@ public void processWrite(SelectorLoop selectorLoop) {

// we was flushing writes, now we to the close
channelClose();
processSessionClosed();
} else {
// no more write event needed
selectorLoop.modifyRegistration(false, !isReadSuspended(), false, (SelectorListener) this,
Expand Down
Expand Up @@ -80,4 +80,34 @@ public void sessionClosed(final IoSession session) {
closedLatch.countDown();
}
}

/**
* Test added for DIRMINA-999
*/
@Test
public void checkSessionCloseEventIsSentClientSideWhenImmediateIsFalse() throws IOException, InterruptedException,
ExecutionException {

NioTcpServer server = new NioTcpServer();
server.bind(0);

NioTcpClient client = new NioTcpClient();
final CountDownLatch closeCounter = new CountDownLatch(1);
client.setIoHandler(new AbstractIoHandler() {

@Override
public void sessionOpened(IoSession session) {
session.close(false);
}

@Override
public void sessionClosed(IoSession session) {
closeCounter.countDown();
}

});
client.connect(new InetSocketAddress(server.getServerSocketChannel().socket().getLocalPort()));
assertTrue(closeCounter.await(WAIT_TIME, TimeUnit.MILLISECONDS));
}

}

0 comments on commit 244bc25

Please sign in to comment.