mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-144665 (Incorrect 'tearDown() is not called from finally block' inspection)
This commit is contained in:
+1
-1
@@ -55,7 +55,7 @@ public class SuperTearDownInFinallyInspection extends BaseInspection {
|
||||
return;
|
||||
}
|
||||
final PsiMethod method = PsiTreeUtil.getParentOfType(expression, PsiMethod.class, true, PsiMember.class, PsiLambdaExpression.class);
|
||||
if (method == null) {
|
||||
if (method == null || !method.getName().equals("tearDown")) {
|
||||
return;
|
||||
}
|
||||
final PsiClass containingClass = method.getContainingClass();
|
||||
|
||||
+17
-3
@@ -1,17 +1,19 @@
|
||||
class SuperTearDownInFinally extends junit.framework.TestCase {
|
||||
import junit.framework.TestCase;
|
||||
|
||||
class SuperTearDownInFinally extends TestCase {
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
super.<warning descr="'tearDown()' not called from 'finally' block">tearDown</warning>();
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
class NoProblem extends junit.framework.TestCase {
|
||||
class NoProblem extends TestCase {
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
class CalledInFinally extends junit.framework.TestCase {
|
||||
class CalledInFinally extends TestCase {
|
||||
|
||||
public void tearDown() throws Exception {
|
||||
try {
|
||||
@@ -20,4 +22,16 @@ class CalledInFinally extends junit.framework.TestCase {
|
||||
super.tearDown();
|
||||
}
|
||||
}
|
||||
}
|
||||
class SomeTest extends TestCase {
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
try {
|
||||
super.setUp();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
super.tearDown(); // yellow code
|
||||
}
|
||||
}
|
||||
public void test_something() {}
|
||||
}
|
||||
Reference in New Issue
Block a user