changeset 44099:bc1a91ee90f0

8176155: SubmissionPublisher closeExceptionally() may override close() Reviewed-by: martin, psandoz
author dl
date Tue, 07 Mar 2017 10:06:39 -0800
parents 4d25a0bb7426
children 9438f2fa5dd9
files jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java
diffstat 1 files changed, 6 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Tue Mar 07 22:55:36 2017 +0800
+++ b/jdk/src/java.base/share/classes/java/util/concurrent/SubmissionPublisher.java	Tue Mar 07 10:06:39 2017 -0800
@@ -588,6 +588,7 @@
         if (!closed) {
             BufferedSubscription<T> b;
             synchronized (this) {
+                // no need to re-check closed here
                 b = clients;
                 clients = null;
                 closed = true;
@@ -619,9 +620,11 @@
             BufferedSubscription<T> b;
             synchronized (this) {
                 b = clients;
-                clients = null;
-                closed = true;
-                closedException = error;
+                if (!closed) {  // don't clobber racing close
+                    clients = null;
+                    closedException = error;
+                    closed = true;
+                }
             }
             while (b != null) {
                 BufferedSubscription<T> next = b.next;