RFR: 8358688: HttpClient: Simplify file streaming in RequestPublishers.FilePublisher [v2]
Daniel Fuchs
dfuchs at openjdk.org
Fri Jun 6 11:15:57 UTC 2025
On Fri, 6 Jun 2025 11:07:00 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:
>> src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java line 269:
>>
>>> 267: // The old code was using `FileInputStream::new`, which throws `FNFE` if file doesn't exist.
>>> 268: // Preserving that behaviour after migrating to `Files::newInputStream`:
>>> 269: t = new FileNotFoundException(path + " (No such file or directory)");
>>
>> I wonder if we should keep `nsfe` as the cause. Does it contain anything interesting in the stack trace that could help debugging if it gets unexpectedly thrown?
>
> I also wanted to keep the `nsfe` as the cause, though `FNFE::new` doesn't have a public ctor accepting a `Throwable`.
>
>> Does it contain anything interesting in the stack trace that could help debugging if it gets unexpectedly thrown?
>
> Not really:
>
>
> jshell> java.nio.file.Files.newInputStream(java.nio.file.Path.of("/foo"))
> | Exception java.nio.file.NoSuchFileException: /foo
> | at UnixException.translateToIOException (UnixException.java:92)
> | at UnixException.rethrowAsIOException (UnixException.java:106)
Ok - doesn't look too useful.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/25662#discussion_r2132003924
More information about the net-dev
mailing list