http-client-branch: addditional BufferingSubscriberTest checks http-client-branch
authorchegar
Wed, 06 Dec 2017 12:11:36 +0000
branchhttp-client-branch
changeset 55960 7553e90ba43c
parent 55959 7fd1a84f4fae
child 55961 896f012552ca
http-client-branch: addditional BufferingSubscriberTest checks
test/jdk/java/net/httpclient/BufferingSubscriberTest.java
--- a/test/jdk/java/net/httpclient/BufferingSubscriberTest.java	Wed Dec 06 12:05:38 2017 +0000
+++ b/test/jdk/java/net/httpclient/BufferingSubscriberTest.java	Wed Dec 06 12:11:36 2017 +0000
@@ -32,6 +32,7 @@
 import java.util.concurrent.Flow;
 import java.util.concurrent.Flow.Subscription;
 import java.util.concurrent.SubmissionPublisher;
+import java.util.function.BiConsumer;
 import jdk.incubator.http.HttpResponse.BodyHandler;
 import jdk.incubator.http.HttpResponse.BodySubscriber;
 import jdk.test.lib.RandomFactory;
@@ -142,6 +143,15 @@
                  perRequestAmount);
     }
 
+    volatile boolean onNextThrew;
+
+    BiConsumer<Flow.Subscriber<?>, ? super Throwable> onNextThrowHandler =
+            (sub, ex) -> {
+                onNextThrew = true;
+                System.out.println("onNext threw " + ex);
+                ex.printStackTrace();
+    };
+
     public void test(int iterations,
                      int delayMillis,
                      int numBuffers,
@@ -156,7 +166,9 @@
                 printStamp(START, "Iteration %d", i);
                 try {
                     SubmissionPublisher<List<ByteBuffer>> publisher =
-                            new SubmissionPublisher<>(executor, 1);
+                            new SubmissionPublisher<>(executor,
+                                                      32,
+                                                      onNextThrowHandler);
                     CompletableFuture<?> cf = sink(publisher,
                             delayMillis,
                             numBuffers * bufferSize,
@@ -170,6 +182,9 @@
                     printStamp(END, "Iteration %d\n", i);
                 }
             }
+
+            assertFalse(onNextThrew, "Unexpected onNextThrew, check output");
+
             out.println("OK");
         } finally {
             executor.shutdown();