List of usage examples for org.apache.http.impl.client ConnectionStatistics getLastUsed
public long getLastUsed()
From source file:org.apache.http.impl.client.AbstractStatisticsGatheringHttpClient.java
/** * Creates a new HTTP client.//from w w w.j av a2 s.c om * * @param conman the connection manager * @param params the parameters */ protected AbstractStatisticsGatheringHttpClient(final ClientConnectionManager conman, final HttpParams params) { defaultParams = params; connManager = conman; Thread t = new Thread() { @Override public void run() { while (true) { synchronized (connectionStats) { for (Integer key : connectionStats.keySet()) { ConnectionStatistics stats = connectionStats.get(key); if (stats.getConnectionState().equals(ConnectionStatistics.State.OPEN)) { if (System.currentTimeMillis() - stats.getLastUsed() > 30000) { log.warn("Possible connection leak for connection " + key + " duration(ms): " + (System.currentTimeMillis() - stats.getLastUsed()) + " request: " + stats.getLastRequest()); } } } } try { Thread.currentThread().sleep(30000); } catch (InterruptedException e) { } } } }; t.start(); }