On Wed, 4 Mar 2026 12:38:11 GMT, Daniel Fuchs <[email protected]> wrote:
>> [JDK-8272758] (#29264) incorrectly added the `if (contextPath == '/') {
>> return true; }` fast path to the `HttpServer` context matcher. As a result,
>> `GET foo` started matching context `/`, where it should not. Fix this.
>>
>> [JDK-8272758]: https://bugs.openjdk.org/browse/JDK-8272758
>
> src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java line 192:
>
>> 190: if ("/".equals(contextPath)) {
>> 191: return true;
>> 192: }
>
> In fact you could probably keep that - and just move it after:
>
> if (!requestPath.startsWith(contextPath)) {
> return false;
> }
>
> below?
AFAICT, the fast path neither brings a significant performance benefit, nor is
at a hot spot. Given playing out smart caused this issue, I'd rather keep
things simple, and remove the fast path.
> src/jdk.httpserver/share/classes/sun/net/httpserver/ContextList.java line 192:
>
>> 190: if (!requestPath.startsWith(contextPath)) {
>> 191: return false;
>> 192: }
>
> you could just move:
>
> if ("/".equals(contextPath)) {
> return true;
> }
>
> just after this check (I think).
See my [earlier comment].
[earlier comment]:
https://github.com/openjdk/jdk/pull/30044#discussion_r2884027713
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/30044#discussion_r2884027713
PR Review Comment: https://git.openjdk.org/jdk/pull/30044#discussion_r2884029453