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

Jaikiran Pai jpai at openjdk.org
Wed Jun 11 09:53:35 UTC 2025


On Fri, 6 Jun 2025 11:07:34 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Simplifies content streaming for `HttpRequest.BodyPublishers::ofFile(Path)`, which delegates to `RequestPublishers.FilePublisher::create(Path)`. This effectively replaces all usages of `FileInputStream::new` in `HttpClient` with `Files::newInputStream(Path)`. See the JBS ticket description for the full story.
>> 
>> Also removing certain test files which were rendered redundant after `SecurityManager` removal. We do this in this PR, since tests were added due to touched lines.
>> 
>> `tier1,2` results on b5f3c8dc6f4 are attached to the ticket.
>
> Volkan Yazici has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Update tests

The changes look good to me.

src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java line 268:

> 266:             } catch (NoSuchFileException nsfe) {
> 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`:

Nit - since the BodyPublishers.ofFile(...) specifies a `FileNotFoundException`, I think a better comment here and a few lines above might be: "// Throw FileNotFoundException to match the specification of BodyPublishers.ofFile()"

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

Marked as reviewed by jpai (Reviewer).

PR Review: https://git.openjdk.org/jdk/pull/25662#pullrequestreview-2916446710
PR Review Comment: https://git.openjdk.org/jdk/pull/25662#discussion_r2139713022


More information about the net-dev mailing list