Remove unnecessary reference to AbstractChannel from AbstractChannelHandlerContext
Motivation: We not need to store another reference to AbstractChannel as we can access it through DefaultChannelHandlerContext. Modifications: Remove reference. Result: Cleaner code.
This commit is contained in:
parent
2d2e07578a
commit
cfa76f6326
@ -31,7 +31,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
private final boolean inbound;
|
||||
private final boolean outbound;
|
||||
private final AbstractChannel channel;
|
||||
private final DefaultChannelPipeline pipeline;
|
||||
private final String name;
|
||||
private boolean removed;
|
||||
@ -55,7 +54,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
throw new NullPointerException("name");
|
||||
}
|
||||
|
||||
channel = pipeline.channel;
|
||||
this.pipeline = pipeline;
|
||||
this.name = name;
|
||||
this.invoker = invoker;
|
||||
@ -66,7 +64,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
@Override
|
||||
public Channel channel() {
|
||||
return channel;
|
||||
return pipeline.channel();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -86,7 +84,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
public ChannelHandlerInvoker invoker() {
|
||||
if (invoker == null) {
|
||||
return channel.unsafe().invoker();
|
||||
return channel().unsafe().invoker();
|
||||
} else {
|
||||
return invoker;
|
||||
}
|
||||
@ -99,12 +97,12 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
@Override
|
||||
public <T> Attribute<T> attr(AttributeKey<T> key) {
|
||||
return channel.attr(key);
|
||||
return channel().attr(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> boolean hasAttr(AttributeKey<T> key) {
|
||||
return channel.hasAttr(key);
|
||||
return channel().hasAttr(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -326,7 +324,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
@Override
|
||||
public ChannelPromise voidPromise() {
|
||||
return channel.voidPromise();
|
||||
return channel().voidPromise();
|
||||
}
|
||||
|
||||
void setRemoved() {
|
||||
@ -345,6 +343,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return StringUtil.simpleClassName(ChannelHandlerContext.class) + '(' + name + ", " + channel + ')';
|
||||
return StringUtil.simpleClassName(ChannelHandlerContext.class) + '(' + name + ", " + channel() + ')';
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user