8161091: Incorrect HTTP Stream.FlowControl implementation allows to send DataFrame even when window size was exhausted
authorbpb
Tue, 19 Jul 2016 16:13:01 -0700
changeset 39757 5f3e350ee13e
parent 39756 c50c31af8cd9
child 39758 28c2c63fc09f
8161091: Incorrect HTTP Stream.FlowControl implementation allows to send DataFrame even when window size was exhausted Summary: Fix flow control Reviewed-by: rriggs, chegar Contributed-by: Sergey Kuksenko <sergey.kuksenko@oracle.com>
jdk/src/java.httpclient/share/classes/java/net/http/Stream.java
--- a/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java	Wed Jun 08 21:45:34 2016 +0100
+++ b/jdk/src/java.httpclient/share/classes/java/net/http/Stream.java	Tue Jul 19 16:13:01 2016 -0700
@@ -467,7 +467,7 @@
 
         public synchronized void take(int amount) throws InterruptedException {
             assert permits >= 0;
-            while (permits < amount) {
+            while (amount > 0) {
                 int n = Math.min(amount, permits);
                 permits -= n;
                 amount -= n;
@@ -499,7 +499,7 @@
 
     DataFrame getDataFrame() throws IOException, InterruptedException {
         userRequestFlowController.take();
-        int maxpayloadLen = connection.getMaxSendFrameSize() - 9;
+        int maxpayloadLen = connection.getMaxSendFrameSize();
         ByteBuffer buffer = connection.getBuffer();
         buffer.limit(maxpayloadLen);
         boolean complete = requestProcessor.onRequestBodyChunk(buffer);