Workaround for NPE in Tomcat on undeploy

This commit is contained in:
Trustin Lee 2009-04-29 13:22:42 +00:00
parent 3ee287bf49
commit 6a570765d4

View File

@ -112,9 +112,7 @@ class HttpTunnelingChannelHandler extends SimpleChannelUpstreamHandler {
cause = ex2; cause = ex2;
} }
} else { } else {
if (invalidated.compareAndSet(false, true)) { invalidateHttpSession();
session.invalidate();
}
e.getChannel().close(); e.getChannel().close();
} }
} finally { } finally {
@ -132,16 +130,22 @@ class HttpTunnelingChannelHandler extends SimpleChannelUpstreamHandler {
@Override @Override
public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception {
logger.warn("Unexpected exception", e.getCause()); logger.warn("Unexpected exception", e.getCause());
if (invalidated.compareAndSet(false, true)) { invalidateHttpSession();
session.invalidate();
}
e.getChannel().close(); e.getChannel().close();
} }
@Override @Override
public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception {
invalidateHttpSession();
}
private void invalidateHttpSession() {
if (invalidated.compareAndSet(false, true)) { if (invalidated.compareAndSet(false, true)) {
session.invalidate(); try {
session.invalidate();
} catch (Exception e) {
// Gulp - https://jira.jboss.org/jira/browse/JBWEB-139
}
} }
} }