src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java
changeset 50985 cd41f34e548c
parent 50681 4254bed3c09d
child 52499 768b1c612100
child 56833 be0819373531
--- a/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Wed Jul 04 16:54:56 2018 +0200
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/SocketTube.java	Wed Jul 04 16:16:24 2018 +0100
@@ -360,7 +360,6 @@
                 }
             } catch (Throwable t) {
                 signalError(t);
-                subscription.cancel();
             }
         }
 
@@ -424,6 +423,8 @@
             }
             completed = true;
             readPublisher.signalError(error);
+            Flow.Subscription subscription = this.subscription;
+            if (subscription != null) subscription.cancel();
         }
 
         // A repeatable WriteEvent which is paused after firing and can
@@ -468,7 +469,11 @@
 
             @Override
             public void cancel() {
+                if (cancelled) return;
                 if (debug.on()) debug.log("write: cancel");
+                if (Log.channel()) {
+                    Log.logChannel("Cancelling write subscription");
+                }
                 dropSubscription();
                 upstreamSubscription.cancel();
             }
@@ -503,9 +508,7 @@
                 } catch (Throwable t) {
                     if (debug.on())
                         debug.log("write: error while requesting more: " + t);
-                    cancelled = true;
                     signalError(t);
-                    subscription.cancel();
                 } finally {
                     debugState("leaving requestMore: ");
                 }