On Wed, 4 Mar 2026 10:03:38 GMT, Volkan Yazici <[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?

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).

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/30044#discussion_r2883571542
PR Review Comment: https://git.openjdk.org/jdk/pull/30044#discussion_r2883577993

Reply via email to