mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-31555 Wrong warning: method invocation may produce a NullPointerException
This commit is contained in:
@@ -685,7 +685,7 @@ class ControlFlowAnalyzer extends JavaElementVisitor {
|
||||
private void addGotoCatch(CatchDescriptor cd) {
|
||||
addInstruction(new PushInstruction(myFactory.getVarFactory().create(cd.getParameter(), false), null));
|
||||
addInstruction(new SwapInstruction());
|
||||
addInstruction(new AssignInstruction(null));
|
||||
myCurrentFlow.addInstruction(new AssignInstruction(null));
|
||||
addInstruction(new PopInstruction());
|
||||
addInstruction(new GotoInstruction(cd.getJumpOffset()));
|
||||
}
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
import java.io.IOException;
|
||||
|
||||
class TestIDEAWarn {
|
||||
private Connection _connection;
|
||||
|
||||
public void warn() throws IOException {
|
||||
try {
|
||||
if (_connection != null) {
|
||||
try {
|
||||
_connection.commit();
|
||||
} finally {
|
||||
_connection.close();
|
||||
_connection = null;
|
||||
}
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void warn2() throws IOException {
|
||||
if (_connection == null) return;
|
||||
try {
|
||||
try {
|
||||
_connection.commit();
|
||||
} finally {
|
||||
_connection.close();
|
||||
_connection = null;
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
interface Connection {
|
||||
void commit() throws IOException;
|
||||
void close() throws IOException;
|
||||
}
|
||||
}
|
||||
@@ -71,5 +71,6 @@ public class DataFlowInspectionFixtureTest extends JavaCodeInsightFixtureTestCas
|
||||
public void testContinueFlushesLoopVariable() throws Throwable { doTest(); }
|
||||
|
||||
public void testEqualsNotNull() throws Throwable { doTest(); }
|
||||
public void testVisitFinallyOnce() throws Throwable { doTest(); }
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user