Skip to content

Possible bug in the data flow analysis? #1060

@mauricioaniche

Description

@mauricioaniche

All, we faced the following NullAway error: [NullAway] unboxing of a @Nullable value in the snippet below. However, as you can see, x can't be null at the point due to the triggered boolean value.

    public double execute(Entity entity, int a, int b) {
        Long x = entity != null ? 123L : null;

        boolean triggered;
        if (a > b) {
            triggered = x != null;
        } else {
            triggered = false;
        }

        double score = 1.0;
        if (triggered) {
            score = score - Utils.function(x); // <-- ERROR HERE!
        }
        return score;
    }

Now that I'm opening up this issue, I believe this can actually be due to #98 (i.e., lack of support for nullability stored in boolean variables). I'll still open up this issue to record that we faced it in a real-world project.

Project reproducing it: https://github.com/mauricioaniche/nullaway-bug.

Library versions:

  • NullAway: 0.12.0
  • Errorprone: 2.34.0
  • Java version: 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions