Skip to content

Enforce NullAway for Guava packages#1570

Merged
bulldozer-bot[bot] merged 4 commits intodevelopfrom
ds/guava-nullaway
Sep 15, 2022
Merged

Enforce NullAway for Guava packages#1570
bulldozer-bot[bot] merged 4 commits intodevelopfrom
ds/guava-nullaway

Conversation

@schlosna
Copy link
Copy Markdown
Contributor

@schlosna schlosna commented Sep 15, 2022

Before this PR

NullAway was not checking Guava com.google.common annotated packages. When enabling as a test for palantir/gradle-baseline#2382 it flagged one likely false positive that we can check.

> Task :tritium-processor:compileJava
/home/circleci/project/tritium-processor/src/main/java/com/palantir/tritium/processor/Methods.java:78: error: [NullAway] unboxing of a @Nullable value
                methodFieldName = originalMethodFieldName + i;
                                  ^
    (see http://t.uber.com/nullaway )
1 error

After this PR

==COMMIT_MSG==
Enforce NullAway for Guava packages
==COMMIT_MSG==

Possible downsides?

@changelog-app
Copy link
Copy Markdown

changelog-app Bot commented Sep 15, 2022

Generate changelog in changelog/@unreleased

Type

  • Feature
  • Improvement
  • Fix
  • Break
  • Deprecation
  • Manual task
  • Migration

Description

Enforce NullAway for Guava packages

Check the box to generate changelog(s)

  • Generate changelog entry

Comment on lines +69 to +72
String methodName = method.element().getSimpleName().toString();
String originalMethodFieldName = CaseFormat.LOWER_CAMEL
String originalMethodFieldName = Strings.nullToEmpty(CaseFormat.LOWER_CAMEL
.converterTo(CaseFormat.UPPER_UNDERSCORE)
.convert(methodName);
.convert(methodName));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

methodName shouldn't ever be null, so I'm not sure exactly why this flags as possibly null. Going to switch this to a checkNotNull to enforce that

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the intent is that convert input is nullable, and the outputs nullability matches the input, but the annotations don't have a clear way to express that

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I was just a little surprised compiler couldn't verify this was always non-null as it flowed through. There's some interesting bits in Converter and com.google.common.base.NullnessCasts#uncheckedCastNullableTToT

@bulldozer-bot bulldozer-bot Bot merged commit 4b8e6e3 into develop Sep 15, 2022
@bulldozer-bot bulldozer-bot Bot deleted the ds/guava-nullaway branch September 15, 2022 13:46
@svc-autorelease
Copy link
Copy Markdown
Collaborator

Released 0.53.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants