RFR: 8367067: Improve exception handling in HttpRequest.BodyPublishers [v2]

Shaojin Wen swen at openjdk.org
Sun Sep 14 09:58:23 UTC 2025


On Mon, 8 Sep 2025 18:33:04 GMT, Volkan Yazici <vyazici at openjdk.org> wrote:

>> Improves exception handling of built-in `HttpClient.BodyPublisher`s to ensure exceptions get propagated in a way compliant with the reactive specification.
>
> Volkan Yazici has updated the pull request incrementally with three additional commits since the last revision:
> 
>  - Remove IOE rethrows
>  - Revert `FilePublisherTest` and `FlowAdapterPublisherTest` changes
>  - Make `CheckedIterable` throw exceptions

RequestPublishers$FilePublisher and RequestPublishers$InputStreamPublisher should be final

src/java.net.http/share/classes/jdk/internal/net/http/PullPublisher.java line 37:

> 35:  * Each new subscription gets a new {@link CheckedIterator}.
> 36:  */
> 37: class PullPublisher<T> implements Flow.Publisher<T> {

Suggestion:

final class PullPublisher<T> implements Flow.Publisher<T> {

add final

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

> 200:     }
> 201: 
> 202:     public static class StringPublisher extends ByteArrayPublisher {

Suggestion:

    public static final class StringPublisher extends ByteArrayPublisher {

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

> 206:     }
> 207: 
> 208:     public static class EmptyPublisher implements BodyPublisher {

Suggestion:

    public static final class EmptyPublisher implements BodyPublisher {

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

PR Comment: https://git.openjdk.org/jdk/pull/26876#issuecomment-3289406471
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2347225544
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2347227054
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2347227613


More information about the net-dev mailing list