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] IdenticalCatchBranches false positive with return expressions #1480

Closed
adangel opened this issue Nov 25, 2018 · 0 comments
Closed

[java] IdenticalCatchBranches false positive with return expressions #1480

adangel opened this issue Nov 25, 2018 · 0 comments
Labels
a:false-positive PMD flags a piece of code that is not problematic
Milestone

Comments

@adangel
Copy link
Member

adangel commented Nov 25, 2018

Affects PMD Version: 6.9.0

Rule: IdenticalCatchBranches

Description: False positive if only the return statement expression is different (true vs. false in the example below).

Code Sample demonstrating the issue:

public boolean classNameExists(String fullyQualifiedClassName) {
try {
pmdClassLoader.loadClass(fullyQualifiedClassName);
return true; // Class found
} catch (ClassNotFoundException e) {
return false;
} catch (LinkageError e2) {
// Class exists, but may be invalid (see https://github.com/pmd/pmd/issues/1131)
return true;
}
}

Running PMD through: Maven

@adangel adangel added the a:false-positive PMD flags a piece of code that is not problematic label Nov 25, 2018
@oowekyala oowekyala added this to the 7.0.0 milestone Apr 25, 2023
@adangel adangel changed the title [java] IdenticalCatchBranches false positive [java] IdenticalCatchBranches false positive with return expressions Apr 27, 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

No branches or pull requests

2 participants