http-client-branch: 8198947: HttpClient fails to send successive POST requests under HTTP/2
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Fri Mar 02 10:18:48 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Fri Mar 02 15:14:03 2018 +0000
@@ -792,13 +792,16 @@
{
assert frame.streamid() == 0;
if (!frame.getFlag(SettingsFrame.ACK)) {
- int oldWindowSize = serverSettings.getParameter(INITIAL_WINDOW_SIZE);
int newWindowSize = frame.getParameter(INITIAL_WINDOW_SIZE);
- int diff = newWindowSize - oldWindowSize;
- if (diff != 0) {
- windowController.adjustActiveStreams(diff);
+ if (newWindowSize != -1) {
+ int oldWindowSize = serverSettings.getParameter(INITIAL_WINDOW_SIZE);
+ int diff = newWindowSize - oldWindowSize;
+ if (diff != 0) {
+ windowController.adjustActiveStreams(diff);
+ }
}
- serverSettings = frame;
+
+ serverSettings.update(frame);
sendFrame(new SettingsFrame(SettingsFrame.ACK));
}
}
--- a/src/java.net.http/share/classes/jdk/internal/net/http/WindowController.java Fri Mar 02 10:18:48 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/WindowController.java Fri Mar 02 15:14:03 2018 +0000
@@ -186,7 +186,9 @@
if (size < 0)
return false;
connectionWindowSize = size;
- DEBUG_LOGGER.log(Level.DEBUG, "Connection window size is now %d", size);
+ DEBUG_LOGGER.log(Level.DEBUG,
+ "Connection window size is now %d (amount added %d)",
+ size, amount);
// Notify waiting streams, until the new increased window size is
// effectively exhausted.
@@ -244,7 +246,8 @@
return false;
streams.put(streamid, size);
DEBUG_LOGGER.log(Level.DEBUG,
- "Stream %s window size is now %s", streamid, size);
+ "Stream %s window size is now %s (amount added %d)",
+ streamid, size, amount);
Map.Entry<Stream<?>,Integer> p = pending.get(streamid);
if (p != null) {
@@ -286,7 +289,8 @@
size += adjustAmount;
streams.put(streamid, size);
DEBUG_LOGGER.log(Level.DEBUG,
- "Stream %s window size is now %s", streamid, size);
+ "Stream %s window size is now %s (adjusting amount %d)",
+ streamid, size, adjustAmount);
}
}
} finally {
--- a/src/java.net.http/share/classes/jdk/internal/net/http/frame/SettingsFrame.java Fri Mar 02 10:18:48 2018 +0000
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/frame/SettingsFrame.java Fri Mar 02 15:14:03 2018 +0000
@@ -114,7 +114,7 @@
if (paramID > MAX_PARAM) {
throw new IllegalArgumentException("illegal parameter");
}
- return parameters[paramID-1];
+ return parameters[paramID - 1];
}
public SettingsFrame setParameter(int paramID, int value) {
@@ -153,6 +153,14 @@
private static final int K = 1024;
+ public synchronized void update(SettingsFrame updated) {
+ for (int i = 0; i < MAX_PARAM; i++) {
+ if (updated.parameters[i] != -1) {
+ parameters[i] = updated.parameters[i];
+ }
+ }
+ }
+
public static SettingsFrame getDefaultSettings() {
SettingsFrame f = new SettingsFrame();
// TODO: check these values