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 206697 Details for
Bug 363293
resource leaks in org.eclipse.jdt.compiler.tool.tests
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
patch with sorting
Bug_363293_v2.patch (text/plain), 5.85 KB, created by
Stephan Herrmann
on 2011-11-09 09:44:53 EST
(
hide
)
Description:
patch with sorting
Filename:
MIME Type:
Creator:
Stephan Herrmann
Created:
2011-11-09 09:44:53 EST
Size:
5.85 KB
patch
obsolete
>diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/AbstractCompilerToolTest.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/AbstractCompilerToolTest.java >index cd6cbfe..cb26233 100644 >--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/AbstractCompilerToolTest.java >+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/AbstractCompilerToolTest.java >@@ -12,6 +12,7 @@ > package org.eclipse.jdt.compiler.tool.tests; > > import java.io.File; >+import java.io.IOException; > import java.io.PrintWriter; > import java.util.ArrayList; > import java.util.List; >@@ -98,16 +99,24 @@ > if (manager == null) { > manager = COMPILER.getStandardFileManager(null, null, null); // will pick defaults up > } >- List<File> files = new ArrayList<File>(); >- String[] fileNames = arguments.fileNames; >- for (int i = 0, l = fileNames.length; i < l; i++) { >- if (fileNames[i].startsWith(OUTPUT_DIR)) { >- files.add(new File(fileNames[i])); >- } else { >- files.add(new File(OUTPUT_DIR + File.separator + fileNames[i])); >+ try { >+ List<File> files = new ArrayList<File>(); >+ String[] fileNames = arguments.fileNames; >+ for (int i = 0, l = fileNames.length; i < l; i++) { >+ if (fileNames[i].startsWith(OUTPUT_DIR)) { >+ files.add(new File(fileNames[i])); >+ } else { >+ files.add(new File(OUTPUT_DIR + File.separator + fileNames[i])); >+ } > } >- } >- CompilationTask task = COMPILER.getTask(out, arguments.standardJavaFileManager /* carry the null over */, new CompilerInvocationDiagnosticListener(err), arguments.options, null, manager.getJavaFileObjectsFromFiles(files)); >- return task.call(); >+ CompilationTask task = COMPILER.getTask(out, arguments.standardJavaFileManager /* carry the null over */, new CompilerInvocationDiagnosticListener(err), arguments.options, null, manager.getJavaFileObjectsFromFiles(files)); >+ return task.call(); >+ } finally { >+ try { >+ manager.close(); >+ } catch (IOException e) { >+ // nop >+ } >+ } > } > } >diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java >index 60be95f..09a1689 100644 >--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java >+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerInvocationTests.java >@@ -502,7 +502,9 @@ > remaining = remainingAsList.iterator(); > assertTrue("does not support -d option", javacStandardJavaFileManager.handleOption("-d", remaining)); > assertEquals("unexpected consumption rate", "remainder", remaining.next()); >+ javacStandardJavaFileManager.close(); > } >+ ecjStandardJavaFileManager.close(); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918 > // options consumption - check consumption rate on supported zero-args options >@@ -525,6 +527,7 @@ > assertEquals("unexpected consumption rate", REMAINDER, remaining.next()); > } > } >+ ecjStandardJavaFileManager.close(); > } > // https://bugs.eclipse.org/bugs/show_bug.cgi?id=226918 > // options consumption - check consumption rate on supported one-arg options >@@ -540,6 +543,7 @@ > assertEquals("unexpected consumption rate", REMAINDER, remaining.next()); > } > } >+ ecjStandardJavaFileManager.close(); > } > // tests #10-11 show that ecj throws a RuntimeException when encountering a wrong > // encoding in its parameters, while the default compiler swallows it silently >diff --git a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java >index 84e2c1f..bf44e40 100644 >--- a/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java >+++ b/org.eclipse.jdt.compiler.tool.tests/src/org/eclipse/jdt/compiler/tool/tests/CompilerToolTests.java >@@ -19,6 +19,7 @@ > import java.io.StringWriter; > import java.nio.charset.Charset; > import java.util.ArrayList; >+import java.util.Collections; > import java.util.HashSet; > import java.util.Iterator; > import java.util.List; >@@ -604,7 +605,7 @@ > assertTrue("delete failed", inputFile.delete()); > } > >- public void testCompilerOneClassWithEclipseCompiler4() { >+ public void testCompilerOneClassWithEclipseCompiler4() throws IOException { > JavaCompiler systemCompiler = ToolProvider.getSystemJavaCompiler(); > if (systemCompiler == null) { > System.out.println("No system java compiler available"); >@@ -653,6 +654,7 @@ > } > // check that the .class file exist for X > assertTrue("delete failed", inputFile.delete()); >+ manager.close(); > } > > public void testCompilerOneClassWithEclipseCompiler5() { >@@ -869,6 +871,7 @@ > builder.append(name.substring(lastIndexOf + 1)); > } > assertEquals("Wrong contents", "X.java", String.valueOf(builder)); >+ fileManager.close(); > } catch (IOException e) { > e.printStackTrace(); > } >@@ -934,15 +937,17 @@ > Iterable<? extends JavaFileObject> compilationUnits = fileManager.list(sourceLoc, "", fileTypes, true); > > Iterator<? extends JavaFileObject> it = compilationUnits.iterator(); >- StringBuilder builder = new StringBuilder(); >+ List<String> names = new ArrayList<String>(); > while (it.hasNext()) { > JavaFileObject next = it.next(); > String name = next.getName(); > name = name.replace('\\', '/'); > int lastIndexOf = name.lastIndexOf('/'); >- builder.append(name.substring(lastIndexOf + 1)); >+ names.add(name.substring(lastIndexOf + 1)); > } >- assertEquals("Wrong contents", "X2.javaX.java", String.valueOf(builder)); >+ Collections.sort(names); >+ assertEquals("Wrong contents", "[X.java, X2.java]", names.toString()); >+ fileManager.close(); > } catch (IOException e) { > e.printStackTrace(); > }
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 363293
:
206678
| 206697