* Correct byte order
* All encoders should ignore the message whose type is unknown to the encoder
This commit is contained in:
parent
b859f120d8
commit
2b2d53ff62
@ -167,6 +167,7 @@ public class Base64 {
|
||||
|
||||
int len43 = len * 4 / 3;
|
||||
ChannelBuffer dest = bufferFactory.getBuffer(
|
||||
src.order(),
|
||||
len43 +
|
||||
(len % 3 > 0? 4 : 0) + // Account for padding
|
||||
(breakLines? len43 / MAX_LINE_LENGTH : 0)); // New lines
|
||||
@ -292,7 +293,7 @@ public class Base64 {
|
||||
byte[] DECODABET = decodabet(dialect);
|
||||
|
||||
int len34 = len * 3 / 4;
|
||||
ChannelBuffer dest = bufferFactory.getBuffer(len34); // Upper limit on size of output
|
||||
ChannelBuffer dest = bufferFactory.getBuffer(src.order(), len34); // Upper limit on size of output
|
||||
int outBuffPosn = 0;
|
||||
|
||||
byte[] b4 = new byte[4];
|
||||
|
@ -107,8 +107,12 @@ public class LengthFieldPrepender extends OneToOneEncoder {
|
||||
@Override
|
||||
protected Object encode(
|
||||
ChannelHandlerContext ctx, Channel channel, Object msg) throws Exception {
|
||||
ChannelBuffer header = channel.getConfig().getBufferFactory().getBuffer(lengthFieldLength);
|
||||
if (!(msg instanceof ChannelBuffer)) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
ChannelBuffer body = (ChannelBuffer) msg;
|
||||
ChannelBuffer header = channel.getConfig().getBufferFactory().getBuffer(body.order(), lengthFieldLength);
|
||||
|
||||
int length = lengthIncludesLengthFieldLength?
|
||||
body.readableBytes() + lengthFieldLength : body.readableBytes();
|
||||
|
@ -44,10 +44,15 @@ public class ProtobufVarint32LengthFieldPrepender extends OneToOneEncoder {
|
||||
@Override
|
||||
protected Object encode(ChannelHandlerContext ctx, Channel channel,
|
||||
Object msg) throws Exception {
|
||||
if (!(msg instanceof ChannelBuffer)) {
|
||||
return msg;
|
||||
}
|
||||
|
||||
ChannelBuffer body = (ChannelBuffer) msg;
|
||||
int length = body.readableBytes();
|
||||
ChannelBuffer header =
|
||||
channel.getConfig().getBufferFactory().getBuffer(
|
||||
body.order(),
|
||||
CodedOutputStream.computeRawVarint32Size(length));
|
||||
CodedOutputStream codedOutputStream = CodedOutputStream
|
||||
.newInstance(new ChannelBufferOutputStream(header));
|
||||
|
Loading…
Reference in New Issue
Block a user