google / error-prone

Catch common Java mistakes as compile-time errors
https://errorprone.info
Apache License 2.0
6.86k stars 744 forks source link

False positive CheckReturnValue triggered on Java 9, on Bazel #850

Closed davido closed 6 years ago

davido commented 6 years ago

As reported here: https://github.com/google/auto/issues/560, trying to build Gerrit Code Review with this Bazel patch: https://github.com/hhclam/bazel/commit/64212c8026df9fc6361d5af8414acc373e221955, is failing with:

ERROR: /home/davido/projects/gerrit2/java/com/google/gerrit/common/BUILD:32:1: Building java/com/google/gerrit/common/libserver.jar (57 source files) failed (Exit 1)
java/com/google/gerrit/common/RawInputUtil.java:34: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
    Preconditions.checkNotNull(bytes);
                              ^
    (see http://errorprone.info/bugpattern/CheckReturnValue)
  Did you mean to remove this line?
[...]
ERROR: /home/davido/projects/gerrit2/java/com/google/gerrit/util/cli/BUILD:1:1: Building java/com/google/gerrit/util/cli/libcli.jar (6 source files) failed (Exit 1)
java/com/google/gerrit/util/cli/CmdLineParser.java:229: error: [CheckReturnValue] Ignored return value of method that is annotated with @CheckReturnValue
        map.put(ent.getKey(), val);
               ^
    (see http://errorprone.info/bugpattern/CheckReturnValue)
  Did you mean to remove this line?
Target //java/com/google/gerrit/server:server failed to build

No issue reported on the same code, on Java 8, though.

cushon commented 6 years ago

The copy of Error Prone distributed with Bazel hasn't been updated since initial Java 9 support was added: https://bazel-review.googlesource.com/c/bazel/+/25631