[#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-07 22:03:05 +01:00
parent 87b853c60d
commit 87602fde25

View File

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