Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
*) Bugfix. Add missing plasmaParserDocument.close() calls
thelia2e309504425
diff --git a/htroot/Bookmarks.java b/htroot/Bookmarks.javaindex 2f8a8b8c0..bdd06ec1b 100644--- a/htroot/Bookmarks.java+++ b/htroot/Bookmarks.java@@ -160,6 +160,7 @@ public class Bookmarks {prop.put("mode_tags", (document == null) ? "" : document.getKeywords(','));prop.put("mode_public", 0);}+ if (document != null) document.close();} else {// get from the bookmark databaseprop.put("mode_edit", 1); // edit modediff --git a/htroot/CacheAdmin_p.java b/htroot/CacheAdmin_p.javaindex 65c450491..40f414288 100644--- a/htroot/CacheAdmin_p.java+++ b/htroot/CacheAdmin_p.java@@ -133,6 +133,7 @@ public class CacheAdmin_p {info.append(sentences[i]).append("<br>");}info.append("</span><br>");+ if (document != null) document.close();}} catch (Exception e) {info.append("- This file is not cached -<br><br>");diff --git a/htroot/ViewFile.java b/htroot/ViewFile.javaindex 79c29238d..b1f12ef9e 100644--- a/htroot/ViewFile.java+++ b/htroot/ViewFile.java@@ -256,6 +256,7 @@ public class ViewFile {prop.put("viewMode_sentences",sentences.length);}+ if (document != null) document.close();}prop.put("error",0);prop.put("error_url",url.toString());diff --git a/htroot/yacysearch.java b/htroot/yacysearch.javaindex 72adb9831..191fa3d71 100644--- a/htroot/yacysearch.java+++ b/htroot/yacysearch.java@@ -200,6 +200,7 @@ public class yacysearch {map.put("description", ((document == null) ? urlentry.descr() : document.getMainLongTitle()).replace(',', ' '));map.put("tags", ((document == null) ? "" : document.getKeywords(' ')));yacyCore.newsPool.publishMyNews(new yacyNewsRecord("stippadd", map));+ document.close();}}}diff --git a/source/de/anomic/plasma/plasmaParser.java b/source/de/anomic/plasma/plasmaParser.javaindex b0038249f..e339bc0fe 100644--- a/source/de/anomic/plasma/plasmaParser.java+++ b/source/de/anomic/plasma/plasmaParser.java@@ -830,6 +830,7 @@ public final class plasmaParser {System.out.println("URL " + anchorNr + ":\t" + key + " | " + anchors.get(key));anchorNr++;}+ document.close();}} catch (Exception e) {e.printStackTrace();diff --git a/source/de/anomic/plasma/plasmaParserDocument.java b/source/de/anomic/plasma/plasmaParserDocument.javaindex 0ca9bb8a1..a9b276d1f 100644--- a/source/de/anomic/plasma/plasmaParserDocument.java+++ b/source/de/anomic/plasma/plasmaParserDocument.java@@ -79,6 +79,7 @@ public class plasmaParserDocument {Map emaillinks;plasmaCondenser condenser;boolean resorted;+ private InputStream textStream;public plasmaParserDocument(URL location, String mimeType, String charset,String[] keywords, String shortTitle, String longTitle,@@ -156,9 +157,12 @@ public class plasmaParserDocument {try {if (this.text == null) return null;- if (this.text instanceof File) return new BufferedInputStream(new FileInputStream((File)this.text));- else if (this.text instanceof byte[]) return new ByteArrayInputStream((byte[])this.text);-+ if (this.text instanceof File) {+ this.textStream = new BufferedInputStream(new FileInputStream((File)this.text));+ } else if (this.text instanceof byte[]) {+ this.textStream = new ByteArrayInputStream((byte[])this.text);+ }+ return this.textStream;} catch (Exception e) {e.printStackTrace();}@@ -320,9 +324,26 @@ public class plasmaParserDocument {}public void close() {+ // try close the output stream+ if (this.textStream != null) {+ try {+ this.textStream.close();+ } catch (Exception e) {+ /* ignore this */+ } finally {+ this.textStream = null;+ }+ }+// delete the temp fileif ((this.text != null) && (this.text instanceof File)) {- try { ((File)this.text).delete(); } catch (Exception e) {/* ignore this */}+ try {+ ((File)this.text).delete();+ } catch (Exception e) {+ /* ignore this */+ } finally {+ this.text = null;+ }}}diff --git a/source/de/anomic/plasma/plasmaSearchImages.java b/source/de/anomic/plasma/plasmaSearchImages.javaindex 6062b7128..129302433 100644--- a/source/de/anomic/plasma/plasmaSearchImages.java+++ b/source/de/anomic/plasma/plasmaSearchImages.java@@ -87,6 +87,7 @@ public final class plasmaSearchImages {}}}+ document.close();}}}diff --git a/source/de/anomic/plasma/plasmaSnippetCache.java b/source/de/anomic/plasma/plasmaSnippetCache.javaindex 1aa2d5b80..10e06f0bf 100644--- a/source/de/anomic/plasma/plasmaSnippetCache.java+++ b/source/de/anomic/plasma/plasmaSnippetCache.java@@ -230,6 +230,7 @@ public class plasmaSnippetCache {//System.out.println("loaded document for URL " + url);String[] sentences = document.getSentences();+ document.close();//System.out.println("----" + url.toString()); for (int l = 0; l < sentences.length; l++) System.out.println(sentences[l]);if ((sentences == null) || (sentences.length == 0)) {//System.out.println("found no sentences in url " + url);diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.javaindex 4d37c31b7..36a46567e 100644--- a/source/de/anomic/plasma/plasmaSwitchboard.java+++ b/source/de/anomic/plasma/plasmaSwitchboard.java@@ -1465,6 +1465,10 @@ public final class plasmaSwitchboard extends serverAbstractSwitch implements ser} catch (ParserException e) {this.log.logInfo("Unable to parse the resource '" + entry.url() + "'. " + e.getMessage());addURLtoErrorDB(entry.url(), entry.referrerHash(), initiatorPeerHash, entry.anchorName(), e.getErrorCode(), new bitfield(indexURL.urlFlagLength));+ if (document != null) {+ document.close();+ document = null;+ }return;}