public void releaseConnection(NHttpClientConnection conn) {
   if (conn == null) {
     return;
   }
   if (this.shutdown) {
     return;
   }
   synchronized (this.lock) {
     if (this.allConns.contains(conn)) {
       if (conn.isOpen()) {
         conn.setSocketTimeout(0);
         AsyncConnectionRequest request = this.pendingRequests.poll();
         if (request != null) {
           System.out.println("Re-using persistent connection");
           request.setConnection(conn);
         } else {
           this.availableConns.add(conn);
         }
       } else {
         this.allConns.remove(conn);
         processRequests();
       }
     }
   }
 }
 public AsyncConnectionRequest requestConnection() {
   if (this.shutdown) {
     throw new IllegalStateException("Connection manager has been shut down");
   }
   AsyncConnectionRequest request = new AsyncConnectionRequest();
   synchronized (this.lock) {
     while (!this.availableConns.isEmpty()) {
       NHttpClientConnection conn = this.availableConns.remove();
       if (conn.isOpen()) {
         System.out.println("Re-using persistent connection");
         request.setConnection(conn);
         break;
       } else {
         this.allConns.remove(conn);
       }
     }
     if (!request.isCompleted()) {
       this.pendingRequests.add(request);
       processRequests();
     }
   }
   return request;
 }