Skip to content

Fixing NPE and correcting corresponding annotations. #1714

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 2 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,8 @@ private PersistedInstallationEntry registerFidWithServer(PersistedInstallationEn
// Note: Default value of instanceIdMigrationAuth: null
String iidToken = null;

if (prefs.getFirebaseInstallationId().length() == 11) {
if (prefs.getFirebaseInstallationId() != null
&& prefs.getFirebaseInstallationId().length() == 11) {
// For a default firebase installation, read the stored star scoped iid token. This token
// will be used for authenticating Instance-ID when migrating to FIS.
iidToken = iidStore.readToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public FirebaseInstallationServiceClient(
@NonNull
public InstallationResponse createFirebaseInstallation(
@NonNull String apiKey,
@NonNull String fid,
@Nullable String fid,
@NonNull String projectID,
@NonNull String appId,
@Nullable String iidToken)
Expand Down Expand Up @@ -186,7 +186,7 @@ public InstallationResponse createFirebaseInstallation(
}

private void writeFIDCreateRequestBodyToOutputStream(
HttpURLConnection httpURLConnection, @NonNull String fid, @NonNull String appId)
HttpURLConnection httpURLConnection, @Nullable String fid, @NonNull String appId)
throws IOException {
writeRequestBodyToOutputStream(
httpURLConnection, getJsonBytes(buildCreateFirebaseInstallationRequestBody(fid, appId)));
Expand Down Expand Up @@ -231,7 +231,8 @@ private static void writeRequestBodyToOutputStream(URLConnection urlConnection,
* @throws IllegalStateException If {@link JSONException} is thrown due to non-null names while
* {@link JSONObject} creation.
*/
private static JSONObject buildCreateFirebaseInstallationRequestBody(String fid, String appId) {
private static JSONObject buildCreateFirebaseInstallationRequestBody(
@Nullable String fid, @NonNull String appId) {
try {
JSONObject firebaseInstallationData = new JSONObject();
firebaseInstallationData.put("fid", fid);
Expand Down