Potential false positive in complex method
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 4.1k
- Forks
- 370
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 68
Description
I have a complex method that, sadly, seems worse when broke apart. So while none of my tests fail, I cannot be certain myself that there is not a bug.
BoundedLocalCache.java:589: error: [NullAway] dereferenced expression candidate is @Nullable
candidate.getPreviousInAccessOrder();
^
However, the loop terminates earlier on the condition that both candidate and victim are null. This error is reported in a block when the victim is null, so therefore the candidate cannot be. I would consider this a perfect example where I'd want to trust a data flow analysis over my own, but I don't think it is correct. Due to the reassignments and looping, it may have gotten confused.
if (victim == null) {
candidates--;
Node<K, V> evict = candidate;
candidate = candidate.getPreviousInAccessOrder();
evictEntry(evict, RemovalCause.SIZE, 0L);
continue;
} else if (candidate == null) { ... }
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked BoundedLocalCache.java method around the NullAway diagnostic at line 589, then trace the loop and its candidate/victim reassignments. Determine whether the warning is a false positive; done means the reported behavior is confirmed and the issue is resolved or clearly documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100