# HG changeset patch # User chegar # Date 1527869758 -3600 # Node ID e9009db09cffe02e9886818b11bab09f2b626ae6 # Parent 8e00f02b7dfc178dfa93563239d03152e281ed59 http-client-branch: fix javadoc examples in BodySubscribers diff -r 8e00f02b7dfc -r e9009db09cff src/java.net.http/share/classes/java/net/http/HttpResponse.java --- a/src/java.net.http/share/classes/java/net/http/HttpResponse.java Fri Jun 01 16:43:54 2018 +0100 +++ b/src/java.net.http/share/classes/java/net/http/HttpResponse.java Fri Jun 01 17:15:58 2018 +0100 @@ -888,20 +888,20 @@ * *
{@code    // Streams the response body to a File
      *   HttpResponse response = client
-     *     .send(request, (statusCode, responseHeaders) -> BodySubscribers.ofByteArray());
+     *     .send(request, responseInfo -> BodySubscribers.ofByteArray());
      *
      *   // Accumulates the response body and returns it as a byte[]
      *   HttpResponse response = client
-     *     .send(request, (statusCode, responseHeaders) -> BodySubscribers.ofByteArray());
+     *     .send(request, responseInfo -> BodySubscribers.ofByteArray());
      *
      *   // Discards the response body
      *   HttpResponse response = client
-     *     .send(request, (statusCode, responseHeaders) -> BodySubscribers.discarding());
+     *     .send(request, responseInfo -> BodySubscribers.discarding());
      *
      *   // Accumulates the response body as a String then maps it to its bytes
      *   HttpResponse response = client
-     *     .send(request, (sc, hdrs) ->
-     *        BodySubscribers.mapping(BodySubscribers.ofString(), String::getBytes));
+     *     .send(request, responseInfo ->
+     *        BodySubscribers.mapping(BodySubscribers.ofString(UTF_8), String::getBytes));
      * }
* * @since 11 diff -r 8e00f02b7dfc -r e9009db09cff test/jdk/java/net/httpclient/examples/JavadocExamples.java --- a/test/jdk/java/net/httpclient/examples/JavadocExamples.java Fri Jun 01 16:43:54 2018 +0100 +++ b/test/jdk/java/net/httpclient/examples/JavadocExamples.java Fri Jun 01 17:15:58 2018 +0100 @@ -45,6 +45,7 @@ import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.Flow; import java.util.regex.Pattern; +import static java.nio.charset.StandardCharsets.UTF_8; /* * THE CONTENTS OF THIS FILE HAVE TO BE IN SYNC WITH THE EXAMPLES USED IN THE @@ -156,6 +157,25 @@ HttpResponse respons4 = client .send(request, BodyHandlers.discarding()); + + // HttpResponse.BodySubscribers class-level description + // Streams the response body to a File + HttpResponse response5 = client + .send(request, responseInfo -> BodySubscribers.ofByteArray()); + + // Accumulates the response body and returns it as a byte[] + HttpResponse response6 = client + .send(request, responseInfo -> BodySubscribers.ofByteArray()); + + // Discards the response body + HttpResponse response7 = client + .send(request, responseInfo -> BodySubscribers.discarding()); + + // Accumulates the response body as a String then maps it to its bytes + HttpResponse response8 = client + .send(request, responseInfo -> + BodySubscribers.mapping(BodySubscribers.ofString(UTF_8), String::getBytes)); + } /**