diff --git a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java index bd00da98384..7c009340a4f 100644 --- a/netty/src/main/java/io/grpc/netty/NettyClientTransport.java +++ b/netty/src/main/java/io/grpc/netty/NettyClientTransport.java @@ -68,7 +68,20 @@ * A Netty-based {@link ConnectionClientTransport} implementation. */ class NettyClientTransport implements ConnectionClientTransport { - static final AttributeKey LOGGER_KEY = AttributeKey.newInstance("channelLogger"); + + /** + * Get the existing {@link ChannelLogger} key in case a separate, isolated class loader has + * already created {@link LOGGER_KEY}. + */ + private static final AttributeKey getOrCreateChannelLogger() { + AttributeKey key = AttributeKey.valueOf("channelLogger"); + if (key == null) { + key = AttributeKey.newInstance("channelLogger"); + } + return key; + } + + static final AttributeKey LOGGER_KEY = getOrCreateChannelLogger(); private final InternalLogId logId; private final Map, ?> channelOptions;