This change adds clearer NullPointerException messages to the POST(), PUT(), and method() methods in HttpRequest.Builder when the provided BodyPublisher is null.
Each of these methods now calls requireNonNull(body, "BodyPublisher must not be null"), making the exception message explicit. A corresponding regression test (RequestBuilderNullBodyTest) has been added to verify this behavior. All builds and related tests (jdk/java/net/httpclient) have passed successfully. Currently, only POST(), PUT(), and method() include these messages. Some other builder methods (such as header(), setHeader(), and uri()) also throw NullPointerException without a message. I would like to discuss whether adding consistent messages to those methods would be beneficial, and whether the current wording "BodyPublisher must not be null" feels appropriate. ------------- Commit messages: - 8271091: fixed whitespace errors - 8271091: Add test verifying NullPointerException messages for null BodyPublisher in HttpRequest.Builder - 8271091: Add descriptive NullPointerException messages for null BodyPublisher in HttpRequest.Builder methods Changes: https://git.openjdk.org/jdk/pull/28103/files Webrev: https://webrevs.openjdk.org/?repo=jdk&pr=28103&range=00 Issue: https://bugs.openjdk.org/browse/JDK-8371091 Stats: 62 lines in 2 files changed: 59 ins; 0 del; 3 mod Patch: https://git.openjdk.org/jdk/pull/28103.diff Fetch: git fetch https://git.openjdk.org/jdk.git pull/28103/head:pull/28103 PR: https://git.openjdk.org/jdk/pull/28103
