[#766] Rename method to extractFrame(..), no need to make it more complicated in 3
This commit is contained in:
parent
bc1ef572b9
commit
ef481bfedb
@ -232,7 +232,7 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
|
||||
|
||||
if (minDelim != null) {
|
||||
int minDelimLength = minDelim.capacity();
|
||||
Object frame;
|
||||
ChannelBuffer frame;
|
||||
|
||||
if (discardingTooLongFrame) {
|
||||
// We've just finished discarding a very large frame.
|
||||
@ -256,9 +256,9 @@ public class DelimiterBasedFrameDecoder extends FrameDecoder {
|
||||
}
|
||||
|
||||
if (stripDelimiter) {
|
||||
frame = extract(buffer, buffer.readerIndex(), minFrameLength);
|
||||
frame = extractFrame(buffer, buffer.readerIndex(), minFrameLength);
|
||||
} else {
|
||||
frame = extract(buffer, buffer.readerIndex(), minFrameLength + minDelimLength);
|
||||
frame = extractFrame(buffer, buffer.readerIndex(), minFrameLength + minDelimLength);
|
||||
}
|
||||
buffer.skipBytes(minFrameLength + minDelimLength);
|
||||
|
||||
|
@ -72,7 +72,7 @@ public class FixedLengthFrameDecoder extends FrameDecoder {
|
||||
if (buffer.readableBytes() < frameLength) {
|
||||
return null;
|
||||
} else {
|
||||
Object frame = extract(buffer, buffer.readerIndex(), frameLength);
|
||||
ChannelBuffer frame = extractFrame(buffer, buffer.readerIndex(), frameLength);
|
||||
buffer.skipBytes(frameLength);
|
||||
return frame;
|
||||
}
|
||||
|
@ -382,7 +382,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* Decodes the received packets so far into a frame.
|
||||
*
|
||||
* If an sub-class wants to extract a frame out of the buffer it should use
|
||||
* the {@link #extract(org.jboss.netty.buffer.ChannelBuffer, int, int)} method,
|
||||
* the {@link #extractFrame(org.jboss.netty.buffer.ChannelBuffer, int, int)} method,
|
||||
* to make optimizations easier later.
|
||||
*
|
||||
* @param ctx the context of this handler
|
||||
@ -566,7 +566,7 @@ public abstract class FrameDecoder extends SimpleChannelUpstreamHandler implemen
|
||||
* <strong>Be sure that this method MUST not modify the readerIndex of the given buffer</strong>
|
||||
*
|
||||
*/
|
||||
protected Object extract(ChannelBuffer buffer, int index, int length) {
|
||||
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length) {
|
||||
ChannelBuffer frame = buffer.factory().getBuffer(length);
|
||||
frame.writeBytes(buffer, index, length);
|
||||
return frame;
|
||||
|
@ -390,21 +390,11 @@ public class LengthFieldBasedFrameDecoder extends FrameDecoder {
|
||||
// extract frame
|
||||
int readerIndex = buffer.readerIndex();
|
||||
int actualFrameLength = frameLengthInt - initialBytesToStrip;
|
||||
Object frame = extract(buffer, readerIndex, actualFrameLength);
|
||||
ChannelBuffer frame = extractFrame(buffer, readerIndex, actualFrameLength);
|
||||
buffer.readerIndex(readerIndex + actualFrameLength);
|
||||
return frame;
|
||||
}
|
||||
|
||||
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length) {
|
||||
ChannelBuffer frame = buffer.factory().getBuffer(length);
|
||||
frame.writeBytes(buffer, index, length);
|
||||
return frame;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Object extract(ChannelBuffer buffer, int index, int length) {
|
||||
return extractFrame(buffer, index, length);
|
||||
}
|
||||
|
||||
private void failIfNecessary(ChannelHandlerContext ctx, boolean firstDetectionOfTooLongFrame) {
|
||||
if (bytesToDiscard == 0) {
|
||||
|
@ -74,7 +74,7 @@ public class LineBasedFrameDecoder extends FrameDecoder {
|
||||
final ChannelBuffer buffer) throws Exception {
|
||||
final int eol = findEndOfLine(buffer);
|
||||
if (eol != -1) {
|
||||
final Object frame;
|
||||
final ChannelBuffer frame;
|
||||
final int length = eol - buffer.readerIndex();
|
||||
assert length >= 0: "Invalid length=" + length;
|
||||
if (discarding) {
|
||||
@ -92,9 +92,9 @@ public class LineBasedFrameDecoder extends FrameDecoder {
|
||||
delimLength = 1;
|
||||
}
|
||||
if (stripDelimiter) {
|
||||
frame = extract(buffer, buffer.readerIndex(), length);
|
||||
frame = extractFrame(buffer, buffer.readerIndex(), length);
|
||||
} else {
|
||||
frame = extract(buffer, buffer.readerIndex(), length + delimLength);
|
||||
frame = extractFrame(buffer, buffer.readerIndex(), length + delimLength);
|
||||
}
|
||||
buffer.skipBytes(length + delimLength);
|
||||
|
||||
|
@ -88,9 +88,4 @@ public class MarshallingDecoder extends LengthFieldBasedFrameDecoder {
|
||||
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length) {
|
||||
return buffer.slice(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Object extract(ChannelBuffer buffer, int index, int length) {
|
||||
return super.extract(buffer, index, length);
|
||||
}
|
||||
}
|
||||
|
@ -132,9 +132,4 @@ public class ObjectDecoder extends LengthFieldBasedFrameDecoder {
|
||||
protected ChannelBuffer extractFrame(ChannelBuffer buffer, int index, int length) {
|
||||
return buffer.slice(index, length);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final Object extract(ChannelBuffer buffer, int index, int length) {
|
||||
return super.extract(buffer, index, length);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user