http-client-branch: inconsistent synchronization of PushGroup http-client-branch
authorchegar
Mon, 05 Feb 2018 11:54:03 +0000
branchhttp-client-branch
changeset 56062 48afabd2de78
parent 56061 6d6290b1176f
child 56063 fb2dd3c0dd60
http-client-branch: inconsistent synchronization of PushGroup
src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java
--- a/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java	Mon Feb 05 11:46:00 2018 +0000
+++ b/src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/PushGroup.java	Mon Feb 05 11:54:03 2018 +0000
@@ -106,15 +106,16 @@
 
         pushPromiseHandler.applyPushPromise(initiatingRequest, pushRequest, acceptor::accept);
 
-        if (acceptor.accepted()) {
-            if (acceptor.bodyHandler instanceof UntrustedBodyHandler) {
-                ((UntrustedBodyHandler)acceptor.bodyHandler).setAccessControlContext(acc);
+        synchronized (this) {
+            if (acceptor.accepted()) {
+                if (acceptor.bodyHandler instanceof UntrustedBodyHandler) {
+                    ((UntrustedBodyHandler) acceptor.bodyHandler).setAccessControlContext(acc);
+                }
+                numberOfPushes++;
+                remainingPushes++;
             }
-            numberOfPushes++;
-            remainingPushes++;
+            return acceptor;
         }
-        return acceptor;
-
     }
 
     // This is called when the main body response completes because it means
@@ -126,7 +127,7 @@
         noMorePushesCF.complete(null);
     }
 
-    CompletableFuture<Void> pushesCF() {
+    synchronized CompletableFuture<Void> pushesCF() {
         return noMorePushesCF;
     }