Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't opt in to CheckOptionalEmptiness #2396

Merged
merged 2 commits into from
Sep 20, 2022

Conversation

iamdanfox
Copy link
Contributor

@iamdanfox iamdanfox commented Sep 20, 2022

Before this PR

When compiling with java 17 and NullAway 0.10.1 internally (https://internal-github/adjudication-service/pull/4216) I have been getting a NPE from inside NullAway, which looks super weird to me because it implies that Java's Element.getKind() method returned null (but I literally can't see what subtype would return null)

error: An unhandled exception was thrown by the Error Prone static analysis plugin.
                .map(Map.Entry::getKey)
                     ^
     Please report this at https://github.com/google/error-prone/issues/new and include the following:
  
     error-prone version: 2.15.0
     BugPattern: NullAway
     Stack Trace:
     java.lang.NullPointerException: Cannot invoke "javax.lang.model.element.ElementKind.equals(Object)" because the return value of "javax.lang.model.element.Element.getKind()" is null
  	at com.uber.nullaway.handlers.StreamNullabilityPropagator.onMatchMethodReference(StreamNullabilityPropagator.java:351)
  	at com.uber.nullaway.handlers.CompositeHandler.onMatchMethodReference(CompositeHandler.java:103)
  	at com.uber.nullaway.NullAway.matchMemberReference(NullAway.java:854)
  	at com.google.errorprone.scanner.ErrorProneScanner.processMatchers(ErrorProneScanner.java:449)
  	at com.google.errorprone.scanner.ErrorProneScanner.visitMemberReference(ErrorProneScanner.java:715)

After this PR

==COMMIT_MSG==
com.palantir.baseline-null-away no longer enables the CheckOptionalEmptiness checker by default.
==COMMIT_MSG==

You can still enable this if you want to with something like

    plugins.withId('com.palantir.baseline-error-prone', {
        tasks.withType(JavaCompile) {
            options.errorprone.errorproneArgs.add '-XepOpt:NullAway:CheckOptionalEmptiness=true'
        }
    })

Possible downsides?

  • folks who were enjoying the reassurance of this strict optional checking now have a bit of static analysis taken away :(

@changelog-app
Copy link

changelog-app bot commented Sep 20, 2022

Generate changelog in changelog/@unreleased

Type

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

Description

com.palantir.baseline-null-away no longer enables the CheckOptionalEmptiness checker by default.

Check the box to generate changelog(s)

  • Generate changelog entry

@iamdanfox iamdanfox changed the title Dont opt in to CheckOptionalEmptiness Don't opt in to CheckOptionalEmptiness Sep 20, 2022
@bulldozer-bot bulldozer-bot bot merged commit 2a915c8 into develop Sep 20, 2022
@bulldozer-bot bulldozer-bot bot deleted the dfox/less-strict-nullaway branch September 20, 2022 16:18
@svc-autorelease
Copy link
Collaborator

Released 4.171.0

This was referenced Sep 20, 2022
bulldozer-bot bot pushed a commit to palantir/witchcraft-api that referenced this pull request Sep 20, 2022
###### _excavator_ is a bot for automating changes across repositories.

Changes produced by the roomba/latest-baseline-oss check.

# Release Notes
## 4.171.0
| Type | Description | Link |
| ---- | ----------- | ---- |
| Fix | `com.palantir.baseline-null-away` no longer enables the `CheckOptionalEmptiness` checker by default. | palantir/gradle-baseline#2396 |


## 4.172.0
_Automated release, no documented user facing changes_


To enable or disable this check, please contact the maintainers of Excavator.
This was referenced Sep 20, 2022
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