*) Bugfix. Add missing plasmaParserDocument.close() calls

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2680 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
theli 18 years ago
parent cd5f349666
commit a2e3095044

@ -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 database
prop.put("mode_edit", 1); // edit mode

@ -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>");

@ -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());

@ -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();
}
}
}

@ -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();

@ -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 file
if ((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;
}
}
}

@ -87,6 +87,7 @@ public final class plasmaSearchImages {
}
}
}
document.close();
}
}
}

@ -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);

@ -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;
}

Loading…
Cancel
Save