Skip to content

Commit e28ca2e

Browse files
authored
Fix MultiDB Regression (#735)
1 parent 1eec932 commit e28ca2e

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

Diff for: src/main/java/com/google/firebase/cloud/FirestoreClient.java

+2-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,8 @@ public static Firestore getFirestore() {
7979
*/
8080
@NonNull
8181
public static Firestore getFirestore(FirebaseApp app) {
82-
return getFirestore(app, ImplFirebaseTrampolines.getFirestoreOptions(app).getDatabaseId());
82+
final FirestoreOptions firestoreOptions = ImplFirebaseTrampolines.getFirestoreOptions(app);
83+
return getFirestore(app, firestoreOptions == null ? null : firestoreOptions.getDatabaseId());
8384
}
8485

8586
/**

Diff for: src/test/java/com/google/firebase/cloud/FirestoreClientTest.java

+14
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ public void testServiceAccountProjectId() throws IOException {
7979
assertNotSame(firestore1, firestore2);
8080
}
8181

82+
@Test
83+
public void testAbsentFirestoreOptions() throws Exception {
84+
String projectId = "test-proj";
85+
FirebaseOptions options = FirebaseOptions.builder()
86+
.setCredentials(GoogleCredentials.fromStream(ServiceAccount.EDITOR.asStream()))
87+
.setProjectId(projectId)
88+
.build();
89+
90+
FirebaseApp.initializeApp(options);
91+
Firestore firestore = FirestoreClient.getFirestore();
92+
assertEquals(projectId, firestore.getOptions().getProjectId());
93+
assertEquals("(default)", firestore.getOptions().getDatabaseId());
94+
}
95+
8296
@Test
8397
public void testFirestoreOptions() throws IOException {
8498
final String databaseId = "databaseIdInTestFirestoreOptions";

0 commit comments

Comments
 (0)