Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2015-12-01 16:08:09 +0000
committerMarkus Keller2015-12-01 16:08:09 +0000
commit7e4ccad828f771ba6f03bf5c585ba5779d2bacdc (patch)
tree03b76b849af8d95c448ebbab5434ce1c06ab72bb
parent96da92a20589d62dad534245c5d9c4d45618ee95 (diff)
downloadeclipse.platform.text-7e4ccad828f771ba6f03bf5c585ba5779d2bacdc.tar.gz
eclipse.platform.text-7e4ccad828f771ba6f03bf5c585ba5779d2bacdc.tar.xz
eclipse.platform.text-7e4ccad828f771ba6f03bf5c585ba5779d2bacdc.zip
follow-up to bug 478673: fixed resource leaks
-rw-r--r--org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java16
-rw-r--r--org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java3
-rw-r--r--org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java1
3 files changed, 12 insertions, 8 deletions
diff --git a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
index 60f8e0dbc..ef1c09d6c 100644
--- a/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
+++ b/org.eclipse.jface.text.tests/src/org/eclipse/jface/text/tests/HTML2TextReaderTest.java
@@ -56,8 +56,10 @@ public class HTML2TextReaderTest extends TestCase {
private void verify(String input, String expectedOutput, int styleRangeCount) throws IOException {
Reader reader= new StringReader(input);
TextPresentation textPresentation= new TextPresentation();
- HTML2TextReader htmlReader= new HTML2TextReader(reader, textPresentation);
- String result= htmlReader.getString();
+ String result;
+ try (HTML2TextReader htmlReader= new HTML2TextReader(reader, textPresentation)) {
+ result= htmlReader.getString();
+ }
if (DEBUG)
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
@@ -86,8 +88,10 @@ public class HTML2TextReaderTest extends TestCase {
private void verify(String input, String expectedOutput, StyleRange[] styleRanges) throws IOException {
Reader reader= new StringReader(input);
TextPresentation textPresentation= new TextPresentation();
- HTML2TextReader htmlReader= new HTML2TextReader(reader, textPresentation);
- String result= htmlReader.getString();
+ String result;
+ try (HTML2TextReader htmlReader= new HTML2TextReader(reader, textPresentation)) {
+ result= htmlReader.getString();
+ }
if (DEBUG)
System.out.println("<" + result + "/>");
assertEquals(expectedOutput, result);
@@ -174,7 +178,9 @@ public class HTML2TextReaderTest extends TestCase {
char[] cb= new char[20];
StringReader reader= new StringReader("<head>");
- new HTML2TextReader(reader, null).read(cb);
+ try (HTML2TextReader r= new HTML2TextReader(reader, null)) {
+ r.read(cb);
+ }
assertTrue(Arrays.equals(new char[20], cb));
}
diff --git a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
index bfc048735..9b5f5bfc3 100644
--- a/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
+++ b/org.eclipse.jface.text/src/org/eclipse/jface/internal/text/html/BrowserInformationControl.java
@@ -427,9 +427,8 @@ public class BrowserInformationControl extends AbstractInformationControl implem
// Instead of inserting an empty line, it just adds a single line break.
// Furthermore, the indentation of <dl><dd> elements is too small (e.g with a long @see line)
TextPresentation presentation= new TextPresentation();
- HTML2TextReader reader= new HTML2TextReader(new StringReader(fInput.getHtml()), presentation);
String text;
- try {
+ try (HTML2TextReader reader= new HTML2TextReader(new StringReader(fInput.getHtml()), presentation)) {
text= reader.getString();
} catch (IOException e) {
text= ""; //$NON-NLS-1$
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
index 56c34f9e7..b14561573 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/templates/TemplatePreferencePage.java
@@ -1586,7 +1586,6 @@ public abstract class TemplatePreferencePage extends PreferencePage implements I
String left= ((TemplateLabelProvider)baseLabel).getColumnText(e1, fSortColumn);
String right= ((TemplateLabelProvider)baseLabel).getColumnText(e2, fSortColumn);
- @SuppressWarnings("unchecked")
int sortResult= getComparator().compare(left, right);
return sortResult * fSortOrder;
}

Back to the top