diff --git a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionHandlerTest.java b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionHandlerTest.java index 742d529f9d..4ac2e1da93 100644 --- a/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionHandlerTest.java +++ b/codec-http2/src/test/java/io/netty/handler/codec/http2/Http2ConnectionHandlerTest.java @@ -27,6 +27,7 @@ import io.netty.channel.DefaultChannelPromise; import io.netty.util.ReferenceCountUtil; import io.netty.util.concurrent.EventExecutor; import io.netty.util.concurrent.GenericFutureListener; +import io.netty.util.concurrent.ImmediateEventExecutor; import io.netty.util.concurrent.Promise; import org.junit.After; import org.junit.Before; @@ -124,7 +125,7 @@ public class Http2ConnectionHandlerTest { public void setup() throws Exception { MockitoAnnotations.initMocks(this); - promise = new DefaultChannelPromise(channel); + promise = new DefaultChannelPromise(channel, ImmediateEventExecutor.INSTANCE); Throwable fakeException = new RuntimeException("Fake exception"); when(encoder.connection()).thenReturn(connection); diff --git a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java index e7218fdc84..cd19da4876 100644 --- a/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java +++ b/common/src/main/java/io/netty/util/concurrent/DefaultPromise.java @@ -60,7 +60,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { * * Threading - synchronized(this). We must support adding listeners when there is no EventExecutor. */ - private volatile Object listeners; + private Object listeners; /** * Threading - synchronized(this). We are required to hold the monitor to use Java's underlying wait()/notifyAll(). */ @@ -417,13 +417,6 @@ public class DefaultPromise extends AbstractFuture implements Promise { } private void notifyListeners() { - if (listeners == null) { - return; - } - notifyListenersWithStackOverFlowProtection(); - } - - private void notifyListenersWithStackOverFlowProtection() { EventExecutor executor = executor(); if (executor.inEventLoop()) { final InternalThreadLocalMap threadLocals = InternalThreadLocalMap.get(); @@ -448,7 +441,7 @@ public class DefaultPromise extends AbstractFuture implements Promise { } /** - * The logic in this method should be identical to {@link #notifyListenersWithStackOverFlowProtection()} but + * The logic in this method should be identical to {@link #notifyListeners()} but * cannot share code because the listener(s) cannot be cached for an instance of {@link DefaultPromise} since the * listener(s) may be changed and is protected by a synchronized operation. */