--- a/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java Mon Apr 23 15:45:40 2018 +0100
+++ b/src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java Tue Apr 24 10:14:51 2018 +0100
@@ -259,8 +259,19 @@
if (!connection.connected()) {
if (debug.on()) debug.log("initiating connect async");
connectCF = connection.connectAsync();
+ Throwable cancelled;
synchronized (lock) {
- operations.add(connectCF);
+ if ((cancelled = failed) == null) {
+ operations.add(connectCF);
+ }
+ }
+ if (cancelled != null) {
+ if (client.isSelectorThread()) {
+ executor.execute(() ->
+ connectCF.completeExceptionally(cancelled));
+ } else {
+ connectCF.completeExceptionally(cancelled);
+ }
}
} else {
connectCF = new MinimalFuture<>();
@@ -403,6 +414,9 @@
if ((error = failed) == null) {
failed = error = cause;
}
+ if (debug.on()) {
+ debug.log(request.uri() + ": " + error);
+ }
if (requestAction != null && requestAction.finished()
&& response != null && response.finished()) {
return;
@@ -447,7 +461,7 @@
exec.execute(() -> {
if (cf.completeExceptionally(x)) {
if (debug.on())
- debug.log("completed cf with %s", (Object) x);
+ debug.log("%s: completed cf with %s", request.uri(), x);
}
});
}