Skip to content

Implementing retry once for FIS Client. #895

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Oct 14, 2019
19 changes: 3 additions & 16 deletions firebase-installations/api.txt
Original file line number Diff line number Diff line change
Expand Up @@ -72,22 +72,9 @@ package com.google.firebase.installations.remote {

public class FirebaseInstallationServiceClient {
ctor public FirebaseInstallationServiceClient(@NonNull Context);
method @NonNull public com.google.firebase.installations.remote.InstallationResponse createFirebaseInstallation(@NonNull String, @NonNull String, @NonNull String, @NonNull String) throws com.google.firebase.installations.remote.FirebaseInstallationServiceException;
method @NonNull public void deleteFirebaseInstallation(@NonNull String, @NonNull String, @NonNull String, @NonNull String) throws com.google.firebase.installations.remote.FirebaseInstallationServiceException;
method @NonNull public InstallationTokenResult generateAuthToken(@NonNull String, @NonNull String, @NonNull String, @NonNull String) throws com.google.firebase.installations.remote.FirebaseInstallationServiceException;
}

public class FirebaseInstallationServiceException {
ctor public FirebaseInstallationServiceException(@NonNull com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status);
ctor public FirebaseInstallationServiceException(@NonNull String, @NonNull com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status);
ctor public FirebaseInstallationServiceException(@NonNull String, @NonNull com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status, @NonNull Throwable);
method @NonNull public com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status getStatus();
}

public enum FirebaseInstallationServiceException.Status {
enum_constant public static final com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status NETWORK_ERROR;
enum_constant public static final com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status SERVER_ERROR;
enum_constant public static final com.google.firebase.installations.remote.FirebaseInstallationServiceException.Status UNAUTHORIZED;
method @NonNull public com.google.firebase.installations.remote.InstallationResponse createFirebaseInstallation(@NonNull String, @NonNull String, @NonNull String, @NonNull String);
method @NonNull public void deleteFirebaseInstallation(@NonNull String, @NonNull String, @NonNull String, @NonNull String);
method @NonNull public InstallationTokenResult generateAuthToken(@NonNull String, @NonNull String, @NonNull String, @NonNull String);
}

public abstract class InstallationResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@
import com.google.android.gms.tasks.Task;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseException;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.installations.local.PersistedInstallation;
import com.google.firebase.installations.local.PersistedInstallation.RegistrationStatus;
import com.google.firebase.installations.local.PersistedInstallationEntry;
import com.google.firebase.installations.remote.FirebaseInstallationServiceClient;
import com.google.firebase.installations.remote.FirebaseInstallationServiceException;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.LinkedBlockingQueue;
Expand Down Expand Up @@ -139,7 +139,7 @@ public class FirebaseInstallationsInstrumentedTest {
.build();

@Before
public void setUp() throws FirebaseInstallationServiceException {
public void setUp() throws FirebaseException {
MockitoAnnotations.initMocks(this);
FirebaseApp.clearInstancesForTest();
executor = new ThreadPoolExecutor(0, 1, 30L, TimeUnit.SECONDS, new LinkedBlockingQueue<>());
Expand Down Expand Up @@ -168,9 +168,7 @@ public void setUp() throws FirebaseInstallationServiceException {

when(backendClientReturnsError.createFirebaseInstallation(
anyString(), anyString(), anyString(), anyString()))
.thenThrow(
new FirebaseInstallationServiceException(
"SDK Error", FirebaseInstallationServiceException.Status.SERVER_ERROR));
.thenThrow(new FirebaseException("SDK Error"));

when(mockUtils.createRandomFid()).thenReturn(TEST_FID_1);
when(mockUtils.currentTimeInSecs()).thenReturn(TEST_CREATION_TIMESTAMP_2);
Expand All @@ -180,9 +178,7 @@ public void setUp() throws FirebaseInstallationServiceException {
.when(backendClientReturnsOk)
.deleteFirebaseInstallation(anyString(), anyString(), anyString(), anyString());
// Mocks server error on FIS deletion
doThrow(
new FirebaseInstallationServiceException(
"Server Error", FirebaseInstallationServiceException.Status.SERVER_ERROR))
doThrow(new FirebaseException("Server Error"))
.when(backendClientReturnsError)
.deleteFirebaseInstallation(anyString(), anyString(), anyString(), anyString());
}
Expand Down Expand Up @@ -524,9 +520,7 @@ public void testGetAuthToken_serverError_failure() throws Exception {
.thenReturn(REGISTERED_INSTALLATION_ENTRY);
when(backendClientReturnsError.generateAuthToken(
anyString(), anyString(), anyString(), anyString()))
.thenThrow(
new FirebaseInstallationServiceException(
"Server Error", FirebaseInstallationServiceException.Status.SERVER_ERROR));
.thenThrow(new FirebaseException("Server Error"));
when(mockUtils.isAuthTokenExpired(REGISTERED_INSTALLATION_ENTRY)).thenReturn(false);

FirebaseInstallations firebaseInstallations =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import com.google.android.gms.tasks.TaskCompletionSource;
import com.google.android.gms.tasks.Tasks;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseException;
import com.google.firebase.installations.local.PersistedInstallation;
import com.google.firebase.installations.local.PersistedInstallation.RegistrationStatus;
import com.google.firebase.installations.local.PersistedInstallationEntry;
import com.google.firebase.installations.remote.FirebaseInstallationServiceClient;
import com.google.firebase.installations.remote.FirebaseInstallationServiceException;
import com.google.firebase.installations.remote.InstallationResponse;
import java.util.ArrayList;
import java.util.Iterator;
Expand Down Expand Up @@ -306,7 +306,7 @@ private Void registerAndSaveFid(PersistedInstallationEntry persistedInstallation
.setTokenCreationEpochInSecs(creationTime)
.build());

} catch (FirebaseInstallationServiceException exception) {
} catch (FirebaseException exception) {
throw new FirebaseInstallationsException(
exception.getMessage(), FirebaseInstallationsException.Status.SDK_INTERNAL_ERROR);
}
Expand Down Expand Up @@ -336,7 +336,7 @@ private InstallationTokenResult fetchAuthTokenFromServer(
.build());

return tokenResult;
} catch (FirebaseInstallationServiceException exception) {
} catch (FirebaseException exception) {
throw new FirebaseInstallationsException(
"Failed to generate auth token for a Firebase Installation.",
FirebaseInstallationsException.Status.SDK_INTERNAL_ERROR);
Expand All @@ -361,7 +361,7 @@ private Void deleteFirebaseInstallationId() throws FirebaseInstallationsExceptio
firebaseApp.getOptions().getProjectId(),
persistedInstallationEntry.getRefreshToken());

} catch (FirebaseInstallationServiceException exception) {
} catch (FirebaseException exception) {
throw new FirebaseInstallationsException(
"Failed to delete a Firebase Installation.",
FirebaseInstallationsException.Status.SDK_INTERNAL_ERROR);
Expand Down
Loading