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>
--- 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);