Reputation: 17601
Apache Mina - 2.0.1
I have a IoHandlerAdapter which has call backs on sessionOpened and sessionClosed. When I open a session I login to the server and start sending requests, in "sessionClosed" I just restart my application.
My application makes a check
if(!session.isClosing()) {
//write to socket
} else {
//throw a runtime exception. Hopefully the sessionClosed API gets
//called soon and the next time this call will succeed.
}
However I did notice that although the session.isClosing() returns true the session actually never gets closed. i.e, I dont really get the call back in my handler. Is this possible? How can I mitigate against such a risk. Can someone explain how long it takes for the close callback to be called?
Upvotes: 1
Views: 2412
Reputation: 653
I have seen this too. I believe this could be a race condition in the MINA layer:
http://mail-archives.apache.org/mod_mbox/mina-dev/200802.mbox/%[email protected]%3E
Upvotes: 0
Reputation: 9793
IMHO you should use a CloseFuture for this senario like so:
CloseFuture future = session.close(true);
// wait until its closed, up to 1 minute
future.awaitUninterruptibly(60000L);
if (future.isClosed()) {
System.out.println("Previous connection close completed");
}
Upvotes: 0