Example usage for org.apache.http.impl.conn.tsccm BasicPoolEntry shutdownEntry

List of usage examples for org.apache.http.impl.conn.tsccm BasicPoolEntry shutdownEntry

Introduction

In this page you can find the example usage for org.apache.http.impl.conn.tsccm BasicPoolEntry shutdownEntry.

Prototype

@Override
    protected void shutdownEntry() 

Source Link

Usage

From source file:org.apache.http.impl.conn.tsccm.RouteSpecificPool.java

/**
 * Obtains a free entry from this pool, if one is available.
 *
 * @return an available pool entry, or <code>null</code> if there is none
 *//*from   www  .  j  a  v  a 2s.  co m*/
public BasicPoolEntry allocEntry(final Object state) {
    if (!freeEntries.isEmpty()) {
        final ListIterator<BasicPoolEntry> it = freeEntries.listIterator(freeEntries.size());
        while (it.hasPrevious()) {
            final BasicPoolEntry entry = it.previous();
            if (entry.getState() == null || LangUtils.equals(state, entry.getState())) {
                it.remove();
                return entry;
            }
        }
    }
    if (getCapacity() == 0 && !freeEntries.isEmpty()) {
        final BasicPoolEntry entry = freeEntries.remove();
        entry.shutdownEntry();
        final OperatedClientConnection conn = entry.getConnection();
        try {
            conn.close();
        } catch (final IOException ex) {
            log.debug("I/O error closing connection", ex);
        }
        return entry;
    }
    return null;
}