File tree Expand file tree Collapse file tree 3 files changed +29
-1
lines changed
main/java/com/google/firebase/internal
test/java/com/google/firebase/internal Expand file tree Collapse file tree 3 files changed +29
-1
lines changed Original file line number Diff line number Diff line change @@ -88,6 +88,10 @@ public static JsonFactory getDefaultJsonFactory() {
8888 }
8989
9090 public static HttpTransport getDefaultTransport () {
91- return new ApacheHttp2Transport ();
91+ return TransportInstanceHolder .INSTANCE ;
92+ }
93+
94+ private static class TransportInstanceHolder {
95+ static final HttpTransport INSTANCE = new ApacheHttp2Transport ();
9296 }
9397}
Original file line number Diff line number Diff line change @@ -292,6 +292,21 @@ public void testVerifyProxyIsRespected() {
292292 }
293293 }
294294
295+ @ Test
296+ public void testVerifyDefaultTransportReused () {
297+ FirebaseOptions o1 = FirebaseOptions .builder ()
298+ .setCredentials (MOCK_CREDENTIALS )
299+ .build ();
300+
301+ FirebaseOptions o2 = FirebaseOptions .builder ()
302+ .setCredentials (MOCK_CREDENTIALS )
303+ .build ();
304+
305+ HttpTransport t1 = o1 .getHttpTransport ();
306+ HttpTransport t2 = o2 .getHttpTransport ();
307+ assertEquals (t1 , t2 );
308+ }
309+
295310 private static ErrorHandlingHttpClient <FirebaseException > getHttpClient (boolean authorized ,
296311 FirebaseApp app ) {
297312 HttpRequestFactory requestFactory ;
Original file line number Diff line number Diff line change 2525import com .google .api .client .http .HttpRequest ;
2626import com .google .api .client .http .HttpRequestFactory ;
2727import com .google .api .client .http .HttpResponse ;
28+ import com .google .api .client .http .HttpTransport ;
2829import com .google .api .client .http .HttpUnsuccessfulResponseHandler ;
2930import com .google .api .client .testing .http .MockHttpTransport ;
3031import com .google .api .client .testing .http .MockLowLevelHttpResponse ;
@@ -128,4 +129,12 @@ public void disconnect() throws IOException {
128129
129130 assertTrue (lowLevelResponse .isDisconnected ());
130131 }
132+
133+ @ Test
134+ public void testVerifyDefaultTransportReused () {
135+ HttpTransport t1 = ApiClientUtils .getDefaultTransport ();
136+ HttpTransport t2 = ApiClientUtils .getDefaultTransport ();
137+ assertEquals (t1 , t2 );
138+ }
139+
131140}
You can’t perform that action at this time.
0 commit comments