Skip to content
15 changes: 14 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyClientTransport.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,20 @@
* A Netty-based {@link ConnectionClientTransport} implementation.
*/
class NettyClientTransport implements ConnectionClientTransport {
static final AttributeKey<ChannelLogger> 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<ChannelLogger> getOrCreateChannelLogger() {
AttributeKey<ChannelLogger> key = AttributeKey.valueOf("channelLogger");
if (key == null) {
key = AttributeKey.newInstance("channelLogger");
}
return key;
}

static final AttributeKey<ChannelLogger> LOGGER_KEY = getOrCreateChannelLogger();

private final InternalLogId logId;
private final Map<ChannelOption<?>, ?> channelOptions;
Expand Down