Skip to content

Commit 1d09152

Browse files
committed
Propagate exceptions to the caller if Fis getToken call fails with an
exception.
1 parent 690d119 commit 1d09152

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
@@ -306,12 +306,12 @@ private void triggerOnStateReached(PersistedInstallationEntry persistedInstallat
306306
}
307307
}
308308

309-
private void triggerOnException(PersistedInstallationEntry prefs, Exception exception) {
309+
private void triggerOnException(Exception exception) {
310310
synchronized (lock) {
311311
Iterator<StateListener> it = listeners.iterator();
312312
while (it.hasNext()) {
313313
StateListener l = it.next();
314-
boolean doneListening = l.onException(prefs, exception);
314+
boolean doneListening = l.onException(exception);
315315
if (doneListening) {
316316
it.remove();
317317
}
@@ -367,7 +367,7 @@ private void doNetworkCallIfNecessary(boolean forceRefresh) {
367367
return;
368368
}
369369
} catch (FirebaseInstallationsException e) {
370-
triggerOnException(prefs, e);
370+
triggerOnException(e);
371371
return;
372372
}
373373

@@ -381,11 +381,11 @@ private void doNetworkCallIfNecessary(boolean forceRefresh) {
381381

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

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)