Skip to content

Commit 51c995e

Browse files
authored
Propagate exceptions to the caller if Fis getToken call fails with an (#2035)
exception.
1 parent 9a8cd2c commit 51c995e

File tree

4 files changed

+10
-17
lines changed

4 files changed

+10
-17
lines changed

firebase-installations/src/main/java/com/google/firebase/installations/FirebaseInstallations.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,12 @@ private void triggerOnStateReached(PersistedInstallationEntry persistedInstallat
305305
}
306306
}
307307

308-
private void triggerOnException(PersistedInstallationEntry prefs, Exception exception) {
308+
private void triggerOnException(Exception exception) {
309309
synchronized (lock) {
310310
Iterator<StateListener> it = listeners.iterator();
311311
while (it.hasNext()) {
312312
StateListener l = it.next();
313-
boolean doneListening = l.onException(prefs, exception);
313+
boolean doneListening = l.onException(exception);
314314
if (doneListening) {
315315
it.remove();
316316
}
@@ -366,7 +366,7 @@ private void doNetworkCallIfNecessary(boolean forceRefresh) {
366366
return;
367367
}
368368
} catch (FirebaseInstallationsException e) {
369-
triggerOnException(prefs, e);
369+
triggerOnException(e);
370370
return;
371371
}
372372

@@ -380,11 +380,11 @@ private void doNetworkCallIfNecessary(boolean forceRefresh) {
380380

381381
// Let the caller know about the result.
382382
if (prefs.isErrored()) {
383-
triggerOnException(prefs, new FirebaseInstallationsException(Status.BAD_CONFIG));
383+
triggerOnException(new FirebaseInstallationsException(Status.BAD_CONFIG));
384384
} else if (prefs.isNotGenerated()) {
385385
// If there is no fid it means the call failed with an auth error. Simulate an
386386
// IOException so that the caller knows to try again.
387-
triggerOnException(prefs, new IOException(AUTH_ERROR_MSG));
387+
triggerOnException(new IOException(AUTH_ERROR_MSG));
388388
} else {
389389
triggerOnStateReached(prefs);
390390
}

firebase-installations/src/main/java/com/google/firebase/installations/GetAuthTokenListener.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,8 @@ public boolean onStateReached(PersistedInstallationEntry persistedInstallationEn
4444
}
4545

4646
@Override
47-
public boolean onException(
48-
PersistedInstallationEntry persistedInstallationEntry, Exception exception) {
49-
if (persistedInstallationEntry.isErrored()
50-
|| persistedInstallationEntry.isNotGenerated()
51-
|| persistedInstallationEntry.isUnregistered()) {
52-
resultTaskCompletionSource.trySetException(exception);
53-
return true;
54-
}
55-
return false;
47+
public boolean onException(Exception exception) {
48+
resultTaskCompletionSource.trySetException(exception);
49+
return true;
5650
}
5751
}

firebase-installations/src/main/java/com/google/firebase/installations/GetIdListener.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public boolean onStateReached(PersistedInstallationEntry persistedInstallationEn
4242
}
4343

4444
@Override
45-
public boolean onException(
46-
PersistedInstallationEntry persistedInstallationEntry, Exception exception) {
45+
public boolean onException(Exception exception) {
4746
return false;
4847
}
4948
}

firebase-installations/src/main/java/com/google/firebase/installations/StateListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,5 +27,5 @@ interface StateListener {
2727
* Returns {@code true} if an exception is thrown while registering a Firebase Installation,
2828
* {@code false} otherwise.
2929
*/
30-
boolean onException(PersistedInstallationEntry persistedInstallationEntry, Exception exception);
30+
boolean onException(Exception exception);
3131
}

0 commit comments

Comments
 (0)