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:
Norman Maurer 2015-11-16 11:49:45 -08:00
parent 2d2e07578a
commit cfa76f6326

View File

@ -31,7 +31,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
private final boolean inbound; private final boolean inbound;
private final boolean outbound; private final boolean outbound;
private final AbstractChannel channel;
private final DefaultChannelPipeline pipeline; private final DefaultChannelPipeline pipeline;
private final String name; private final String name;
private boolean removed; private boolean removed;
@ -55,7 +54,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
throw new NullPointerException("name"); throw new NullPointerException("name");
} }
channel = pipeline.channel;
this.pipeline = pipeline; this.pipeline = pipeline;
this.name = name; this.name = name;
this.invoker = invoker; this.invoker = invoker;
@ -66,7 +64,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
@Override @Override
public Channel channel() { public Channel channel() {
return channel; return pipeline.channel();
} }
@Override @Override
@ -86,7 +84,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
public ChannelHandlerInvoker invoker() { public ChannelHandlerInvoker invoker() {
if (invoker == null) { if (invoker == null) {
return channel.unsafe().invoker(); return channel().unsafe().invoker();
} else { } else {
return invoker; return invoker;
} }
@ -99,12 +97,12 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
@Override @Override
public <T> Attribute<T> attr(AttributeKey<T> key) { public <T> Attribute<T> attr(AttributeKey<T> key) {
return channel.attr(key); return channel().attr(key);
} }
@Override @Override
public <T> boolean hasAttr(AttributeKey<T> key) { public <T> boolean hasAttr(AttributeKey<T> key) {
return channel.hasAttr(key); return channel().hasAttr(key);
} }
@Override @Override
@ -326,7 +324,7 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
@Override @Override
public ChannelPromise voidPromise() { public ChannelPromise voidPromise() {
return channel.voidPromise(); return channel().voidPromise();
} }
void setRemoved() { void setRemoved() {
@ -345,6 +343,6 @@ abstract class AbstractChannelHandlerContext implements ChannelHandlerContext, R
@Override @Override
public String toString() { public String toString() {
return StringUtil.simpleClassName(ChannelHandlerContext.class) + '(' + name + ", " + channel + ')'; return StringUtil.simpleClassName(ChannelHandlerContext.class) + '(' + name + ", " + channel() + ')';
} }
} }