From 3b0f45c93cdb56bb0edc9c0ff52338ec879fc97c Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Tue, 31 Jan 2012 11:07:33 +0100 Subject: [PATCH] Fix possible NPE which will be thrown if the Buffer was set to null and after that Exception was thrown. See #166 --- .../java/org/jboss/netty/channel/socket/nio/NioWorker.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java index 5554bee218..84b47340d0 100644 --- a/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java +++ b/src/main/java/org/jboss/netty/channel/socket/nio/NioWorker.java @@ -495,7 +495,9 @@ class NioWorker implements Runnable { } catch (AsynchronousCloseException e) { // Doesn't need a user attention - ignore. } catch (Throwable t) { - buf.release(); + if (buf != null) { + buf.release(); + } channel.currentWriteEvent = null; channel.currentWriteBuffer = null; buf = null;