[#4357] Fix possible assert error in GlobalEventExecutor

Motivation:

We started the thread before store it in a field which could lead to an assert error when the thread is executed before we actually store it.

Modifications:

Store thread before start it.

Result:

No more assert error possible.
This commit is contained in:
Norman Maurer 2015-10-14 19:35:04 +02:00
parent 6faef55aef
commit 562c2d1074

View File

@ -218,8 +218,11 @@ public final class GlobalEventExecutor extends AbstractScheduledEventExecutor {
private void startThread() {
if (started.compareAndSet(false, true)) {
Thread t = threadFactory.newThread(taskRunner);
t.start();
// Set the thread before starting it as otherwise inEventLoop() may return false and so produce
// an assert error.
// See https://github.com/netty/netty/issues/4357
thread = t;
t.start();
}
}