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

false-positive in EXS_EXCEPTION_SOFTENING_NO_CONSTRAINTS when rethrowing exception #447

Open
Vampire opened this issue Jun 27, 2023 · 2 comments

Comments

@Vampire
Copy link

Vampire commented Jun 27, 2023

I have some code that catches a RuntimeException subclass, enriches it with some details and rethrows the same exception instance.
The rule description "catching a checked exception and weakening it to a runtime exception" does not apply.
But nevertheless I get a finding reported by 7.6.0.

@mebigfatguy
Copy link
Owner

I tried doing

public class EXS_Sample {
public long fpRTToRT(String s) {
try {
throw new MyRTE();
} catch (MyRTE r) {
MyRTE rr = r.embellish("important!");
throw rr;
}
}
}

class MyRTE extends RuntimeException {
String data;

class MyRTE extends RuntimeException {
String data;

public MyRTE() {
}

MyRTE embellish(String s) {
    data = s;
    return this;
}

}

but couldn't reproduce. can you break my sample?

@Vampire
Copy link
Author

Vampire commented Nov 17, 2023

Maybe try to throw r, not rr?
Otherwise I have to try again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants