On Wed, 20 Mar 2024 10:12:35 GMT, Michael McMahon <[email protected]> wrote:
>> Hi, >> >> This PR proposes to add simple utility method which returns a simple GET >> HttpRequest in one call. The current builder pattern requires 4 (or 3 since >> GET is the default method) method calls to achieve the same effect. >> >> Thanks, >> Michael > > Michael McMahon has updated the pull request incrementally with one > additional commit since the last revision: > > Update test/jdk/java/net/httpclient/GETTest.java > > Co-authored-by: Andrey Turbanov <[email protected]> src/java.net.http/share/classes/java/net/http/HttpResponse.java line 154: > 152: */ > 153: public Optional<T> bodyWhen(Predicate<ResponseInfo> predicate) > throws IOException; > 154: I believe the method should be specified to close the body if it is closeable and if it is not returned. src/java.net.http/share/classes/jdk/internal/net/http/HttpResponseImpl.java line 106: > 104: return Optional.of(body()); > 105: } else { > 106: return Optional.empty(); should close the body here if it is closeable - or subscribe and cancel the subscribtion if it is a publisher. ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/18227#discussion_r1532328105 PR Review Comment: https://git.openjdk.org/jdk/pull/18227#discussion_r1532330839
