Menu

#1404 UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR problem with annotation

3.x
closed-rejected
nobody
None
5
2017-10-22
2015-07-30
No

I have a lot of false positives for UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR when there is any use of annotations that would enforce the value to be initialized.
like:
org.hibernate.validator.constraints.NotEmpty
javax.annotation.PostConstruct

Discussion

  • Anonymous

    Anonymous - 2015-07-30

    Also, there is a problem with lambdas. For example:

    private Set<String> set;
    String[] filter(String[] values) {
        if (set == null || values == null || values.length == 0) {
            return values;
        }
    
        return Arrays.stream(values)
            .filter(value-> set.contains(value))
            .toArray(String[]::new);
    }
    
     

    Last edit: Tagir Valeev 2015-10-08
  • Tagir Valeev

    Tagir Valeev - 2015-10-08

    Actually there are two different problems. Lambda body is compiled into separate method which is analyzed just as normal method. FindBugs is not too smart currently to understand that this method can be called only from the filter method after an explicit check. By the way you can use method reference to get rid of warning: .filter(set::contains).

     
  • Andrey Loskutov

    Andrey Loskutov - 2017-10-22
    • Status: open --> closed-rejected
     

Log in to post a comment.

MongoDB Logo MongoDB