Skip to content

Commit 9eb88b1

Browse files
authored
Log the available Firebase options along with the error stream. (#1537)
* Dropping guava and appcompat dependency from FIS SDK. * Fix OverlappingFileLockException. Access the data shared by multiple threads only after acquiring cross-process and multi-thread safe locks. * Log the available Firebase options along with the error stream. * Cleanup diff PR changes * Minor fix. * Using Textutils. * Addressing Rayo's comments. * Fix string format.
1 parent 973c911 commit 9eb88b1

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

firebase-installations/src/main/java/com/google/firebase/installations/remote/FirebaseInstallationServiceClient.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public InstallationResponse createFirebaseInstallation(
165165
return readCreateResponse(httpURLConnection);
166166
}
167167

168-
logFisCommunicationError(httpURLConnection);
168+
logFisCommunicationError(httpURLConnection, appId, apiKey, projectID);
169169

170170
if (httpResponseCode == 429 || (httpResponseCode >= 500 && httpResponseCode < 600)) {
171171
retryCount++;
@@ -307,7 +307,7 @@ public void deleteFirebaseInstallation(
307307
return;
308308
}
309309

310-
logFisCommunicationError(httpURLConnection);
310+
logFisCommunicationError(httpURLConnection, null, apiKey, projectID);
311311

312312
if (httpResponseCode == 429 || (httpResponseCode >= 500 && httpResponseCode < 600)) {
313313
retryCount++;
@@ -374,7 +374,7 @@ public TokenResult generateAuthToken(
374374
return readGenerateAuthTokenResponse(httpURLConnection);
375375
}
376376

377-
logFisCommunicationError(httpURLConnection);
377+
logFisCommunicationError(httpURLConnection, null, apiKey, projectID);
378378

379379
if (httpResponseCode == 401 || httpResponseCode == 404) {
380380
return TokenResult.builder().setResponseCode(TokenResult.ResponseCode.AUTH_ERROR).build();
@@ -522,13 +522,25 @@ static long parseTokenExpirationTimestamp(String expiresIn) {
522522
: Long.parseLong(expiresIn.substring(0, expiresIn.length() - 1));
523523
}
524524

525-
private static void logFisCommunicationError(HttpURLConnection conn) {
525+
private static void logFisCommunicationError(
526+
HttpURLConnection conn,
527+
@Nullable String appId,
528+
@NonNull String apiKey,
529+
@NonNull String projectId) {
526530
String logString = readErrorResponse(conn);
527531
if (!TextUtils.isEmpty(logString)) {
528532
Log.w(FIS_TAG, logString);
533+
Log.w(FIS_TAG, availableFirebaseOptions(appId, apiKey, projectId));
529534
}
530535
}
531536

537+
private static String availableFirebaseOptions(
538+
@Nullable String appId, @NonNull String apiKey, @NonNull String projectId) {
539+
return String.format(
540+
"Firebase options used while communicating with Firebase server APIs: %s, %s%s",
541+
apiKey, projectId, TextUtils.isEmpty(appId) ? "" : ", " + appId);
542+
}
543+
532544
// Read the error message from the response.
533545
@Nullable
534546
private static String readErrorResponse(HttpURLConnection conn) {

0 commit comments

Comments
 (0)