/** * since 3.1 */ public void shutdown() { httpConnection.close(); }
/** * Aborts the execution of this method. * * @since 3.0 */ public void abort() { if (this.aborted) { return; } this.aborted = true; HttpConnection conn = this.responseConnection; if (conn != null) { conn.close(); } }
/** * @since 3.0 */ public void closeIdleConnections(long idleTimeout) { long maxIdleTime = System.currentTimeMillis() - idleTimeout; if (idleStartTime <= maxIdleTime) { httpConnection.close(); } }
public void close() { if (hasConnection()) { wrappedConnection.close(); } else { // do nothing } }
/** * @see HttpConnectionManager#releaseConnection(org.apache.commons.httpclient.HttpConnection) */ public void releaseConnection(HttpConnection conn) { if (conn != httpConnection) { throw new IllegalStateException("Unexpected release of an unknown connection."); } if (this.alwaysClose) { httpConnection.close(); } else { // make sure the connection is reuseable finishLastResponse(httpConnection); } inUse = false; // track the time the connection was made idle idleStartTime = System.currentTimeMillis(); }
/** * Closes the connection if stale. * * @return <code>true</code> if the connection was stale and therefore closed, * <code>false</code> otherwise. * * @see #isStale() * * @since 3.0 */ public boolean closeIfStale() throws IOException { if (isOpen && isStale()) { LOG.debug("Connection is stale, closing..."); close(); return true; } return false; }
/** * Closes connections that have been idle for at least the given amount of time. * * @param idleTime the minimum idle time, in milliseconds, for connections to be closed */ public void closeIdleConnections(long idleTime) { // the latest time for which connections will be closed long idleTimeout = System.currentTimeMillis() - idleTime; if (LOG.isDebugEnabled()) { LOG.debug("Checking for connections, idleTimeout: " + idleTimeout); } Iterator connectionIter = connectionToAdded.keySet().iterator(); while (connectionIter.hasNext()) { HttpConnection conn = (HttpConnection) connectionIter.next(); Long connectionTime = (Long) connectionToAdded.get(conn); if (connectionTime.longValue() <= idleTimeout) { if (LOG.isDebugEnabled()) { LOG.debug("Closing connection, connection time: " + connectionTime); } connectionIter.remove(); conn.close(); } } } }
HttpConnection conn = (HttpConnection) iter.next(); iter.remove(); conn.close();
/** * Since the same connection is about to be reused, make sure the * previous request was completely processed, and if not * consume it now. * @param conn The connection */ static void finishLastResponse(HttpConnection conn) { InputStream lastResponse = conn.getLastResponseInputStream(); if (lastResponse != null) { conn.setLastResponseInputStream(null); try { lastResponse.close(); } catch (IOException ioe) { conn.close(); } } }
public void close() { if (httpConnection != null) { if (httpConnection.isOpen()) { releaseConnection(httpConnection); } httpConnection.close(); } httpConnection = null; conn = null; } }
connection.close();
/** * Deletes the given connection. This will remove all reference to the connection * so that it can be GCed. * * <p><b>Note:</b> Does not remove the connection from the freeConnections list. It * is assumed that the caller has already handled this case.</p> * * @param connection The connection to delete */ private synchronized void deleteConnection(HttpConnection connection) { HostConfiguration connectionConfiguration = configurationForConnection(connection); if (LOG.isDebugEnabled()) { LOG.debug("Reclaiming connection, hostConfig=" + connectionConfiguration); } connection.close(); HostConnectionPool hostPool = getHostPool(connectionConfiguration, true); hostPool.freeConnections.remove(connection); hostPool.numConnections--; numConnections--; if ((hostPool.numConnections == 0) && hostPool.waitingThreads.isEmpty()) { mapHosts.remove(connectionConfiguration); } // remove the connection from the timeout handler idleConnectionHandler.remove(connection); }
conn.close(); return;
response.setSocket(connectionManager.getConnection().getSocket()); } else { connectionManager.getConnection().close();
return true; } else { this.conn.close(); return false;
httpConnection.close();
public void close() { if (hasConnection()) { wrappedConnection.close(); } else { // do nothing } }
public void close() { if (hasConnection()) { wrappedConnection.close(); } else { // do nothing } }