RFR: 8272758: Improve HttpServer to avoid partial file name matches while mapping request path to context path

Volkan Yazici vyazici at openjdk.org
Fri Jan 16 08:16:11 UTC 2026


On Fri, 16 Jan 2026 08:07:48 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

> Currently `HttpServer` allows matching a request path `/foobar` to context path `/foo`. Replace this surprising behaviour with a safer approach by disallowing partial file name matches.
> 
> 
>          |           Request path
>  Context +------+-------+----------+---------
>   path   | /foo | /foo/ | /foo/bar | /foobar
> ---------+------+-------+----------+---------
>  /       |   Y  |   Y   |     Y    |    Y
>  /foo/   |   N  |   Y   |     Y    |    N

src/jdk.httpserver/share/classes/com/sun/net/httpserver/HttpServer.java line 1:

> 1: /*

Recall that the issue was first reported in [JDK-8225479], and there, the decision was to introduce the `@apiNote` workaround you see here. I took the approach of adding an `@implNote` stating where we deviate from the `@apiNote`.

I am not really sure if the _"this would match requests"_ statement (note the _"would"_!) implies a conflict between the old `@apiNote` and the newly introduced `@implNote`. If so, this can bite use in the CSR review.

In short, I appreciate your feedback on how to massage the API docs.

[JDK-8225479]: https://bugs.openjdk.org/browse/JDK-8225479

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

PR Review Comment: https://git.openjdk.org/jdk/pull/29264#discussion_r2697430212


More information about the net-dev mailing list