On Thu, 8 May 2025 13:42:37 GMT, Volkan Yazici <vyaz...@openjdk.org> wrote:

>> Allows relative paths in the content root directory passed to the 
>> `jwebserver`. Changes effect both the `jwebserver` executable and the `java 
>> -m jdk.httpserver` execution.
>> 
>> ### Implementation notes
>> 
>> Received `Path` is read using `toRealPath()`, and then employed in 
>> `s.n.h.s.FileServerHandler`, which is the only place in the web server code 
>> where an absolute path requirement is present.
>
> Volkan Yazici has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Revert `SimpleFileServerImpl` changes, and allow relative paths in 
> `FileServerHandler` instead

src/jdk.httpserver/share/classes/sun/net/httpserver/simpleserver/FileServerHandler.java
 line 81:

> 79:         if (!Files.exists(root)) {
> 80:             throw new IllegalArgumentException("Path does not exist: " + 
> root);
> 81:         }

As I tried to explain in the comment block above, without this pre-check, 
non-existent files are reported poorly:


$ build/linux-x64/jdk/bin/jwebserver -d no-such-file
Error: server config failed: Path is invalid: no-such-file
$ _


Note the lack of context regarding the failure.

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

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

Reply via email to