fb-contrib
fb-contrib copied to clipboard
false-positive? in `EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS`
With this code:
public void foo() throws Exception {
}
public void bar() {
java.util.Collections.emptyList().forEach(foo -> {
try {
foo();
} catch (Exception e) {
throw new RuntimeException(e);
}
});
}
public void baz() {
java.util.Collections.emptyList().forEach(foo -> bam());
}
public void bam() {
try {
foo();
} catch (Exception e) {
throw new RuntimeException(e);
}
}
the pattern is happy with bar() as the forEach must not throw a checked exception.
But it complains about bam (even if it is private static) where the try-catch is moved to an own method for better readability / maintainability.
Maybe the pattern can be made not detected if used like this in the same class?
it's likely that lambda's were synthetic, and ignored, which wasn't a thing at the time. i'll check