-
Notifications
You must be signed in to change notification settings - Fork 615
FIS error handling #911
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
FIS error handling #911
Changes from 29 commits
49708d2
a987647
1d9b1ca
28d0d85
126e372
c39cdb8
c21a59e
7a46ab0
314b3bb
715d427
bb322d0
1fd193b
e2d3631
e68e599
58c8efd
56d1eab
c8367dc
72e335d
560fba1
3ac3da2
d9e5c22
f57137c
1d51edf
0c0b9c2
0407614
2e7b881
615bdf4
dfa85e7
97b616c
31d441a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -218,12 +218,18 @@ private final void doRegistration() { | |
persistedInstallation.readPersistedInstallationEntryValue(); | ||
|
||
// New FID needs to be created | ||
if (persistedInstallationEntry.isErrored() || persistedInstallationEntry.isNotGenerated()) { | ||
if (persistedInstallationEntry.isNotGenerated()) { | ||
String fid = utils.createRandomFid(); | ||
persistFid(fid); | ||
persistedInstallationEntry = persistedInstallation.readPersistedInstallationEntryValue(); | ||
} | ||
|
||
if (persistedInstallationEntry.isErrored()) { | ||
throw new FirebaseInstallationsException( | ||
persistedInstallationEntry.getFisError(), | ||
FirebaseInstallationsException.Status.SDK_INTERNAL_ERROR); | ||
} | ||
|
||
triggerOnStateReached(persistedInstallationEntry); | ||
|
||
// FID needs to be registered | ||
|
@@ -262,6 +268,7 @@ private final void doRegistration() { | |
PersistedInstallationEntry errorInstallationEntry = | ||
persistedInstallationEntry | ||
.toBuilder() | ||
.setFisError(e.getMessage()) | ||
.setRegistrationStatus(RegistrationStatus.REGISTER_ERROR) | ||
.build(); | ||
persistedInstallation.insertOrUpdatePersistedInstallationEntry(errorInstallationEntry); | ||
|
@@ -296,15 +303,17 @@ private Void registerAndSaveFid(PersistedInstallationEntry persistedInstallation | |
/*fid= */ persistedInstallationEntry.getFirebaseInstallationId(), | ||
/*projectID= */ firebaseApp.getOptions().getProjectId(), | ||
/*appId= */ getApplicationId()); | ||
persistedInstallation.insertOrUpdatePersistedInstallationEntry( | ||
PersistedInstallationEntry.builder() | ||
.setFirebaseInstallationId(installationResponse.getFid()) | ||
.setRegistrationStatus(RegistrationStatus.REGISTERED) | ||
.setAuthToken(installationResponse.getAuthToken().getToken()) | ||
.setRefreshToken(installationResponse.getRefreshToken()) | ||
.setExpiresInSecs(installationResponse.getAuthToken().getTokenExpirationTimestamp()) | ||
.setTokenCreationEpochInSecs(creationTime) | ||
.build()); | ||
if (installationResponse.getFid() != null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fyi: What happens here if the field "fid" is not set? What state will the SDK end up in? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is to differentiate between 200, 5xx & 4xx errors. 200 - createInstallation successful response - fid is not empty There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If that is what you are doing, then I would recommend your code to express that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For that: I have to include Response Code as a field in InstallationResponse. Is that what you recommend? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. since y'all control both sides of this exchange we should be able to use and trust the status codes. imo having canonical status codes as a classification for installation responses is a good idea. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ack. PTAL. |
||
persistedInstallation.insertOrUpdatePersistedInstallationEntry( | ||
PersistedInstallationEntry.builder() | ||
.setFirebaseInstallationId(installationResponse.getFid()) | ||
.setRegistrationStatus(RegistrationStatus.REGISTERED) | ||
.setAuthToken(installationResponse.getAuthToken().getToken()) | ||
.setRefreshToken(installationResponse.getRefreshToken()) | ||
.setExpiresInSecs(installationResponse.getAuthToken().getTokenExpirationTimestamp()) | ||
.setTokenCreationEpochInSecs(creationTime) | ||
.build()); | ||
} | ||
|
||
} catch (FirebaseException exception) { | ||
throw new FirebaseInstallationsException( | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where does this test stub a 500 error?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the confusion. Added a comment & changed the test name. Does this makes sense?