error-prone icon indicating copy to clipboard operation
error-prone copied to clipboard

MustBeClosedChecker - False positive due to variable declaration without expression

Open rwinograd opened this issue 3 years ago • 0 comments

Looking at this line of code, I believe that we should be looking for the next statement that is not an empty variable declaration.

For example:

Closeable closeable = getCloseable();
@var SomeVariable x;
try {
 // code here
} finally {
  closeable.close();
}

I believe that since there is no expression on the RHS of the SomeVariable declaration, that the closeable is indeed guaranteed to be closed.

rwinograd avatar Jul 27 '22 21:07 rwinograd