Affects PMD Version: 6.19.0
Rule: PreserveStackTrace
Description: The below code generates a false-positive PreserveStackTrace error while the outer exception really is preserved as part of the inner exception using addSuppressed.
This is really a rare case and I'm fine with suppressing it for now, but wanted to let you know about it and maybe this report even helps someone.
Code Sample demonstrating the issue:
try {
return ...;
} catch (IOException outerException) {
try {
return ...;
} catch (IOException innerException) {
innerException.addSuppressed(outerException);
throw new UncheckedIOException(innerException);
}
}
Affects PMD Version: 6.19.0
Rule: PreserveStackTrace
Description: The below code generates a false-positive
PreserveStackTraceerror while the outer exception really is preserved as part of the inner exception usingaddSuppressed.This is really a rare case and I'm fine with suppressing it for now, but wanted to let you know about it and maybe this report even helps someone.
Code Sample demonstrating the issue: