Fix #263 No way to pass unfold=true to decoder superclass
- Allow modifying unfold property until the decoder is added to a pipeline
This commit is contained in:
parent
1311a2edc1
commit
8650cfbc53
@ -179,7 +179,7 @@ import org.jboss.netty.handler.codec.replay.ReplayingDecoder;
|
||||
*/
|
||||
public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implements LifeCycleAwareChannelHandler {
|
||||
|
||||
private final boolean unfold;
|
||||
private boolean unfold;
|
||||
protected ChannelBuffer cumulation;
|
||||
private volatile ChannelHandlerContext ctx;
|
||||
private int copyThreshold;
|
||||
@ -192,6 +192,19 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
this.unfold = unfold;
|
||||
}
|
||||
|
||||
public final boolean isUnfold() {
|
||||
return unfold;
|
||||
}
|
||||
|
||||
public final void setUnfold(boolean unfold) {
|
||||
if (ctx == null) {
|
||||
this.unfold = unfold;
|
||||
} else {
|
||||
throw new IllegalStateException(
|
||||
"decoder properties cannot be changed once the decoder is added to a pipeline.");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* See {@link #setMaxCumulationBufferCapacity(int)} for explaintation of this setting
|
||||
*
|
||||
@ -224,13 +237,13 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
*/
|
||||
public final void setMaxCumulationBufferCapacity(int copyThreshold) {
|
||||
if (copyThreshold < 0) {
|
||||
throw new IllegalArgumentException("MaxCumulationBufferCapacity must be >= 0");
|
||||
throw new IllegalArgumentException("maxCumulationBufferCapacity must be >= 0");
|
||||
}
|
||||
if (ctx == null) {
|
||||
this.copyThreshold = copyThreshold;
|
||||
} else {
|
||||
throw new IllegalStateException("MaxCumulationBufferCapacity " +
|
||||
"can only be changed before the Decoder was added to the ChannelPipeline");
|
||||
throw new IllegalStateException(
|
||||
"decoder properties cannot be changed once the decoder is added to a pipeline.");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user