From 351bfa5585367fab8bd9c796fcc6bd6d122c60bd Mon Sep 17 00:00:00 2001 From: gregw Date: Tue, 3 Nov 2020 14:28:51 +0100 Subject: [PATCH] Fix #5562 Improve HTTP Field cache allocation Fix #5562 by initially putting cacheable fields into a inexpensive arraylist. Only create the Trie (with space and complexity costs) if a second request is received. --- .../org/eclipse/jetty/http/HttpParser.java | 69 +++++++++++++++---- 1 file changed, 55 insertions(+), 14 deletions(-) diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java index 9cad979abd44..29f32e186a9c 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/HttpParser.java @@ -20,6 +20,8 @@ import java.nio.ByteBuffer; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; import java.util.EnumSet; import java.util.List; import java.util.Locale; @@ -89,6 +91,7 @@ public class HttpParser public static final String __STRICT = "org.eclipse.jetty.http.HttpParser.STRICT"; public static final int INITIAL_URI_LENGTH = 256; private static final int MAX_CHUNK_LENGTH = Integer.MAX_VALUE / 16 - 16; + private static final List NO_CACHE = Collections.emptyList(); /** * Cache of common {@link HttpField}s including: