Skip to content

Commit

Permalink
Fix NPE which is triggered if the destory method is called
Browse files Browse the repository at this point in the history
before channelOpen(..). See netty#143
  • Loading branch information
normanmaurer committed Jan 7, 2012
1 parent 521bf83 commit 7c41284
Showing 1 changed file with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -309,17 +309,23 @@ private void initialize(ChannelHandlerContext ctx) {

private void destroy(ChannelHandlerContext ctx) {
State state = (State) ctx.getAttachment();
if (state.readerIdleTimeout != null) {
state.readerIdleTimeout.cancel();
state.readerIdleTimeout = null;
}
if (state.writerIdleTimeout != null) {
state.writerIdleTimeout.cancel();
state.writerIdleTimeout = null;
}
if (state.allIdleTimeout != null) {
state.allIdleTimeout.cancel();
state.allIdleTimeout = null;
// Check if the state was set before, it may not if the destroy method was called before the
// channelOpen(...) method.
//
// See #143
if (state != null) {
if (state.readerIdleTimeout != null) {
state.readerIdleTimeout.cancel();
state.readerIdleTimeout = null;
}
if (state.writerIdleTimeout != null) {
state.writerIdleTimeout.cancel();
state.writerIdleTimeout = null;
}
if (state.allIdleTimeout != null) {
state.allIdleTimeout.cancel();
state.allIdleTimeout = null;
}
}
}

Expand Down

0 comments on commit 7c41284

Please sign in to comment.