From 4320f69574c7eed541c8bd2a17f7a3880f78b5b7 Mon Sep 17 00:00:00 2001 From: lotus Date: Sun, 5 Jul 2009 08:12:14 +0000 Subject: [PATCH] universal handling for crashed parsers reverting r6090/1 git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@6176 6c8d7289-2bf4-0310-a012-ef5d649a1542 --- source/de/anomic/plasma/parser/pdf/pdfParser.java | 4 ++-- source/de/anomic/plasma/parser/swf/swfParser.java | 11 +---------- source/de/anomic/plasma/plasmaSwitchboard.java | 7 ++++++- 3 files changed, 9 insertions(+), 13 deletions(-) diff --git a/source/de/anomic/plasma/parser/pdf/pdfParser.java b/source/de/anomic/plasma/parser/pdf/pdfParser.java index ebe3c92cc..b0693beea 100644 --- a/source/de/anomic/plasma/parser/pdf/pdfParser.java +++ b/source/de/anomic/plasma/parser/pdf/pdfParser.java @@ -76,7 +76,6 @@ public class pdfParser extends AbstractParser implements Parser { public plasmaParserDocument parse(final yacyURL location, final String mimeType, final String charset, final InputStream source) throws ParserException, InterruptedException { PDDocument theDocument = null; - plasmaParserDocument theDoc = null; Writer writer = null; File writerFile = null; try { @@ -136,6 +135,8 @@ public class pdfParser extends AbstractParser implements Parser { String[] docKeywords = null; if (docKeywordStr != null) docKeywords = docKeywordStr.split(" |,"); + plasmaParserDocument theDoc = null; + if (writer instanceof serverCharBuffer) { final byte[] contentBytes = ((serverCharBuffer)writer).toString().getBytes("UTF-8"); theDoc = new plasmaParserDocument( @@ -186,7 +187,6 @@ public class pdfParser extends AbstractParser implements Parser { if (theDocument != null) try { theDocument.close(); } catch (final Exception e) {/* ignore this */} if (writer != null) try { writer.close(); } catch (final Exception e) {/* ignore this */} Thread.currentThread().setPriority(Thread.NORM_PRIORITY); - if (theDoc == null) throw new ParserException("Unexpected error while parsing pdf file. possibly out of memory",location); } } diff --git a/source/de/anomic/plasma/parser/swf/swfParser.java b/source/de/anomic/plasma/parser/swf/swfParser.java index 1f275a607..cfc4765bf 100644 --- a/source/de/anomic/plasma/parser/swf/swfParser.java +++ b/source/de/anomic/plasma/parser/swf/swfParser.java @@ -75,8 +75,6 @@ public class swfParser extends AbstractParser implements Parser { */ public plasmaParserDocument parse(final yacyURL location, final String mimeType, final String charset, final InputStream source) throws ParserException, InterruptedException { - plasmaParserDocument theDoc = null; - try { final SWF2HTML swf2html = new SWF2HTML(); String contents = ""; @@ -114,7 +112,7 @@ public class swfParser extends AbstractParser implements Parser { } // As the result of parsing this function must return a plasmaParserDocument object - theDoc = new plasmaParserDocument( + final plasmaParserDocument theDoc = new plasmaParserDocument( location, // url of the source document mimeType, // the documents mime type "UTF-8", // charset of the document text @@ -139,13 +137,6 @@ public class swfParser extends AbstractParser implements Parser { final String errorMsg = "Unable to parse the swf document '" + location + "':" + e.getMessage(); this.theLogger.logSevere(errorMsg); throw new ParserException(errorMsg, location); - } finally { - if (theDoc == null) { - // if an unexpected error occures just log the error and raise a new ParserException - final String errorMsg = "Unable to parse the swf document '" + location + "': possibly out of memory"; - this.theLogger.logSevere(errorMsg); - throw new ParserException(errorMsg, location); - } } } diff --git a/source/de/anomic/plasma/plasmaSwitchboard.java b/source/de/anomic/plasma/plasmaSwitchboard.java index 325d0c99f..f78d41735 100644 --- a/source/de/anomic/plasma/plasmaSwitchboard.java +++ b/source/de/anomic/plasma/plasmaSwitchboard.java @@ -1693,7 +1693,6 @@ public final class plasmaSwitchboard extends serverAbstractSwitch