Fix memory leak in NameResolverGroup
Motivation: NameResolverGroup uses the EventExecutor specified with getResolver() as the key of its internal map. Because the EventExecutor is often a wrapped one, such as PausibleChannelEventExecutor, which actually is a wrapper of the same executor, they should instantiate only one NameResolver. Modifications: Unwrap the EventExecutor before using it as the key of the internal map Result: Memory leak is gone.
This commit is contained in:
parent
5f8483646b
commit
d7f5353fe8
@ -49,7 +49,7 @@ public abstract class NameResolverGroup<T extends SocketAddress> implements Clos
|
||||
* {@link #newResolver(EventExecutor)} so that the new resolver is reused on another
|
||||
* {@link #getResolver(EventExecutor)} call with the same {@link EventExecutor}.
|
||||
*/
|
||||
public NameResolver<T> getResolver(final EventExecutor executor) {
|
||||
public NameResolver<T> getResolver(EventExecutor executor) {
|
||||
if (executor == null) {
|
||||
throw new NullPointerException("executor");
|
||||
}
|
||||
@ -58,6 +58,10 @@ public abstract class NameResolverGroup<T extends SocketAddress> implements Clos
|
||||
throw new IllegalStateException("executor not accepting a task");
|
||||
}
|
||||
|
||||
return getResolver0(executor.unwrap());
|
||||
}
|
||||
|
||||
private NameResolver<T> getResolver0(final EventExecutor executor) {
|
||||
NameResolver<T> r;
|
||||
synchronized (resolvers) {
|
||||
r = resolvers.get(executor);
|
||||
|
Loading…
Reference in New Issue
Block a user