src/java.net.http/share/classes/jdk/internal/net/http/HttpConnection.java
changeset 54324 9d5c84b0a598
parent 53300 54aa3ea04fe8
child 54579 270557b396eb
equal deleted inserted replaced
54323:846bc643f4ef 54324:9d5c84b0a598
   315     }
   315     }
   316 
   316 
   317     void closeOrReturnToCache(HttpHeaders hdrs) {
   317     void closeOrReturnToCache(HttpHeaders hdrs) {
   318         if (hdrs == null) {
   318         if (hdrs == null) {
   319             // the connection was closed by server, eof
   319             // the connection was closed by server, eof
       
   320             Log.logTrace("Cannot return connection to pool: closing {0}", this);
   320             close();
   321             close();
   321             return;
   322             return;
   322         }
   323         }
   323         if (!isOpen()) {
       
   324             return;
       
   325         }
       
   326         HttpClientImpl client = client();
   324         HttpClientImpl client = client();
   327         if (client == null) {
   325         if (client == null) {
       
   326             Log.logTrace("Client released: closing {0}", this);
   328             close();
   327             close();
   329             return;
   328             return;
   330         }
   329         }
   331         ConnectionPool pool = client.connectionPool();
   330         ConnectionPool pool = client.connectionPool();
   332         boolean keepAlive = hdrs.firstValue("Connection")
   331         boolean keepAlive = hdrs.firstValue("Connection")
   333                 .map((s) -> !s.equalsIgnoreCase("close"))
   332                 .map((s) -> !s.equalsIgnoreCase("close"))
   334                 .orElse(true);
   333                 .orElse(true);
   335 
   334 
   336         if (keepAlive) {
   335         if (keepAlive && isOpen()) {
   337             Log.logTrace("Returning connection to the pool: {0}", this);
   336             Log.logTrace("Returning connection to the pool: {0}", this);
   338             pool.returnToPool(this);
   337             pool.returnToPool(this);
   339         } else {
   338         } else {
       
   339             Log.logTrace("Closing connection (keepAlive={0}, isOpen={1}): {2}",
       
   340                     keepAlive, isOpen(), this);
   340             close();
   341             close();
   341         }
   342         }
   342     }
   343     }
   343 
   344 
   344     /* Tells whether or not this connection is a tunnel through a proxy */
   345     /* Tells whether or not this connection is a tunnel through a proxy */