Skip to content

Commit a41b07e

Browse files
fix: don't throw NPE in DocumentSnapshot.getDate() when value is missing (#513)
1 parent d3ff673 commit a41b07e

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,8 @@ public Long getLong(@Nonnull String field) {
345345
*/
346346
@Nullable
347347
public Date getDate(@Nonnull String field) {
348-
return ((Timestamp) get(field)).toDate();
348+
Timestamp timestamp = getTimestamp(field);
349+
return timestamp == null ? null : timestamp.toDate();
349350
}
350351

351352
/**

0 commit comments

Comments
 (0)