Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sonar wants to close the Stream [duplicate]

I have a next code:

private Stream<Field> getStreamWithAccessibleFields(final Object object) {
    return Arrays.stream(object.getClass()
            .getDeclaredFields()).peek(field -> field.setAccessible(true));
}

Sonar throws me an issue: [MINOR] Close this "Stream". squid:S2095. Can anybody give an advice, how I can handle this problem?

like image 292
Sergey Zim Avatar asked Apr 29 '16 14:04

Sergey Zim


1 Answers

This is a false positive that is already fixed and soon to be released with SonarQube Java 3.14.

For further reference, please check SONARJAVA-1478.

like image 158
Fabrice - SonarSource Team Avatar answered Sep 29 '22 10:09

Fabrice - SonarSource Team