src/java.net.http/share/classes/jdk/internal/net/http/Http1Exchange.java
changeset 49944 4690a2871b44
parent 49765 ee6f7a61f3a5
child 50681 4254bed3c09d
child 56507 2294c51eae30
equal deleted inserted replaced
49943:8e1ed2a15845 49944:4690a2871b44
   257 
   257 
   258         CompletableFuture<Void> connectCF;
   258         CompletableFuture<Void> connectCF;
   259         if (!connection.connected()) {
   259         if (!connection.connected()) {
   260             if (debug.on()) debug.log("initiating connect async");
   260             if (debug.on()) debug.log("initiating connect async");
   261             connectCF = connection.connectAsync();
   261             connectCF = connection.connectAsync();
       
   262             Throwable cancelled;
   262             synchronized (lock) {
   263             synchronized (lock) {
   263                 operations.add(connectCF);
   264                 if ((cancelled = failed) == null) {
       
   265                     operations.add(connectCF);
       
   266                 }
       
   267             }
       
   268             if (cancelled != null) {
       
   269                 if (client.isSelectorThread()) {
       
   270                     executor.execute(() ->
       
   271                         connectCF.completeExceptionally(cancelled));
       
   272                 } else {
       
   273                     connectCF.completeExceptionally(cancelled);
       
   274                 }
   264             }
   275             }
   265         } else {
   276         } else {
   266             connectCF = new MinimalFuture<>();
   277             connectCF = new MinimalFuture<>();
   267             connectCF.complete(null);
   278             connectCF.complete(null);
   268         }
   279         }
   400         int count = 0;
   411         int count = 0;
   401         Throwable error;
   412         Throwable error;
   402         synchronized (lock) {
   413         synchronized (lock) {
   403             if ((error = failed) == null) {
   414             if ((error = failed) == null) {
   404                 failed = error = cause;
   415                 failed = error = cause;
       
   416             }
       
   417             if (debug.on()) {
       
   418                 debug.log(request.uri() + ": " + error);
   405             }
   419             }
   406             if (requestAction != null && requestAction.finished()
   420             if (requestAction != null && requestAction.finished()
   407                     && response != null && response.finished()) {
   421                     && response != null && response.finished()) {
   408                 return;
   422                 return;
   409             }
   423             }
   445             while (!toComplete.isEmpty()) {
   459             while (!toComplete.isEmpty()) {
   446                 CompletableFuture<?> cf = toComplete.poll();
   460                 CompletableFuture<?> cf = toComplete.poll();
   447                 exec.execute(() -> {
   461                 exec.execute(() -> {
   448                     if (cf.completeExceptionally(x)) {
   462                     if (cf.completeExceptionally(x)) {
   449                         if (debug.on())
   463                         if (debug.on())
   450                             debug.log("completed cf with %s", (Object) x);
   464                             debug.log("%s: completed cf with %s", request.uri(), x);
   451                     }
   465                     }
   452                 });
   466                 });
   453             }
   467             }
   454         }
   468         }
   455     }
   469     }