View | Details | Raw Unified | Return to bug 358903 | Differences between
and this patch

Collapse All | Expand All

(-)a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/ResourceLeakTests.java (-2 / +28 lines)
Lines 26-32 import org.eclipse.jdt.internal.compiler.impl.CompilerOptions; Link Here
26
public class ResourceLeakTests extends AbstractRegressionTest {
26
public class ResourceLeakTests extends AbstractRegressionTest {
27
27
28
static {
28
static {
29
//	TESTS_NAMES = new String[] { "test061c"};
29
//	TESTS_NAMES = new String[] { "test063e"};
30
//	TESTS_NUMBERS = new int[] { 50 };
30
//	TESTS_NUMBERS = new int[] { 50 };
31
//	TESTS_RANGE = new int[] { 11, -1 };
31
//	TESTS_RANGE = new int[] { 11, -1 };
32
}
32
}
Lines 1838-1844 public void test056throw5() { Link Here
1838
		true,
1838
		true,
1839
		options);
1839
		options);
1840
}
1840
}
1841
1842
// Bug 358903 - Filter practically unimportant resource leak warnings
1841
// Bug 358903 - Filter practically unimportant resource leak warnings
1843
// Bug 360908 - Avoid resource leak warning when the underlying/chained resource is closed explicitly
1842
// Bug 360908 - Avoid resource leak warning when the underlying/chained resource is closed explicitly
1844
// a resource wrapper is not closed but the underlying resource is
1843
// a resource wrapper is not closed but the underlying resource is
Lines 2674-2678 public void test063d() throws IOException { Link Here
2674
		"----------\n",
2673
		"----------\n",
2675
		options);
2674
		options);
2676
}
2675
}
2676
// Bug 362332 - Only report potential leak when closeable not created in the local scope
2677
// a resource is obtained from a field read, then re-assigned
2678
public void test063e() {
2679
	Map options = getCompilerOptions();
2680
	options.put(CompilerOptions.OPTION_ReportUnclosedCloseable, CompilerOptions.ERROR);
2681
	options.put(CompilerOptions.OPTION_ReportPotentiallyUnclosedCloseable, CompilerOptions.ERROR);
2682
	this.runConformTest(
2683
		new String[] {
2684
			"X.java",
2685
			"import java.io.FileInputStream;\n" +
2686
			"import java.io.IOException;\n" +
2687
			"public class X {\n" +
2688
			"    FileInputStream input1;\n" +
2689
			"    public void foo() throws IOException {\n" +
2690
			"        FileInputStream input = input1;\n" +
2691
			"        input = new FileInputStream(\"adfafd\");\n" +
2692
			"        input.close();\n" +
2693
			"    }\n" +
2694
			"}\n"
2695
		},
2696
		"",
2697
		null,
2698
		true,
2699
		null,
2700
		options,
2701
		null);
2702
}
2677
2703
2678
}
2704
}
(-)a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/FakedTrackingVariable.java (-2 / +1 lines)
Lines 351-358 public class FakedTrackingVariable extends LocalDeclaration { Link Here
351
			tracker.globalClosingState |= PASSED_TO_OUTSIDE;
351
			tracker.globalClosingState |= PASSED_TO_OUTSIDE;
352
			flowInfo.markPotentiallyNullBit(tracker.binding); // shed some doubt
352
			flowInfo.markPotentiallyNullBit(tracker.binding); // shed some doubt
353
			return tracker;			
353
			return tracker;			
354
		} else if (expression instanceof FieldReference 
354
		} else if ((expression.bits & RestrictiveFlagMASK) == Binding.FIELD) 
355
				|| expression instanceof QualifiedNameReference) 
356
		{
355
		{
357
			// responsibility for this resource probably lies at a higher level
356
			// responsibility for this resource probably lies at a higher level
358
			FakedTrackingVariable tracker = new FakedTrackingVariable(local, location);
357
			FakedTrackingVariable tracker = new FakedTrackingVariable(local, location);

Return to bug 358903