Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

don't close the input stream as HTMLParser spawns a thread internally and closing the stream leads to errors (this reverts one of my previous changes)

Daniel Naber71067fa4ff10
diff --git a/src/demo/org/apache/lucene/demo/HTMLDocument.java b/src/demo/org/apache/lucene/demo/HTMLDocument.java
index 7e9145bd5fc..13e9fe1a891 100644
--- a/src/demo/org/apache/lucene/demo/HTMLDocument.java
+++ b/src/demo/org/apache/lucene/demo/HTMLDocument.java
@@ -62,25 +62,19 @@ public class HTMLDocument {
// tokenized prior to indexing.
doc.add(new Field("uid", uid(f), Field.Store.NO, Field.Index.UN_TOKENIZED));
- FileInputStream fis = null;
- try {
- fis = new FileInputStream(f);
- HTMLParser parser = new HTMLParser(fis);
+ FileInputStream fis = new FileInputStream(f);
+ HTMLParser parser = new HTMLParser(fis);
- // Add the tag-stripped contents as a Reader-valued Text field so it will
- // get tokenized and indexed.
- doc.add(new Field("contents", parser.getReader()));
+ // Add the tag-stripped contents as a Reader-valued Text field so it will
+ // get tokenized and indexed.
+ doc.add(new Field("contents", parser.getReader()));
- // Add the summary as a field that is stored and returned with
- // hit documents for display.
- doc.add(new Field("summary", parser.getSummary(), Field.Store.YES, Field.Index.NO));
+ // Add the summary as a field that is stored and returned with
+ // hit documents for display.
+ doc.add(new Field("summary", parser.getSummary(), Field.Store.YES, Field.Index.NO));
- // Add the title as a field that it can be searched and that is stored.
- doc.add(new Field("title", parser.getTitle(), Field.Store.YES, Field.Index.TOKENIZED));
- } finally {
- if (fis != null)
- fis.close();
- }
+ // Add the title as a field that it can be searched and that is stored.
+ doc.add(new Field("title", parser.getTitle(), Field.Store.YES, Field.Index.TOKENIZED));
// return the document
return doc;