From 6a570765d4a987d489484e487e3f9a26c273b6fb Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Wed, 29 Apr 2009 13:22:42 +0000 Subject: [PATCH] Workaround for NPE in Tomcat on undeploy --- .../http/HttpTunnelingChannelHandler.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingChannelHandler.java b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingChannelHandler.java index dbc7eac9f4..752ed4d97d 100644 --- a/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingChannelHandler.java +++ b/src/main/java/org/jboss/netty/channel/socket/http/HttpTunnelingChannelHandler.java @@ -112,9 +112,7 @@ class HttpTunnelingChannelHandler extends SimpleChannelUpstreamHandler { cause = ex2; } } else { - if (invalidated.compareAndSet(false, true)) { - session.invalidate(); - } + invalidateHttpSession(); e.getChannel().close(); } } finally { @@ -132,16 +130,22 @@ class HttpTunnelingChannelHandler extends SimpleChannelUpstreamHandler { @Override public void exceptionCaught(ChannelHandlerContext ctx, ExceptionEvent e) throws Exception { logger.warn("Unexpected exception", e.getCause()); - if (invalidated.compareAndSet(false, true)) { - session.invalidate(); - } + invalidateHttpSession(); e.getChannel().close(); } @Override public void channelClosed(ChannelHandlerContext ctx, ChannelStateEvent e) throws Exception { + invalidateHttpSession(); + } + + private void invalidateHttpSession() { if (invalidated.compareAndSet(false, true)) { - session.invalidate(); + try { + session.invalidate(); + } catch (Exception e) { + // Gulp - https://jira.jboss.org/jira/browse/JBWEB-139 + } } }