Call FastThreadLocal.removeAll() before notify termination future of … (#8666)

Motivation:

We should try removing all FastThreadLocals for the Thread before we notify the termination. future. The user may block on the future and once it unblocks the JVM may terminate and start unloading classes.

Modifications:

Remove all FastThreadLocals for the Thread before notify termination future.

Result:

Fixes https://github.com/netty/netty/issues/6596.
This commit is contained in:
Norman Maurer 2018-12-21 11:06:43 +01:00 committed by GitHub
parent e2d9665707
commit 6464c98743
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -939,6 +939,12 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx
try {
cleanup();
} finally {
// Lets remove all FastThreadLocals for the Thread as we are about to terminate and notify
// the future. The user may block on the future and once it unblocks the JVM may terminate
// and start unloading classes.
// See https://github.com/netty/netty/issues/6596.
FastThreadLocal.removeAll();
STATE_UPDATER.set(SingleThreadEventExecutor.this, ST_TERMINATED);
threadLock.release();
if (!taskQueue.isEmpty()) {
@ -947,7 +953,6 @@ public abstract class SingleThreadEventExecutor extends AbstractScheduledEventEx
"non-empty task queue (" + taskQueue.size() + ')');
}
}
terminationFuture.setSuccess(null);
}
}