http-client-branch: Http2Connection should not try to send RST_STREAM if the channel is already closed
--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Wed May 02 15:47:57 2018 +0100
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Thu May 03 18:27:32 2018 +0100
@@ -797,12 +797,22 @@
}
void resetStream(int streamid, int code) throws IOException {
- Log.logError(
- "Resetting stream {0,number,integer} with error code {1,number,integer}",
- streamid, code);
- ResetFrame frame = new ResetFrame(streamid, code);
- sendFrame(frame);
- closeStream(streamid);
+ try {
+ if (connection.channel().isOpen()) {
+ // no need to try & send a reset frame if the
+ // connection channel is already closed.
+ Log.logError(
+ "Resetting stream {0,number,integer} with error code {1,number,integer}",
+ streamid, code);
+ ResetFrame frame = new ResetFrame(streamid, code);
+ sendFrame(frame);
+ } else if (debug.on()) {
+ debug.log("Channel already closed, no need to reset stream %d",
+ streamid);
+ }
+ } finally {
+ closeStream(streamid);
+ }
}
void closeStream(int streamid) {