http-client-branch: moved noBody() to HttpRequest.BodyPublisher http-client-branch
authordfuchs
Fri, 17 Nov 2017 15:44:11 +0000
branchhttp-client-branch
changeset 55833 3e1f7cdef8a5
parent 55832 2585c47a1a55
child 55834 bc54d015e09d
http-client-branch: moved noBody() to HttpRequest.BodyPublisher
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java
test/jdk/java/net/httpclient/HttpRequestBuilderTest.java
test/jdk/java/net/httpclient/RequestBuilderTest.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java	Fri Nov 17 15:42:34 2017 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/HttpRequest.java	Fri Nov 17 15:44:11 2017 +0000
@@ -434,8 +434,9 @@
          * Sets the request method and request body of this builder to the
          * given values.
          *
-         * @apiNote The {@linkplain #noBody() noBody} request body publisher can
-         * be used where no request body is required or appropriate.
+         * @apiNote The {@linkplain BodyPublisher#noBody() noBody} request
+         * body publisher can be used where no request body is required or
+         * appropriate.
          *
          * @param method the method to use
          * @param bodyPublisher the body publisher
@@ -587,16 +588,6 @@
     }
 
     /**
-     * A request body publisher which sends no request body.
-     *
-     * @return a BodyPublisher which completes immediately and sends
-     *         no request body.
-     */
-    public static BodyPublisher noBody() {
-        return new RequestPublishers.EmptyPublisher();
-    }
-
-    /**
      * A Publisher which converts high level Java objects into flows of
      * {@linkplain ByteBuffer}s suitable for sending as request bodies.
      * {@Incubating}
@@ -725,6 +716,17 @@
         static BodyPublisher fromByteArrays(Iterable<byte[]> iter) {
             return new RequestPublishers.IterablePublisher(iter);
         }
+
+        /**
+         * A request body publisher which sends no request body.
+         *
+         * @return a BodyPublisher which completes immediately and sends
+         *         no request body.
+         */
+        static BodyPublisher noBody() {
+            return new RequestPublishers.EmptyPublisher();
+        }
+
         /**
          * Returns the content length for this request body. May be zero
          * if no request body being sent, greater than zero for a fixed
--- a/test/jdk/java/net/httpclient/HttpRequestBuilderTest.java	Fri Nov 17 15:42:34 2017 +0000
+++ b/test/jdk/java/net/httpclient/HttpRequestBuilderTest.java	Fri Nov 17 15:44:11 2017 +0000
@@ -32,6 +32,7 @@
 import java.util.stream.Stream;
 import jdk.incubator.http.HttpRequest;
 import static jdk.incubator.http.HttpRequest.BodyPublisher.fromString;
+import static jdk.incubator.http.HttpRequest.BodyPublisher.noBody;
 
 /**
  * @test
@@ -155,16 +156,16 @@
                         IllegalArgumentException.class);
 
         builder = test1("DELETE", builder, builder::DELETE,
-                        HttpRequest.noBody(), null);
+                        noBody(), null);
 
         builder = test1("POST", builder, builder::POST,
-                        HttpRequest.noBody(), null);
+                        noBody(), null);
 
         builder = test1("PUT", builder, builder::PUT,
-                        HttpRequest.noBody(), null);
+                        noBody(), null);
 
         builder = test2("method", builder, builder::method, "GET",
-                        HttpRequest.noBody(), null);
+                        noBody(), null);
 
         builder = test1("DELETE", builder, builder::DELETE,
                         (HttpRequest.BodyPublisher)null,
@@ -203,7 +204,7 @@
                         NullPointerException.class);
 
         builder = test2("method", builder, builder::method, null,
-                        HttpRequest.BodyPublisher.fromString("foo"),
+                        fromString("foo"),
                         NullPointerException.class);
 // see JDK-8170093
 //
--- a/test/jdk/java/net/httpclient/RequestBuilderTest.java	Fri Nov 17 15:42:34 2017 +0000
+++ b/test/jdk/java/net/httpclient/RequestBuilderTest.java	Fri Nov 17 15:44:11 2017 +0000
@@ -37,7 +37,7 @@
 import static jdk.incubator.http.HttpClient.Version.HTTP_1_1;
 import static jdk.incubator.http.HttpClient.Version.HTTP_2;
 import static jdk.incubator.http.HttpRequest.BodyPublisher.fromString;
-import static jdk.incubator.http.HttpRequest.noBody;
+import static jdk.incubator.http.HttpRequest.BodyPublisher.noBody;
 import static jdk.incubator.http.HttpRequest.newBuilder;
 import static org.testng.Assert.*;
 import org.testng.annotations.Test;