Skip to content

Null field value is treated inconsistently in DocumentSnapshot get{Type} methods (return null vs throw NPE) #491

@AndrewJudson

Description

@AndrewJudson

Compare
https://github.com/googleapis/java-firestore/blob/master/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java#L336

with

https://github.com/googleapis/java-firestore/blob/master/google-cloud-firestore/src/main/java/com/google/cloud/firestore/DocumentSnapshot.java#L348

In the first example, if the field does not exist or is null, you return null. In the second case, you throw an NPE. This is confusing when the behavior is not consistent between different field types, and it is incorrect to label the methods that throw an NPE as Nullable, as they will never return null.

Metadata

Metadata

Labels

api: firestoreIssues related to the googleapis/java-firestore API.type: questionRequest for information or clarification. Not an issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions