RFR: 8355360: -d option of jwebserver command should accept relative paths

Alan Bateman alanb at openjdk.org
Thu May 8 09:24:53 UTC 2025


On Thu, 8 May 2025 09:01:33 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

> Allows relative paths in the content root directory passed to the `jwebserver`. Changes apply to both the `jwebserver` executable and the `java -m jdk.httpserver` execution.
> 
> ### Implementation notes
> 
> Received `Path` is first passed through `.normalize().toAbsolutePath()`, and then used. The rest of the logic is untouched. This effectively implies that
> 
> 1. Parts that require an absolute path (e.g., `s.n.h.s.FileServerHandler`) kept their conditions
> 2. Logging, failures, etc. containing the user-provided directory will now refer to the _normalized absolute_ path instead of the user-provided one (can be relative, can be not normalized, etc.)

src/jdk.httpserver/share/classes/sun/net/httpserver/simpleserver/SimpleFileServerImpl.java line 115:

> 113:                     }
> 114:                     case "-d", "--directory" ->
> 115:                         root = Path.of(optionArg = options.next()).normalize().toAbsolutePath();

normalize removes redundant name elements and is for "user input". Are you 100% sure it make sense here?

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25113#discussion_r2079265013


More information about the net-dev mailing list