[#2215] DefaultChannelHandlerContext tasks needs to be volatile to ensure every thread only see full initialized instances

This commit is contained in:
Norman Maurer 2014-02-08 10:35:54 +01:00
parent d8c1409820
commit bd20f80ca0

View File

@ -194,10 +194,12 @@ final class DefaultChannelHandlerContext implements ChannelHandlerContext, Resou
private ChannelFuture succeededFuture;
// Lazily instantiated tasks used to trigger events to a handler with different executor.
Runnable invokeChannelReadCompleteTask;
Runnable invokeReadTask;
Runnable invokeFlushTask;
Runnable invokeChannelWritableStateChangedTask;
// These needs to be volatile as otherwise an other Thread may see an half initialized instance.
// See the JMM for more details
volatile Runnable invokeChannelReadCompleteTask;
volatile Runnable invokeReadTask;
volatile Runnable invokeFlushTask;
volatile Runnable invokeChannelWritableStateChangedTask;
DefaultChannelHandlerContext(
DefaultChannelPipeline pipeline, ChannelHandlerInvoker invoker, String name, ChannelHandler handler) {