• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

uber / NullAway / #985
93%

Build:
DEFAULT BRANCH: master
Ran 02 Nov 2022 04:46AM UTC
Jobs 1
Files 73
Run time 4s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

pending completion
#985

push

github-actions

web-flow
Fix LibraryModels recording of dataflow nullness for Map APs  (#685)

We had a long-standing bug in our recording of the nullness of access paths inside `LibraryModelsHandler`.

Namely, as part of `accessPathsAtIndexes`, we were calling `getAccessPathForNodeNoMapGet`, rather
than `getAccessPathForNodeWithMapGet`. Among other things, `accessPathsAtIndexes` is used to calculate
which arguments for a method like `Preconditions.checkNotNull([expr])` are marked as being non-null after
the method's execution (this extends to all methods in `failIfNullParameters` and similar logic applies to other
types of library models). Due to our use of `getAccessPathForNodeNoMapGet`, code like the following:

```
private void foo(Map<String,Object> m) {
    Preconditions.checkNotNull(m.get(\"foo\"));
    m.get(\"foo\").toString(); // FP!
  }
}
```

Would result in a false positive, where `m.get(\"foo\").toString()` shows up as a null-dereference, despite the
preceding `Preconditions.checkNotNull` call.

This despite the following working without issue:

```
private void foo(@Nullable Object o) {
    Preconditions.checkNotNull(o);
    o.toString(); // Worked before and still works!
  }
}
```

This PR fixes this bug.

The core fix is simply replacing the `getAccessPathForNodeNoMapGet` with `getAccessPathForNodeWithMapGet`.

However, to achieve this, we must thread `VisitorState` all the way to the 
`LibraryModelsHandler.accessPathsAtIndexes(...)` method, which requires changing the signature of the
`onDataflowVisitMethodInvocation(...)` handler extension point. This makes the bulk of the code changes
in this PR.

Finally, we include a few test cases for unboxing, which are an artifact of how we discovered and then triagged
this bug.

(Edit for posterity: thanks @msridhar for finding the root cause here)

5050 of 5446 relevant lines covered (92.73%)

0.93 hits per line

Jobs
ID Job ID Ran Files Coverage
1 #985.1 02 Nov 2022 04:46AM UTC 0
92.73
Source Files on build #985
Detailed source file information is not available for this build.
  • Back to Repo
  • Build #985
  • d1415f4c on github
  • Prev Build on master
  • Next Build on master
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc