Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 204331 Details for
Bug 359334
Analysis for resource leak warnings does not consider exceptions as method exit points
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
test & fix
Bug_359334.patch (text/plain), 4.89 KB, created by
Stephan Herrmann
on 2011-09-29 18:58:54 EDT
(
hide
)
Description:
test & fix
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-09-29 18:58:54 EDT
Size:
4.89 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >index 0deb894..f1d190b 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/MethodVerifyTest.java >@@ -11238,7 +11238,6 @@ > } > //https://bugs.eclipse.org/bugs/show_bug.cgi?id=285088 > public void test200() { >- Map options = getCompilerOptions(); > String errorMessage = > "----------\n" + > "1. ERROR in X.java (at line 3)\n" + >diff --git a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java >index be3fcc3..542911f 100644 >--- a/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java >+++ b/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/TryWithResourcesStatementTest.java >@@ -10,6 +10,7 @@ > * Stephan Herrmann - Contributions for > * bug 358827 - [1.7] exception analysis for t-w-r spoils null analysis > * bug 349326 - [1.7] new warning for missing try-with-resources >+ * bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points > *******************************************************************************/ > package org.eclipse.jdt.core.tests.compiler.regression; > >@@ -4942,6 +4943,45 @@ > true, > options); > } >+// Bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points >+public void test056throw1() { >+ Map options = getCompilerOptions(); >+ options.put(JavaCore.COMPILER_PB_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR); >+ options.put(JavaCore.COMPILER_PB_POTENTIALLY_UNCLOSED_CLOSEABLE, CompilerOptions.ERROR); >+ options.put(JavaCore.COMPILER_PB_EXPLICITLY_CLOSED_AUTOCLOSEABLE, CompilerOptions.ERROR); >+ options.put(JavaCore.COMPILER_PB_DEAD_CODE, CompilerOptions.ERROR); >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "import java.io.FileReader;\n" + >+ "public class X {\n" + >+ " void foo2(boolean a, boolean b, boolean c) throws Exception {\n" + >+ " FileReader reader = new FileReader(\"file\");\n" + >+ " if(a)\n" + >+ " throw new Exception(); //warning 1\n" + >+ " else if (b)\n" + >+ " reader.close();\n" + >+ " else if(c)\n" + >+ " throw new Exception(); //warning 2\n" + >+ " reader.close();\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " throw new Exception(); //warning 1\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Resource leak: \'reader\' is not closed at this location\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 10)\n" + >+ " throw new Exception(); //warning 2\n" + >+ " ^^^^^^^^^^^^^^^^^^^^^^\n" + >+ "Resource leak: \'reader\' is not closed at this location\n" + >+ "----------\n", >+ null, >+ true, >+ options); >+} > public static Class testClass() { > return TryWithResourcesStatementTest.class; > } >diff --git a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java >index 7e3d4c2..2e2fe4e 100644 >--- a/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java >+++ b/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ThrowStatement.java >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2009 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -7,6 +7,7 @@ > * > * Contributors: > * IBM Corporation - initial API and implementation >+ * Stephan Herrmann - Contribution for bug 359334 - Analysis for resource leak warnings does not consider exceptions as method exit points > *******************************************************************************/ > package org.eclipse.jdt.internal.compiler.ast; > >@@ -35,6 +36,7 @@ > this.exception.checkNPE(currentScope, flowContext, flowInfo); > // need to check that exception thrown is actually caught somewhere > flowContext.checkExceptionHandlers(this.exceptionType, this, flowInfo, currentScope); >+ currentScope.checkUnclosedCloseables(flowInfo, null/*ignore exception exits from flowContext*/, this); > return FlowInfo.DEAD_END; > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 359334
:
204331
|
204333
|
204420
|
204421