.class public final Lokhttp3/ConnectionPool; .super Ljava/lang/Object; .source "" # static fields .field static final synthetic $assertionsDisabled:Z .field private static final executor:Ljava/util/concurrent/Executor; # instance fields .field private final cleanupRunnable:Ljava/lang/Runnable; .field cleanupRunning:Z .field private final connections:Ljava/util/Deque; .annotation system Ldalvik/annotation/Signature; value = { "Ljava/util/Deque<", "Lokhttp3/internal/connection/RealConnection;", ">;" } .end annotation .end field .field private final keepAliveDurationNs:J .field private final maxIdleConnections:I .field final routeDatabase:Lokhttp3/internal/connection/RouteDatabase; # direct methods .method static constructor ()V .locals 9 new-instance v8, Ljava/util/concurrent/ThreadPoolExecutor; const/4 v1, 0x0 const v2, 0x7fffffff const-wide/16 v3, 0x3c sget-object v5, Ljava/util/concurrent/TimeUnit;->SECONDS:Ljava/util/concurrent/TimeUnit; new-instance v6, Ljava/util/concurrent/SynchronousQueue; invoke-direct {v6}, Ljava/util/concurrent/SynchronousQueue;->()V const/4 v0, 0x1 const-string v7, "OkHttp ConnectionPool" invoke-static {v7, v0}, Lokhttp3/internal/Util;->threadFactory(Ljava/lang/String;Z)Ljava/util/concurrent/ThreadFactory; move-result-object v7 move-object v0, v8 invoke-direct/range {v0 .. v7}, Ljava/util/concurrent/ThreadPoolExecutor;->(IIJLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/BlockingQueue;Ljava/util/concurrent/ThreadFactory;)V sput-object v8, Lokhttp3/ConnectionPool;->executor:Ljava/util/concurrent/Executor; return-void .end method .method public constructor ()V .locals 4 sget-object v0, Ljava/util/concurrent/TimeUnit;->MINUTES:Ljava/util/concurrent/TimeUnit; const/4 v1, 0x5 const-wide/16 v2, 0x5 invoke-direct {p0, v1, v2, v3, v0}, Lokhttp3/ConnectionPool;->(IJLjava/util/concurrent/TimeUnit;)V return-void .end method .method public constructor (IJLjava/util/concurrent/TimeUnit;)V .locals 2 invoke-direct {p0}, Ljava/lang/Object;->()V new-instance v0, Lokhttp3/ConnectionPool$1; invoke-direct {v0, p0}, Lokhttp3/ConnectionPool$1;->(Lokhttp3/ConnectionPool;)V iput-object v0, p0, Lokhttp3/ConnectionPool;->cleanupRunnable:Ljava/lang/Runnable; new-instance v0, Ljava/util/ArrayDeque; invoke-direct {v0}, Ljava/util/ArrayDeque;->()V iput-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; new-instance v0, Lokhttp3/internal/connection/RouteDatabase; invoke-direct {v0}, Lokhttp3/internal/connection/RouteDatabase;->()V iput-object v0, p0, Lokhttp3/ConnectionPool;->routeDatabase:Lokhttp3/internal/connection/RouteDatabase; iput p1, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I invoke-virtual {p4, p2, p3}, Ljava/util/concurrent/TimeUnit;->toNanos(J)J move-result-wide v0 iput-wide v0, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J const-wide/16 v0, 0x0 cmp-long p1, p2, v0 if-lez p1, :cond_0 return-void :cond_0 new-instance p1, Ljava/lang/IllegalArgumentException; new-instance p4, Ljava/lang/StringBuilder; invoke-direct {p4}, Ljava/lang/StringBuilder;->()V const-string v0, "keepAliveDuration <= 0: " invoke-virtual {p4, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {p4, p2, p3}, Ljava/lang/StringBuilder;->append(J)Ljava/lang/StringBuilder; invoke-virtual {p4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object p2 invoke-direct {p1, p2}, Ljava/lang/IllegalArgumentException;->(Ljava/lang/String;)V throw p1 .end method .method private pruneAndGetAllocationCount(Lokhttp3/internal/connection/RealConnection;J)I .locals 6 iget-object v0, p1, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List; const/4 v1, 0x0 const/4 v2, 0x0 :cond_0 :goto_0 invoke-interface {v0}, Ljava/util/List;->size()I move-result v3 if-ge v2, v3, :cond_2 invoke-interface {v0, v2}, Ljava/util/List;->get(I)Ljava/lang/Object; move-result-object v3 check-cast v3, Ljava/lang/ref/Reference; invoke-virtual {v3}, Ljava/lang/ref/Reference;->get()Ljava/lang/Object; move-result-object v4 if-eqz v4, :cond_1 add-int/lit8 v2, v2, 0x1 goto :goto_0 :cond_1 check-cast v3, Lokhttp3/internal/connection/StreamAllocation$StreamAllocationReference; new-instance v4, Ljava/lang/StringBuilder; invoke-direct {v4}, Ljava/lang/StringBuilder;->()V const-string v5, "A connection to " invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {p1}, Lokhttp3/internal/connection/RealConnection;->route()Lokhttp3/Route; move-result-object v5 invoke-virtual {v5}, Lokhttp3/Route;->address()Lokhttp3/Address; move-result-object v5 invoke-virtual {v5}, Lokhttp3/Address;->url()Lokhttp3/HttpUrl; move-result-object v5 invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/Object;)Ljava/lang/StringBuilder; const-string v5, " was leaked. Did you forget to close a response body?" invoke-virtual {v4, v5}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder; invoke-virtual {v4}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String; move-result-object v4 invoke-static {}, Lokhttp3/internal/platform/Platform;->get()Lokhttp3/internal/platform/Platform; move-result-object v5 iget-object v3, v3, Lokhttp3/internal/connection/StreamAllocation$StreamAllocationReference;->callStackTrace:Ljava/lang/Object; invoke-virtual {v5, v4, v3}, Lokhttp3/internal/platform/Platform;->logCloseableLeak(Ljava/lang/String;Ljava/lang/Object;)V invoke-interface {v0, v2}, Ljava/util/List;->remove(I)Ljava/lang/Object; const/4 v3, 0x1 iput-boolean v3, p1, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z invoke-interface {v0}, Ljava/util/List;->isEmpty()Z move-result v3 if-eqz v3, :cond_0 iget-wide v2, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J sub-long/2addr p2, v2 iput-wide p2, p1, Lokhttp3/internal/connection/RealConnection;->idleAtNanos:J return v1 :cond_2 invoke-interface {v0}, Ljava/util/List;->size()I move-result p1 return p1 .end method # virtual methods .method cleanup(J)J .locals 11 monitor-enter p0 :try_start_0 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator; move-result-object v0 const/4 v1, 0x0 const/4 v2, 0x0 const-wide/high16 v3, -0x8000000000000000L move-object v5, v2 const/4 v2, 0x0 const/4 v6, 0x0 :cond_0 :goto_0 invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z move-result v7 if-eqz v7, :cond_2 invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v7 check-cast v7, Lokhttp3/internal/connection/RealConnection; invoke-direct {p0, v7, p1, p2}, Lokhttp3/ConnectionPool;->pruneAndGetAllocationCount(Lokhttp3/internal/connection/RealConnection;J)I move-result v8 if-lez v8, :cond_1 add-int/lit8 v6, v6, 0x1 goto :goto_0 :cond_1 add-int/lit8 v2, v2, 0x1 iget-wide v8, v7, Lokhttp3/internal/connection/RealConnection;->idleAtNanos:J sub-long v8, p1, v8 cmp-long v10, v8, v3 if-lez v10, :cond_0 move-object v5, v7 move-wide v3, v8 goto :goto_0 :cond_2 iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J cmp-long v0, v3, p1 if-gez v0, :cond_6 iget p1, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I if-le v2, p1, :cond_3 goto :goto_1 :cond_3 if-lez v2, :cond_4 iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J sub-long/2addr p1, v3 monitor-exit p0 return-wide p1 :cond_4 if-lez v6, :cond_5 iget-wide p1, p0, Lokhttp3/ConnectionPool;->keepAliveDurationNs:J monitor-exit p0 return-wide p1 :cond_5 iput-boolean v1, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z const-wide/16 p1, -0x1 monitor-exit p0 return-wide p1 :cond_6 :goto_1 iget-object p1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {p1, v5}, Ljava/util/Deque;->remove(Ljava/lang/Object;)Z monitor-exit p0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 invoke-virtual {v5}, Lokhttp3/internal/connection/RealConnection;->socket()Ljava/net/Socket; move-result-object p1 invoke-static {p1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/net/Socket;)V const-wide/16 p1, 0x0 return-wide p1 :catchall_0 move-exception p1 :try_start_1 monitor-exit p0 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 goto :goto_3 :goto_2 throw p1 :goto_3 goto :goto_2 .end method .method connectionBecameIdle(Lokhttp3/internal/connection/RealConnection;)Z .locals 1 iget-boolean v0, p1, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z if-nez v0, :cond_1 iget v0, p0, Lokhttp3/ConnectionPool;->maxIdleConnections:I if-nez v0, :cond_0 goto :goto_0 :cond_0 invoke-virtual {p0}, Ljava/lang/Object;->notifyAll()V const/4 p1, 0x0 return p1 :cond_1 :goto_0 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0, p1}, Ljava/util/Deque;->remove(Ljava/lang/Object;)Z const/4 p1, 0x1 return p1 .end method .method public declared-synchronized connectionCount()I .locals 1 monitor-enter p0 :try_start_0 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0}, Ljava/util/Deque;->size()I move-result v0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 monitor-exit p0 return v0 :catchall_0 move-exception v0 monitor-exit p0 throw v0 .end method .method deduplicate(Lokhttp3/Address;Lokhttp3/internal/connection/StreamAllocation;)Ljava/net/Socket; .locals 3 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator; move-result-object v0 :cond_0 invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z move-result v1 const/4 v2, 0x0 if-eqz v1, :cond_1 invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v1 check-cast v1, Lokhttp3/internal/connection/RealConnection; invoke-virtual {v1, p1, v2}, Lokhttp3/internal/connection/RealConnection;->isEligible(Lokhttp3/Address;Lokhttp3/Route;)Z move-result v2 if-eqz v2, :cond_0 invoke-virtual {v1}, Lokhttp3/internal/connection/RealConnection;->isMultiplexed()Z move-result v2 if-eqz v2, :cond_0 invoke-virtual {p2}, Lokhttp3/internal/connection/StreamAllocation;->connection()Lokhttp3/internal/connection/RealConnection; move-result-object v2 if-eq v1, v2, :cond_0 invoke-virtual {p2, v1}, Lokhttp3/internal/connection/StreamAllocation;->releaseAndAcquire(Lokhttp3/internal/connection/RealConnection;)Ljava/net/Socket; move-result-object p1 return-object p1 :cond_1 return-object v2 .end method .method public evictAll()V .locals 4 new-instance v0, Ljava/util/ArrayList; invoke-direct {v0}, Ljava/util/ArrayList;->()V monitor-enter p0 :try_start_0 iget-object v1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator; move-result-object v1 :cond_0 :goto_0 invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z move-result v2 if-eqz v2, :cond_1 invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v2 check-cast v2, Lokhttp3/internal/connection/RealConnection; iget-object v3, v2, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List; invoke-interface {v3}, Ljava/util/List;->isEmpty()Z move-result v3 if-eqz v3, :cond_0 const/4 v3, 0x1 iput-boolean v3, v2, Lokhttp3/internal/connection/RealConnection;->noNewStreams:Z invoke-interface {v0, v2}, Ljava/util/List;->add(Ljava/lang/Object;)Z invoke-interface {v1}, Ljava/util/Iterator;->remove()V goto :goto_0 :cond_1 monitor-exit p0 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 invoke-interface {v0}, Ljava/util/List;->iterator()Ljava/util/Iterator; move-result-object v0 :goto_1 invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z move-result v1 if-eqz v1, :cond_2 invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v1 check-cast v1, Lokhttp3/internal/connection/RealConnection; invoke-virtual {v1}, Lokhttp3/internal/connection/RealConnection;->socket()Ljava/net/Socket; move-result-object v1 invoke-static {v1}, Lokhttp3/internal/Util;->closeQuietly(Ljava/net/Socket;)V goto :goto_1 :cond_2 return-void :catchall_0 move-exception v0 :try_start_1 monitor-exit p0 :try_end_1 .catchall {:try_start_1 .. :try_end_1} :catchall_0 goto :goto_3 :goto_2 throw v0 :goto_3 goto :goto_2 .end method .method get(Lokhttp3/Address;Lokhttp3/internal/connection/StreamAllocation;Lokhttp3/Route;)Lokhttp3/internal/connection/RealConnection; .locals 3 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0}, Ljava/util/Deque;->iterator()Ljava/util/Iterator; move-result-object v0 :cond_0 invoke-interface {v0}, Ljava/util/Iterator;->hasNext()Z move-result v1 if-eqz v1, :cond_1 invoke-interface {v0}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v1 check-cast v1, Lokhttp3/internal/connection/RealConnection; invoke-virtual {v1, p1, p3}, Lokhttp3/internal/connection/RealConnection;->isEligible(Lokhttp3/Address;Lokhttp3/Route;)Z move-result v2 if-eqz v2, :cond_0 const/4 p1, 0x1 invoke-virtual {p2, v1, p1}, Lokhttp3/internal/connection/StreamAllocation;->acquire(Lokhttp3/internal/connection/RealConnection;Z)V return-object v1 :cond_1 const/4 p1, 0x0 return-object p1 .end method .method public declared-synchronized idleConnectionCount()I .locals 3 monitor-enter p0 const/4 v0, 0x0 :try_start_0 iget-object v1, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v1}, Ljava/util/Deque;->iterator()Ljava/util/Iterator; move-result-object v1 :cond_0 :goto_0 invoke-interface {v1}, Ljava/util/Iterator;->hasNext()Z move-result v2 if-eqz v2, :cond_1 invoke-interface {v1}, Ljava/util/Iterator;->next()Ljava/lang/Object; move-result-object v2 check-cast v2, Lokhttp3/internal/connection/RealConnection; iget-object v2, v2, Lokhttp3/internal/connection/RealConnection;->allocations:Ljava/util/List; invoke-interface {v2}, Ljava/util/List;->isEmpty()Z move-result v2 :try_end_0 .catchall {:try_start_0 .. :try_end_0} :catchall_0 if-eqz v2, :cond_0 add-int/lit8 v0, v0, 0x1 goto :goto_0 :cond_1 monitor-exit p0 return v0 :catchall_0 move-exception v0 monitor-exit p0 goto :goto_2 :goto_1 throw v0 :goto_2 goto :goto_1 .end method .method put(Lokhttp3/internal/connection/RealConnection;)V .locals 2 iget-boolean v0, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z if-nez v0, :cond_0 const/4 v0, 0x1 iput-boolean v0, p0, Lokhttp3/ConnectionPool;->cleanupRunning:Z sget-object v0, Lokhttp3/ConnectionPool;->executor:Ljava/util/concurrent/Executor; iget-object v1, p0, Lokhttp3/ConnectionPool;->cleanupRunnable:Ljava/lang/Runnable; invoke-interface {v0, v1}, Ljava/util/concurrent/Executor;->execute(Ljava/lang/Runnable;)V :cond_0 iget-object v0, p0, Lokhttp3/ConnectionPool;->connections:Ljava/util/Deque; invoke-interface {v0, p1}, Ljava/util/Deque;->add(Ljava/lang/Object;)Z return-void .end method