Skip to content

Commit 14215c3

Browse files
committed
fix unnecessary threadpool-creation
New OkHttpClients came with their own thread and connection pools. With newBuilder() we can create a new client with an already existing pool. Fixes signalapp/Signal-Android#6283
1 parent 2154ae4 commit 14215c3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

java/src/main/java/org/whispersystems/signalservice/internal/push/PushServiceSocket.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@
7777
public class PushServiceSocket {
7878

7979
private static final String TAG = PushServiceSocket.class.getSimpleName();
80+
private static final OkHttpClient CLIENT = new OkHttpClient();
8081

8182
private static final String CREATE_ACCOUNT_SMS_PATH = "/v1/accounts/sms/code/%s";
8283
private static final String CREATE_ACCOUNT_VOICE_PATH = "/v1/accounts/voice/code/%s";
@@ -612,7 +613,7 @@ private Response getConnection(String urlFragment, String method, String body)
612613
SSLContext context = SSLContext.getInstance("TLS");
613614
context.init(null, trustManagers, null);
614615

615-
OkHttpClient.Builder okHttpClientBuilder = new OkHttpClient.Builder()
616+
OkHttpClient.Builder okHttpClientBuilder = CLIENT.newBuilder()
616617
.sslSocketFactory(context.getSocketFactory(), (X509TrustManager)trustManagers[0])
617618
.connectTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS)
618619
.readTimeout(soTimeoutMillis, TimeUnit.MILLISECONDS);

0 commit comments

Comments
 (0)