summaryrefslogtreecommitdiffstatsabout
diff options
context:
space:
mode:
authorMickael Istria2013-10-08 05:24:17 (EDT)
committer Paul Webster2013-10-08 09:27:15 (EDT)
commitcc58f7512baa46a5c2395d64cc7959ddfb207fb8 (patch)
tree6cf01ca6500e35002bc2fa4ba600d699a0de6f95
parent8de3155d663912d58c7b1b72a02807af3e359096 (diff)
downloadeclipse.platform.ui-cc58f7512baa46a5c2395d64cc7959ddfb207fb8.zip
eclipse.platform.ui-cc58f7512baa46a5c2395d64cc7959ddfb207fb8.tar.gz
eclipse.platform.ui-cc58f7512baa46a5c2395d64cc7959ddfb207fb8.tar.bz2
Bug 413348: Fix stream leakrefs/changes/12/14712/8
Signed-off-by: Mickael Istria <mistria@redhat.com> Change-Id: I3b182dcd63251188aef58aaf9d904fa4d3f85eea
-rw-r--r--bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/AbstractCSSEngine.java28
1 files changed, 18 insertions, 10 deletions
diff --git a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/AbstractCSSEngine.java b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/AbstractCSSEngine.java
index d5670e4..1293898 100644
--- a/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/AbstractCSSEngine.java
+++ b/bundles/org.eclipse.e4.ui.css.core/src/org/eclipse/e4/ui/css/core/impl/engine/AbstractCSSEngine.java
@@ -9,6 +9,7 @@
* Angelo Zerr <angelo.zerr@gmail.com> - initial API and implementation
* IBM Corporation - ongoing development
* Red Hat Inc. (mistria) - Fixes suggested by FindBugs
+ * Red Hat Inc. (mistria) - Bug 413348: fix stream leak
*******************************************************************************/
package org.eclipse.e4.ui.css.core.impl.engine;
@@ -202,16 +203,23 @@ public abstract class AbstractCSSEngine implements CSSEngine {
url = new URL(path);
}
}
- InputStream stream = url.openStream();
- InputSource tempStream = new InputSource();
- tempStream.setURI(url.toString());
- tempStream.setByteStream(stream);
- parseImport = true;
- styleSheet = (CSSStyleSheet) this.parseStyleSheet(tempStream);
- parseImport = false;
- CSSRuleList tempRules = styleSheet.getCssRules();
- for (int j = 0; j < tempRules.getLength(); j++) {
- masterList.add(tempRules.item(j));
+ InputStream stream = null;
+ try {
+ stream = url.openStream();
+ InputSource tempStream = new InputSource();
+ tempStream.setURI(url.toString());
+ tempStream.setByteStream(stream);
+ parseImport = true;
+ styleSheet = (CSSStyleSheet) this.parseStyleSheet(tempStream);
+ parseImport = false;
+ CSSRuleList tempRules = styleSheet.getCssRules();
+ for (int j = 0; j < tempRules.getLength(); j++) {
+ masterList.add(tempRules.item(j));
+ }
+ } finally {
+ if (stream != null) {
+ stream.close();
+ }
}
}