From 89593a719bee31b54efd7f18734258d0d8a8a423 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 18 Jul 2014 07:08:30 +0200 Subject: [PATCH] [#2666] Fix possible NPE when try to fullfill connect ChannelPromise Motivation: Because of a missing return statement we may produce a NPE when try to fullfill the connect ChannelPromise when it was fullfilled before. Modification: Add missing return statement. Result: No more NPE. --- .../src/main/java/io/netty/channel/epoll/EpollSocketChannel.java | 1 + .../src/main/java/io/netty/channel/nio/AbstractNioChannel.java | 1 + 2 files changed, 2 insertions(+) diff --git a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java index d7f86b5236..de3e009b9a 100644 --- a/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java +++ b/transport-native-epoll/src/main/java/io/netty/channel/epoll/EpollSocketChannel.java @@ -554,6 +554,7 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So private void fulfillConnectPromise(ChannelPromise promise, Throwable cause) { if (promise == null) { // Closed via cancellation and the promise has been notified already. + return; } // Use tryFailure() instead of setFailure() to avoid the race against cancel(). diff --git a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java index 516a94f665..bf144dee78 100644 --- a/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java +++ b/transport/src/main/java/io/netty/channel/nio/AbstractNioChannel.java @@ -268,6 +268,7 @@ public abstract class AbstractNioChannel extends AbstractChannel { private void fulfillConnectPromise(ChannelPromise promise, Throwable cause) { if (promise == null) { // Closed via cancellation and the promise has been notified already. + return; } // Use tryFailure() instead of setFailure() to avoid the race against cancel().