From b38bde2d2b7e4ab99844e3018ebfd9f61c7028de Mon Sep 17 00:00:00 2001 From: Trustin Lee Date: Tue, 29 Jan 2013 15:53:43 +0900 Subject: [PATCH] Allocate smaller dynamic buffer to read a line - Also fixes some inspector warnings from the previous patch - Related: #992 --- .../codec/http/multipart/HttpPostRequestDecoder.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java index 1efbf94183..ac20b5abc0 100644 --- a/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java +++ b/src/main/java/org/jboss/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java @@ -1219,17 +1219,17 @@ public class HttpPostRequestDecoder { private String readLineStandard() throws NotEnoughDataDecoderException { int readerIndex = undecodedChunk.readerIndex(); try { - ChannelBuffer line = ChannelBuffers.dynamicBuffer(); + ChannelBuffer line = ChannelBuffers.dynamicBuffer(64); while (undecodedChunk.readable()) { byte nextByte = undecodedChunk.readByte(); if (nextByte == HttpConstants.CR) { nextByte = undecodedChunk.readByte(); if (nextByte == HttpConstants.LF) { - return line.toString(this.charset); + return line.toString(charset); } } else if (nextByte == HttpConstants.LF) { - return line.toString(this.charset); + return line.toString(charset); } else { line.writeByte(nextByte); } @@ -1256,7 +1256,7 @@ public class HttpPostRequestDecoder { } int readerIndex = undecodedChunk.readerIndex(); try { - ChannelBuffer line = ChannelBuffers.dynamicBuffer(); + ChannelBuffer line = ChannelBuffers.dynamicBuffer(64); while (sao.pos < sao.limit) { byte nextByte = sao.bytes[sao.pos ++]; if (nextByte == HttpConstants.CR) { @@ -1264,14 +1264,14 @@ public class HttpPostRequestDecoder { nextByte = sao.bytes[sao.pos ++]; if (nextByte == HttpConstants.LF) { sao.setReadPosition(0); - return line.toString(this.charset); + return line.toString(charset); } } else { line.writeByte(nextByte); } } else if (nextByte == HttpConstants.LF) { sao.setReadPosition(0); - return line.toString(this.charset); + return line.toString(charset); } else { line.writeByte(nextByte); }