RFR: 8367067: Improve exception handling in HttpRequest.BodyPublishers [v2]
Volkan Yazici
vyazici at openjdk.org
Mon Sep 8 18:33:10 UTC 2025
On Mon, 8 Sep 2025 13:29:07 GMT, Daniel Fuchs <dfuchs at openjdk.org> wrote:
>> 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
>
> src/java.net.http/share/classes/jdk/internal/net/http/PullPublisher.java line 68:
>
>> 66: try {
>> 67: iterator = iterable.iterator();
>> 68: } catch (Exception exception) {
>
> Either CheckedIterable::iterator() should be declared to throw Exception, or we should catch `RuntimeException` here - or even maybe `RuntimeException | Error` ?
Changed `CheckedIterable::iterator` to throw `Exception` in 75e98c4bc45.
> src/java.net.http/share/classes/jdk/internal/net/http/RequestPublishers.java line 395:
>
>> 393: exception = new IOException("Stream supplier returned null");
>> 394: }
>> 395: } catch (Exception cause) {
>
> Can we get anything but RuntimeException here?
AFAICT, no – I thought being cautious as catching `Exception` would be a good practice here.
> test/jdk/java/net/httpclient/FilePublisherTest.java line 178:
>
>> 176: var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
>> 177: out.println("Got response: " + resp);
>> 178: out.println("Got body: " + resp.body());
>
> Maybe we could revert the changes to this file and do that in a followup
Reverted these in 9fd8958932b – I will remove duplicates in [JDK-8367068].
[JDK-8367068]: https://bugs.openjdk.org/browse/JDK-8367068
> test/jdk/java/net/httpclient/FlowAdapterPublisherTest.java line 122:
>
>> 120: }
>> 121: }
>> 122:
>
> Maybe we could revert changes to this file and do that in a followup
Reverted these in 9fd8958932b – I will remove duplicates in [JDK-8367068].
[JDK-8367068]: https://bugs.openjdk.org/browse/JDK-8367068
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2330963062
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2331003299
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2331019821
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2331020844
More information about the net-dev
mailing list