RFR: 8367067: Improve exception handling in HttpRequest.BodyPublishers

Volkan Yazici vyazici at openjdk.org
Mon Sep 8 09:19:33 UTC 2025


On Thu, 21 Aug 2025 16:40:15 GMT, Chen Liang <liach 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.
>
> src/java.net.http/share/classes/jdk/internal/net/http/PullPublisher.java line 47:
> 
>> 45: 
>> 46:     PullPublisher(CheckedIterable<T> iterable, Throwable throwable) {
>> 47:         if ((iterable == null && throwable == null) || (iterable != null && throwable != null)) {
> 
> You can express this as `((iterable == null) == (throwable == null))` for simplicity.

Changed as suggested in 53f483bb.

> src/java.net.http/share/classes/jdk/internal/net/http/PullPublisher.java line 49:
> 
>> 47:         if ((iterable == null && throwable == null) || (iterable != null && throwable != null)) {
>> 48:             String message = String.format(
>> 49:                     "only one of `iterable` or `throwable` can be null, but %s are",
> 
> "only one of xxx can be null" sounds like you allow both to be non-null, but that is not the case. Maybe use other wording like "one argument should be null and the other should be non-null, but both are null/non-null"?

I had copy-pasted that phrase from line 39. I've updated both as suggested in a68707c6.

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

PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2293142237
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2293142343


More information about the net-dev mailing list