From fb8cc156f33447c29bd32ba6e022d9af42703be7 Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Thu, 25 Jun 2009 09:18:14 +0000 Subject: [PATCH] Fixed NPE in OioWorker.write when the socket is closed already --- .../org/jboss/netty/channel/socket/oio/OioWorker.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java index 5622405655..a222510e60 100644 --- a/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/oio/OioWorker.java @@ -117,7 +117,15 @@ class OioWorker implements Runnable { static void write( OioSocketChannel channel, ChannelFuture future, Object message) { + OutputStream out = channel.getOutputStream(); + if (out == null) { + Exception e = new ClosedChannelException(); + future.setFailure(e); + fireExceptionCaught(channel, e); + return; + } + try { ChannelBuffer a = (ChannelBuffer) message; int bytes = a.readableBytes();