Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NettyClientTransport: use getOrCreate() for new instances of ChannelLogger AttributeKey. #7048

Merged
merged 10 commits into from May 21, 2020
15 changes: 14 additions & 1 deletion netty/src/main/java/io/grpc/netty/NettyClientTransport.java
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