rules_java icon indicating copy to clipboard operation
rules_java copied to clipboard

Fix downstream failures due to new error prone checks

Open hvadehra opened this issue 3 years ago • 7 comments

New error prone checks since the last java_tools release now break bazel and other downstream projects (https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/2430) This is currently blocking a java_tools release (https://github.com/bazelbuild/java_tools/issues/55).

I plan to disable the checks for now (as done before in https://github.com/bazelbuild/bazel/commit/cf573455e8205a2b79629df1b5eb4e3b9efabec1) on the default java toolchain and proceed with the release.

Filing this issue to track fixing of downstream and then re-enable the checks.

cc @comius

hvadehra avatar Apr 12 '22 12:04 hvadehra

Disabling globally to make progress is OK with me.

These are the distinct errors I saw, which could be fixed more locally. Did you see others?

api/src/test/java/com/google/common/flogger/LogContextTest.java:418: error: [FloggerLogString] Arguments to log(String) must be compile-time constants or parameters annotated with @CompileTimeConstant. If possible, use Flogger's formatting log methods instead.
--
  | logger.atInfo().log(nullString);
  | ^
external/desugar_jdk_libs/src/share/classes/java/util/stream/Collectors.java:630: error: [ReturnValueIgnored] Return value of 'sumWithCompensation' must be used
--
  | (a, t) -> { sumWithCompensation(a, mapper.applyAsDouble(t)); a[2]++; a[3]+= mapper.applyAsDouble(t);},
  | ^

cushon avatar Apr 12 '22 15:04 cushon

The Flogger test needs to be updated. It's been fixed internally (423382085) but for some reason has not been exported to github yet (probably waiting for an error prone release) The latter desugar lib failure is the one I'm attempting to fix with the global disable of ReturnValueIgnored (afaict flags allowing more fine-grained disabling have been removed) These are the only failures related to error prone.

hvadehra avatar Apr 12 '22 15:04 hvadehra

The original flogger fix was made internal only, I just mailed cl/441196089

For desugar I think you could also add the flag to the javacopts for the affected target, but disabling it globally to unblock the release is still fine with me

cushon avatar Apr 12 '22 15:04 cushon

Got it, I'll mail a change to update it locally at desugar as a followup.

hvadehra avatar Apr 12 '22 15:04 hvadehra

Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team (@bazelbuild/triage) if you think this issue is still relevant or you are interested in getting the issue resolved.

github-actions[bot] avatar Jun 17 '23 01:06 github-actions[bot]

@cushon @hvadehra @ReturnValueIgnored (and @CheckReturnValues as an alias) is disabled in rules_java https://github.com/bazelbuild/rules_java/blob/ea611cfc6951dd734e2acfd56bd6338490101ef1/toolchains/default_java_toolchain.bzl#L63 and leaking to projects that using Bazel. Which results in those inspections disabled as well via DEFAULT_JAVACOPTS.

dkashyn-sfdc avatar Mar 28 '25 00:03 dkashyn-sfdc

Reopened, and transferring to rules_java to track dropping these in the next major version release.

hvadehra avatar Mar 28 '25 09:03 hvadehra