RFR: 8367067: Improve exception handling in HttpRequest.BodyPublishers
Chen Liang
liach at openjdk.org
Mon Sep 8 09:19:32 UTC 2025
On Thu, 21 Aug 2025 09:43:47 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.
I don't think we need to add new `throws Exception` declarations if the existing code does not need it.
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.
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"?
-------------
PR Review: https://git.openjdk.org/jdk/pull/26876#pullrequestreview-3141492419
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2291597776
PR Review Comment: https://git.openjdk.org/jdk/pull/26876#discussion_r2291628366
More information about the net-dev
mailing list