RFR: 8358688: HttpClient: Simplify file streaming in RequestPublishers.FilePublisher [v2]

Volkan Yazici vyazici at openjdk.org
Fri Jun 6 11:09:51 UTC 2025


On Fri, 6 Jun 2025 08:28:30 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:

>> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
>> 
>>   Add back removed SM tests
>
> 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)

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

PR Review Comment: https://git.openjdk.org/jdk/pull/25662#discussion_r2131998716


More information about the net-dev mailing list