Inspections: Is it possible to mark a method as resolving an inspection?

Answered

I'm looking for JDBC resource leaks in a large project, and the inspection "JDBC resource opened but not safely closed" is reporting thousands of instances that are not actually problems.

We have a helper method that we use in all finally blocks that avoids NullPointerException and swallows any SQLExceptions thrown by calling close() on the resources. Here's an example:

try {
...
} finally {
DBHelper.cleanUp(rs, stmt, connection);
}

Is there a facility in IntelliJ IDEA to let me specify that DBHelper.cleanUp(*) resolves the inspection?

Edit: I should note that the inspection option "Any method may close resource argument" doesn't work when the method is used in the finally block. It only appears to work when used inside the same try block as where the resource was created.

0
1 comment

Hi. per https://youtrack.jetbrains.com/issue/IDEA-72042 this should work from the box, could you please raise a ticket at https://youtrack.jetbrains.com/issues ?

0

Please sign in to leave a comment.