Skip to content

Commit 4c8bc81

Browse files
committed
[netty#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.
1 parent dd80dbf commit 4c8bc81

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

common/src/main/java/io/netty/util/concurrent/GlobalEventExecutor.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,11 @@ public void execute(Runnable task) {
214214
private void startThread() {
215215
if (started.compareAndSet(false, true)) {
216216
Thread t = threadFactory.newThread(taskRunner);
217-
t.start();
217+
// Set the thread before starting it as otherwise inEventLoop() may return false and so produce
218+
// an assert error.
219+
// See https://github.com/netty/netty/issues/4357
218220
thread = t;
221+
t.start();
219222
}
220223
}
221224

0 commit comments

Comments
 (0)