jetty.project icon indicating copy to clipboard operation
jetty.project copied to clipboard

Many servlet mappings using URL suffixes may get lost in Jetty 9.4

Open quijote opened this issue 3 years ago • 3 comments

Jetty version(s) 9.4.x. It is unclear to me if "End of community support" means that major issues should not even be reported anymore.

Java version/vendor (use: java -version)

openjdk version "11.0.14.1" 2022-02-08
OpenJDK Runtime Environment Temurin-11.0.14.1+1 (build 11.0.14.1+1)
OpenJDK 64-Bit Server VM Temurin-11.0.14.1+1 (build 11.0.14.1+1, mixed mode)

OS type/version

Windows

Description

My application uses a couple of servlet mappings like this:

<servlet-mapping>
    <servlet-name>SimpleHtml</servlet-name>
    <url-pattern>*.simple</url-pattern>
</servlet-mapping>

At some point I added another mapping and large parts of the application stopped working.

After some debugging the root cause was found here:

// grow the capacity of the Trie
_suffixMap = new ArrayTernaryTrie<>((ArrayTernaryTrie<MappedResource<E>>)_prefixMap, 1.5);

https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java#L347

Code tries to resize _suffixMap but it accidentally initializes the new map from _prefixMap instead of _suffixMap.

How to reproduce?

Create a webapplication where the total number of characters of suffixes in url-patterns is large (roughly larger than 128 which is the default size of ArrayTernaryTrie). Then try to call one of the first sevlets.

quijote avatar Aug 01 '22 13:08 quijote

Use Jetty 9.4.48.v20220622

See: https://github.com/eclipse/jetty.project/issues/8184

joakime avatar Aug 01 '22 16:08 joakime

After some debugging the root cause was found here:

// grow the capacity of the Trie
_suffixMap = new ArrayTernaryTrie<>((ArrayTernaryTrie<MappedResource<E>>)_prefixMap, 1.5);

https://github.com/eclipse/jetty.project/blob/jetty-9.4.x/jetty-http/src/main/java/org/eclipse/jetty/http/pathmap/PathMappings.java#L347

Code tries to resize _suffixMap but it accidentally initializes the new map from _prefixMap instead of _suffixMap.

This is a legitimate bug. And needs to be fixed.

joakime avatar Aug 01 '22 16:08 joakime

This bug does not exist in Jetty 10+

joakime avatar Aug 01 '22 16:08 joakime

This issue has been automatically marked as stale because it has been a full year without activity. It will be closed if no further activity occurs. Thank you for your contributions.

github-actions[bot] avatar Aug 02 '23 00:08 github-actions[bot]

@joakime can this be closed?

sbordet avatar Aug 02 '23 09:08 sbordet

Closed with issue #8184

joakime avatar Aug 02 '23 10:08 joakime