File: ProtoFieldPreconditionsCheckNotNull.md

package info (click to toggle)
error-prone-java 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 15,076 kB
  • sloc: java: 171,398; xml: 1,459; sh: 34; makefile: 7
file content (8 lines) | stat: -rw-r--r-- 466 bytes parent folder | download
1
2
3
4
5
6
7
8
This checker looks for comparisons of protocol buffer fields with null via the
com.google.common.base.Preconditions.checkNotNull method. If a proto field is
not specified, its field accessor will return a non-null default value. Thus,
the result of calling one of these accessors can never be null, and comparisons
like these often indicate a nearby error.

If you meant to check whether an optional field has been set, you should use the
hasField() method instead.