Exception logging

This commit is contained in:
Trustin Lee 2009-04-21 11:14:59 +00:00
parent 212be9327d
commit 75cf84c5da
2 changed files with 14 additions and 1 deletions

View File

@ -47,6 +47,8 @@ import org.jboss.netty.channel.socket.ClientSocketChannelFactory;
import org.jboss.netty.channel.socket.SocketChannel; import org.jboss.netty.channel.socket.SocketChannel;
import org.jboss.netty.channel.socket.SocketChannelConfig; import org.jboss.netty.channel.socket.SocketChannelConfig;
import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder; import org.jboss.netty.handler.codec.frame.DelimiterBasedFrameDecoder;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
import org.jboss.netty.util.internal.LinkedTransferQueue; import org.jboss.netty.util.internal.LinkedTransferQueue;
/** /**
@ -57,6 +59,9 @@ import org.jboss.netty.util.internal.LinkedTransferQueue;
class HttpTunnelingClientSocketChannel extends AbstractChannel class HttpTunnelingClientSocketChannel extends AbstractChannel
implements org.jboss.netty.channel.socket.SocketChannel { implements org.jboss.netty.channel.socket.SocketChannel {
static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpTunnelingClientSocketChannel.class);
private final Lock reconnectLock = new ReentrantLock(); private final Lock reconnectLock = new ReentrantLock();
volatile boolean awaitingInitialResponse = true; volatile boolean awaitingInitialResponse = true;
@ -257,6 +262,7 @@ class HttpTunnelingClientSocketChannel extends AbstractChannel
@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());
channel.close(); channel.close();
} }
} }

View File

@ -36,6 +36,8 @@ import org.jboss.netty.buffer.ChannelBuffer;
import org.jboss.netty.buffer.ChannelBuffers; import org.jboss.netty.buffer.ChannelBuffers;
import org.jboss.netty.channel.Channel; import org.jboss.netty.channel.Channel;
import org.jboss.netty.channel.MessageEvent; import org.jboss.netty.channel.MessageEvent;
import org.jboss.netty.logging.InternalLogger;
import org.jboss.netty.logging.InternalLoggerFactory;
/** /**
* A Servlet that acts as a proxy for a netty channel * A Servlet that acts as a proxy for a netty channel
@ -48,12 +50,15 @@ public class HttpTunnelingServlet extends HttpServlet {
private static final long serialVersionUID = -872309493835745385L; private static final long serialVersionUID = -872309493835745385L;
private static final InternalLogger logger =
InternalLoggerFactory.getInstance(HttpTunnelingServlet.class);
final static String CHANNEL_PROP = "channel"; final static String CHANNEL_PROP = "channel";
final static String HANDLER_PROP = "handler"; final static String HANDLER_PROP = "handler";
protected void doRequest( protected void doRequest(
HttpServletRequest request, HttpServletRequest request,
HttpServletResponse response) throws IOException { HttpServletResponse response) {
HttpSession session = request.getSession(); HttpSession session = request.getSession();
Channel channel = (Channel) session.getAttribute(CHANNEL_PROP); Channel channel = (Channel) session.getAttribute(CHANNEL_PROP);
HttpTunnelingChannelHandler handler = HttpTunnelingChannelHandler handler =
@ -64,6 +69,8 @@ public class HttpTunnelingServlet extends HttpServlet {
} else { } else {
pollResponse(channel, request, response, session, handler); pollResponse(channel, request, response, session, handler);
} }
} catch (Throwable t) {
logger.warn("Unexpected exception", t);
} finally { } finally {
try { try {
request.getInputStream().close(); request.getInputStream().close();