Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[java] PreserveStackTrace not handling Throwable.addSuppressed(...) #2134

Closed
lars-sh opened this issue Nov 27, 2019 · 1 comment · Fixed by #3179
Closed

[java] PreserveStackTrace not handling Throwable.addSuppressed(...) #2134

lars-sh opened this issue Nov 27, 2019 · 1 comment · Fixed by #3179
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@lars-sh
Copy link

lars-sh commented Nov 27, 2019

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);
	}
}
@jsotuyod jsotuyod added an:enhancement An improvement on existing features / rules a:false-positive PMD flags a piece of code that is not problematic and removed an:enhancement An improvement on existing features / rules labels Nov 27, 2019
@oowekyala oowekyala linked a pull request May 9, 2021 that will close this issue
5 tasks
oowekyala added a commit to oowekyala/pmd that referenced this issue May 9, 2021
@adangel adangel added this to the 7.0.0 milestone May 27, 2021
@adangel adangel mentioned this issue Jan 23, 2023
55 tasks
@adangel
Copy link
Member

adangel commented Apr 22, 2023

This has been fixed with PMD 7.0.0-rc1.

@adangel adangel closed this as completed Apr 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a:false-positive PMD flags a piece of code that is not problematic
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants