Skip to content

Apache Lucene open-source search software

LUCENE-1455: close FileInputStream after parsing

Mark Robert Miller85f5a9c7401c
diff --git a/contrib/ant/src/java/org/apache/lucene/ant/HtmlDocument.java b/contrib/ant/src/java/org/apache/lucene/ant/HtmlDocument.java
index 2bd6e6e7524..956523e433c 100644
--- a/contrib/ant/src/java/org/apache/lucene/ant/HtmlDocument.java
+++ b/contrib/ant/src/java/org/apache/lucene/ant/HtmlDocument.java
@@ -60,8 +60,13 @@ public class HtmlDocument {
Tidy tidy = new Tidy();
tidy.setQuiet(true);
tidy.setShowWarnings(false);
- org.w3c.dom.Document root =
- tidy.parseDOM(new FileInputStream(file), null);
+ org.w3c.dom.Document root = null;
+ InputStream is = new FileInputStream(file);
+ try {
+ root = tidy.parseDOM(is, null);
+ } finally {
+ is.close();
+ }
rawDoc = root.getDocumentElement();
}