[#2234] Use QueryStringDecoder.decodeComponent to decode url-encoded data instead of Java's URLDecoder.
Motivation: Previously, we used URLDecoder.decode(...) to decode url-encoded data. This generates a lot of garbage and takes a considerable amount of time. Modifications: Replace URLDecoder.decode(...) with QueryStringDecoder.decodeComponent(...) Result: Less garbage to GC and faster decode processing.
This commit is contained in:
parent
27671e0dbd
commit
98bc7b7859
@ -20,6 +20,7 @@ import io.netty.handler.codec.http.HttpConstants;
|
||||
import io.netty.handler.codec.http.HttpContent;
|
||||
import io.netty.handler.codec.http.HttpRequest;
|
||||
import io.netty.handler.codec.http.LastHttpContent;
|
||||
import io.netty.handler.codec.http.QueryStringDecoder;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadNoBackArrayException;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostBodyUtil.SeekAheadOptimize;
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.EndOfDataDecoderException;
|
||||
@ -28,8 +29,6 @@ import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.MultiPartSta
|
||||
import io.netty.handler.codec.http.multipart.HttpPostRequestDecoder.NotEnoughDataDecoderException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -646,13 +645,8 @@ public class HttpPostStandardRequestDecoder implements InterfaceHttpPostRequestD
|
||||
* @return the decoded component
|
||||
*/
|
||||
private static String decodeAttribute(String s, Charset charset) {
|
||||
if (s == null) {
|
||||
return "";
|
||||
}
|
||||
try {
|
||||
return URLDecoder.decode(s, charset.name());
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
throw new ErrorDataDecoderException(charset.toString(), e);
|
||||
return QueryStringDecoder.decodeComponent(s, charset);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw new ErrorDataDecoderException("Bad string: '" + s + '\'', e);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user