Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

ArrayTrie getBest fails to match the empty string entry in certain cases #7518

Closed
lorban opened this issue Feb 2, 2022 · 0 comments · Fixed by #7527
Closed

ArrayTrie getBest fails to match the empty string entry in certain cases #7518

lorban opened this issue Feb 2, 2022 · 0 comments · Fixed by #7527
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@lorban
Copy link
Contributor

lorban commented Feb 2, 2022

Jetty version(s)
9.4.x

Description

When an ArrayTrie contains an empty string, getBest() should always match it as a last resort. But when getBest() is given a key that starts with common letters but does not match an existing entry then null is returned instead of the empty string's value.

Consider the following:

ArrayTrie<Integer> trie = new ArrayTrie<>();

assertTrue(trie.put("", 0));
assertTrue(trie.put("prefix", 1));

assertEquals(0, trie.getBest("unknown"));
assertEquals(0, trie.getBest("pre-unknown")); // fails
@lorban lorban added the Bug For general bugs on Jetty side label Feb 2, 2022
gregw added a commit that referenced this issue Feb 3, 2022
Only increment current row if not recursing.

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw linked a pull request Feb 3, 2022 that will close this issue
gregw added a commit that referenced this issue Feb 3, 2022
Avoid recursion where possible

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Feb 3, 2022
Fixed match ending with big char

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Feb 3, 2022
Fix #7518 Trie.getBest with empty Key

 * Only increment current row if not recursing.
 * Fixed match ending with big char

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Feb 3, 2022
Fix #7518 Trie stack overflows

* Avoid recursion where possible

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Feb 4, 2022
Fix #7518 Trie.getBest with empty Key

 * Only increment current row if not recursing.
 * Fixed match ending with big char

Signed-off-by: Greg Wilkins <gregw@webtide.com>
gregw added a commit that referenced this issue Feb 4, 2022
Fix #7518 Trie stack overflows

* Avoid recursion where possible

Signed-off-by: Greg Wilkins <gregw@webtide.com>
@gregw gregw closed this as completed in bdc60ee Feb 7, 2022
lorban added a commit that referenced this issue Feb 18, 2022
Signed-off-by: Ludovic Orban <lorban@bitronix.be>
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Bug For general bugs on Jetty side
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants