Search in sources :

Example 61 with OperatedClientConnection

use of org.apache.http.conn.OperatedClientConnection in project platform_external_apache-http by android.

the class RouteSpecificPool method allocEntry.

/**
     * Obtains a free entry from this pool, if one is available.
     *
     * @return an available pool entry, or <code>null</code> if there is none
     */
public BasicPoolEntry allocEntry(final Object state) {
    if (!freeEntries.isEmpty()) {
        ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
        while (it.hasPrevious()) {
            BasicPoolEntry entry = it.previous();
            if (LangUtils.equals(state, entry.getState())) {
                it.remove();
                return entry;
            }
        }
    }
    if (!freeEntries.isEmpty()) {
        BasicPoolEntry entry = freeEntries.remove();
        entry.setState(null);
        OperatedClientConnection conn = entry.getConnection();
        try {
            conn.close();
        } catch (IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
        return entry;
    }
    return null;
}
Also used : OperatedClientConnection(org.apache.http.conn.OperatedClientConnection) IOException(java.io.IOException)

Aggregations

OperatedClientConnection (org.apache.http.conn.OperatedClientConnection)61 InterruptedIOException (java.io.InterruptedIOException)5 IOException (java.io.IOException)4 Socket (java.net.Socket)4 SSLSession (javax.net.ssl.SSLSession)4 SSLSocket (javax.net.ssl.SSLSocket)4 RouteTracker (org.apache.http.conn.routing.RouteTracker)4 ConnectionShutdownException (org.apache.http.impl.conn.ConnectionShutdownException)4 HttpHost (org.apache.http.HttpHost)3