Skip to content

Commit 55742a8

Browse files
committed
Update status code check and initialize response code to 0
1 parent 59be1eb commit 55742a8

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

firebase-config/src/main/java/com/google/firebase/remoteconfig/internal/ConfigRealtimeHttpClient.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,7 @@ private boolean isStatusCodeRetryable(int statusCode) {
313313
|| statusCode == HTTP_TOO_MANY_REQUESTS
314314
|| statusCode == HttpURLConnection.HTTP_BAD_GATEWAY
315315
|| statusCode == HttpURLConnection.HTTP_UNAVAILABLE
316-
|| statusCode == HttpURLConnection.HTTP_GATEWAY_TIMEOUT
317-
|| statusCode == HttpURLConnection.HTTP_OK;
316+
|| statusCode == HttpURLConnection.HTTP_GATEWAY_TIMEOUT;
318317
}
319318

320319
/**
@@ -330,7 +329,7 @@ public synchronized void beginRealtimeHttpStream() {
330329
return;
331330
}
332331

333-
int responseCode = 200;
332+
int responseCode = 0;
334333
try {
335334
// Create the open the connection.
336335
httpURLConnection = createRealtimeConnection();
@@ -349,7 +348,11 @@ public synchronized void beginRealtimeHttpStream() {
349348
Log.d(TAG, "Exception connecting to realtime stream. Retrying the connection...");
350349
} finally {
351350
closeRealtimeHttpStream();
352-
if (isStatusCodeRetryable(responseCode)) {
351+
352+
// If responseCode is 0 then no connection was made to server and the SDK should still retry.
353+
if (responseCode == 0
354+
|| responseCode == HttpURLConnection.HTTP_OK
355+
|| isStatusCodeRetryable(responseCode)) {
353356
retryHTTPConnection();
354357
} else {
355358
propagateErrors(

0 commit comments

Comments
 (0)