File tree 2 files changed +16
-1
lines changed
main/java/com/google/firebase/cloud
test/java/com/google/firebase/cloud
2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -79,7 +79,8 @@ public static Firestore getFirestore() {
79
79
*/
80
80
@ NonNull
81
81
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 ());
83
84
}
84
85
85
86
/**
Original file line number Diff line number Diff line change @@ -79,6 +79,20 @@ public void testServiceAccountProjectId() throws IOException {
79
79
assertNotSame (firestore1 , firestore2 );
80
80
}
81
81
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
+
82
96
@ Test
83
97
public void testFirestoreOptions () throws IOException {
84
98
final String databaseId = "databaseIdInTestFirestoreOptions" ;
You can’t perform that action at this time.
0 commit comments