ucr-riple / NullAwayAnnotator

A tool to help adapting code bases to NullAway type system.
MIT License
13 stars 6 forks source link

Bug Report: Annotator Incorrectly Adds Duplicate @Nullable Annotations #262

Closed nimakarimipour closed 5 days ago

nimakarimipour commented 5 days ago

Describe the Bug

Annotator mistakenly adds a duplicate @Nullable annotation to a field that already has a @Nullable annotation with a comment.

Steps to Reproduce

Consider the following code snippet:

class Test {
    @Nullable @GuardedBy("this") // Either a RuntimeException, non-fatal Error, or IOException.
    private Throwable creationFailure;
}

When Annotator attempts to ensure the creationFailure field is nullable, it fails to recognize that the field is already annotated as @Nullable. The resulting output incorrectly adds a duplicate annotation:

class Test {
    @Nullable @Nullable @GuardedBy("this") // Either a RuntimeException, non-fatal Error, or IOException.
    private Throwable creationFailure;
}

This causes a compilation error, terminating the process.