# HG changeset patch # User dfuchs # Date 1528821300 -3600 # Node ID 5c86a9790f5af9c38f7c1e3a43d9248b8c4e5cf8 # Parent 00b64a0234f594fd30964c52876ffbb176bc5345 http-client-branch: improve error logging for HTTP/2 connection shutdown diff -r 00b64a0234f5 -r 5c86a9790f5a src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Tue Jun 12 16:07:19 2018 +0100 +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http2Connection.java Tue Jun 12 17:35:00 2018 +0100 @@ -661,7 +661,13 @@ if (closed == true) return; closed = true; } - Log.logError(t); + if (Log.errors()) { + if (!(t instanceof EOFException) || isActive()) { + Log.logError(t); + } else if (t != null) { + Log.logError("Shutting down connection: {0}", t.getMessage()); + } + } Throwable initialCause = this.cause; if (initialCause == null) this.cause = t; client2.deleteConnection(this); @@ -1278,8 +1284,11 @@ @Override public void onComplete() { - if (debug.on()) debug.log("EOF"); - error = new EOFException("EOF reached while reading"); + String msg = isActive() + ? "EOF reached while reading" + : "Idle connection closed by HTTP/2 peer"; + if (debug.on()) debug.log(msg); + error = new EOFException(msg); completed = true; runOrSchedule(); } @@ -1293,6 +1302,10 @@ } } + synchronized boolean isActive() { + return numReservedClientStreams > 0 || numReservedServerStreams > 0; + } + @Override public final String toString() { return dbgString();