@@ -58,8 +58,6 @@ public class HttpAccess {
5858
5959 private String userAgent ;
6060 private OkHttpClient okHttpClient ;
61- private OkHttpClient .Builder okHttpBuilder ;
62- private OkHttpClient .Builder unauthenticatedOkHttpBuilder ;
6361
6462 // Connection manager.
6563 private final ConnectivityManager conMgr ;
@@ -102,24 +100,26 @@ public HttpAccess(Context app, String userAgent) {
102100 * and user agent interceptor for an authenticated client.
103101 */
104102 public OkHttpClient .Builder getOkHttpClientBuilder () {
105- if (okHttpBuilder == null ) {
106- okHttpBuilder = createNewClientBuilder ();
107- }
108-
109- return okHttpBuilder ;
103+ ConnectionSpec connectionSpec = new ConnectionSpec .Builder (ConnectionSpec .MODERN_TLS )
104+ .tlsVersions (TlsVersion .TLS_1_1 , TlsVersion .TLS_1_2 )
105+ .build ();
106+ return new OkHttpClient .Builder ()
107+ .connectionSpecs (Collections .singletonList (connectionSpec ))
108+ .connectTimeout (CONNECT_TIMEOUT , TimeUnit .SECONDS )
109+ .readTimeout (READ_TIMEOUT , TimeUnit .SECONDS )
110+ .addNetworkInterceptor (new UserAgentInterceptor ());
110111 }
111112
112113 /**
113114 *
114115 * @return okHttpClient.Builder with appropriate connection spec
115116 * and user agent interceptor for an unauthenticated client.
117+ *
118+ * @deprecated To be removed in 14.0. Please use {{@link #getOkHttpClientBuilder()}} instead.
116119 */
120+ @ Deprecated
117121 public OkHttpClient .Builder getUnauthenticatedOkHttpBuilder () {
118- if (unauthenticatedOkHttpBuilder == null ) {
119- unauthenticatedOkHttpBuilder = createNewClientBuilder ();
120- }
121-
122- return unauthenticatedOkHttpBuilder ;
122+ return getOkHttpClientBuilder ();
123123 }
124124
125125 /**
@@ -158,17 +158,6 @@ public String getUserAgent() {
158158 return userAgent ;
159159 }
160160
161- private OkHttpClient .Builder createNewClientBuilder () {
162- ConnectionSpec connectionSpec = new ConnectionSpec .Builder (ConnectionSpec .MODERN_TLS )
163- .tlsVersions (TlsVersion .TLS_1_1 , TlsVersion .TLS_1_2 )
164- .build ();
165- return new OkHttpClient .Builder ()
166- .connectionSpecs (Collections .singletonList (connectionSpec ))
167- .connectTimeout (CONNECT_TIMEOUT , TimeUnit .SECONDS )
168- .readTimeout (READ_TIMEOUT , TimeUnit .SECONDS )
169- .addNetworkInterceptor (new UserAgentInterceptor ());
170- }
171-
172161 /**
173162 * Exception thrown if the device is offline, during an attempted HTTP call.
174163 */
0 commit comments