Fixed issue: NETTY-372 NullPointerException in ChunkedWriteHandler

This commit is contained in:
Trustin Lee 2011-02-01 12:20:43 +09:00
parent a5aef71218
commit 4c9b4329f2

View File

@ -199,6 +199,7 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
// attempt for the current request has been failed. // attempt for the current request has been failed.
currentEvent = null; currentEvent = null;
} else { } else {
final MessageEvent currentEvent = this.currentEvent;
Object m = currentEvent.getMessage(); Object m = currentEvent.getMessage();
if (m instanceof ChunkedInput) { if (m instanceof ChunkedInput) {
ChunkedInput chunks = (ChunkedInput) m; ChunkedInput chunks = (ChunkedInput) m;
@ -215,7 +216,6 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
} }
endOfInput = chunks.isEndOfInput(); endOfInput = chunks.isEndOfInput();
} catch (Throwable t) { } catch (Throwable t) {
MessageEvent currentEvent = this.currentEvent;
this.currentEvent = null; this.currentEvent = null;
currentEvent.getFuture().setFailure(t); currentEvent.getFuture().setFailure(t);
@ -226,7 +226,6 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
} }
ChannelFuture writeFuture; ChannelFuture writeFuture;
final MessageEvent currentEvent = this.currentEvent;
if (endOfInput) { if (endOfInput) {
this.currentEvent = null; this.currentEvent = null;
closeInput(chunks); closeInput(chunks);
@ -255,7 +254,6 @@ public class ChunkedWriteHandler implements ChannelUpstreamHandler, ChannelDowns
break; break;
} }
} else { } else {
MessageEvent currentEvent = this.currentEvent;
this.currentEvent = null; this.currentEvent = null;
ctx.sendDownstream(currentEvent); ctx.sendDownstream(currentEvent);
} }