# HG changeset patch # User dfuchs # Date 1528728535 -3600 # Node ID 705824c1e59696ae7988009643d40e54300785b2 # Parent c5c86a0a368c4e11fc213f7183404fbc7329d08b http-client-branch: fix regression introcuced by last changeset diff -r c5c86a0a368c -r 705824c1e596 src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java --- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java Mon Jun 11 14:10:24 2018 +0100 +++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java Mon Jun 11 15:48:55 2018 +0100 @@ -396,7 +396,6 @@ && response != null && response.finished()) { return; } - connection.close(); // TODO: ensure non-blocking if holding the lock writePublisher.writeScheduler.stop(); if (operations.isEmpty()) { Log.logTrace("Http1Exchange: request [{0}/timeout={1}ms] no pending operation." @@ -419,27 +418,31 @@ operations.clear(); } } - Log.logError("Http1Exchange.cancel: count=" + count); - if (toComplete != null) { - // We might be in the selector thread in case of timeout, when - // the SelectorManager calls purgeTimeoutsAndReturnNextDeadline() - // There may or may not be other places that reach here - // from the SelectorManager thread, so just make sure we - // don't complete any CF from within the selector manager - // thread. - Executor exec = client.isSelectorThread() - ? executor - : this::runInline; - Throwable x = error; - while (!toComplete.isEmpty()) { - CompletableFuture cf = toComplete.poll(); - exec.execute(() -> { - if (cf.completeExceptionally(x)) { - if (debug.on()) - debug.log("%s: completed cf with %s", request.uri(), x); - } - }); + try { + Log.logError("Http1Exchange.cancel: count=" + count); + if (toComplete != null) { + // We might be in the selector thread in case of timeout, when + // the SelectorManager calls purgeTimeoutsAndReturnNextDeadline() + // There may or may not be other places that reach here + // from the SelectorManager thread, so just make sure we + // don't complete any CF from within the selector manager + // thread. + Executor exec = client.isSelectorThread() + ? executor + : this::runInline; + Throwable x = error; + while (!toComplete.isEmpty()) { + CompletableFuture cf = toComplete.poll(); + exec.execute(() -> { + if (cf.completeExceptionally(x)) { + if (debug.on()) + debug.log("%s: completed cf with %s", request.uri(), x); + } + }); + } } + } finally { + connection.close(); } }