diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java index db4ea9909c5..f1d86de3783 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/ArrayTernaryTrie.java @@ -630,15 +630,16 @@ public class ArrayTernaryTrie extends AbstractTrie public boolean put(String s, V v) { boolean added = _trie.put(s,v); - while (!added) + while (!added && _growby>0) { ArrayTernaryTrie bigger = new ArrayTernaryTrie<>(_trie._key.length+_growby); for (Map.Entry entry : _trie.entrySet()) bigger.put(entry.getKey(),entry.getValue()); + _trie = bigger; added = _trie.put(s,v); } - return true; + return added; } public V get(String s, int offset, int len) diff --git a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java index 6385a310934..9e7fd968456 100644 --- a/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java +++ b/jetty-webapp/src/main/java/org/eclipse/jetty/webapp/ClasspathPattern.java @@ -180,8 +180,7 @@ public class ClasspathPattern extends AbstractSet if (_entries.get(name)!=null) return false; - _entries.put(name,entry); - return true; + return _entries.put(name,entry); } @Override diff --git a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ClasspathPatternTest.java b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ClasspathPatternTest.java index 9ccf88c935e..47c195dffe0 100644 --- a/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ClasspathPatternTest.java +++ b/jetty-webapp/src/test/java/org/eclipse/jetty/webapp/ClasspathPatternTest.java @@ -228,4 +228,21 @@ public class ClasspathPatternTest assertThat(pattern.match(JDK.class),is(true)); assertThat(pattern.match(ClasspathPatternTest.class),is(false)); } + + + + @Test + public void testLarge() + { + ClasspathPattern pattern = new ClasspathPattern(); + for (int i=0; i<500; i++) + { + assertTrue(pattern.add("n"+i+"."+Integer.toHexString(100+i)+".Name")); + } + + for (int i=0; i<500; i++) + { + assertTrue(pattern.match("n"+i+"."+Integer.toHexString(100+i)+".Name")); + } + } }