Skip to content

Stream handling failing when using multiple filters #1492

@korshyadoo

Description

@korshyadoo

Here is a method in my project where NullAway is reporting [NullAway] dereferenced expression re.getValue() is @Nullable in the second filter.

    public List<RelatedEntity> filterByRoleAndServiceSpecificationName(List<RelatedEntity> relatedEntities,SERVICE_SPECIFICATION serviceSpecName) {
        return relatedEntities.stream()
            .filter(re -> nonNull(re) && nonNull(re.getValue()) && nonNull(re.getValue().getServiceSpecification()))
            .filter(re -> serviceSpecName.value.equalsIgnoreCase(re.getValue().getServiceSpecification().getName()))
            .collect(Collectors.toList());
    }

It seems to be recognizing that re was null checked because it does not report an error on dereferencing re, but it's not recognizing that re.getValue() has been checked.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions