Author: ozeigermann Date: Mon Jun 25 05:18:05 2007 New Revision: 550467 URL: http://svn.apache.org/viewvc?view=rev&rev=550467 Log: PDFDocument will be closed now even in case of an error
Modified: jakarta/slide/trunk/src/share/org/apache/slide/extractor/PDFExtractor.java Modified: jakarta/slide/trunk/src/share/org/apache/slide/extractor/PDFExtractor.java URL: http://svn.apache.org/viewvc/jakarta/slide/trunk/src/share/org/apache/slide/extractor/PDFExtractor.java?view=diff&rev=550467&r1=550466&r2=550467 ============================================================================== --- jakarta/slide/trunk/src/share/org/apache/slide/extractor/PDFExtractor.java (original) +++ jakarta/slide/trunk/src/share/org/apache/slide/extractor/PDFExtractor.java Mon Jun 25 05:18:05 2007 @@ -26,6 +26,7 @@ import java.io.CharArrayReader; import java.io.CharArrayWriter; import java.io.FileInputStream; +import java.io.IOException; import java.io.InputStream; import java.io.Reader; @@ -50,12 +51,13 @@ public Reader extract(InputStream content) throws ExtractorException { + PDDocument document = null; try { PDFParser parser = new PDFParser( content ); parser.parse(); - PDDocument document = parser.getPDDocument(); + document = parser.getPDDocument(); CharArrayWriter writer = new CharArrayWriter(); @@ -63,7 +65,6 @@ stripper.setLineSeparator("\n"); stripper.writeText(document, writer); - document.close(); writer.close(); return new CharArrayReader(writer.toCharArray()); @@ -71,7 +72,15 @@ catch(Exception e ) { throw new ExtractorException(e.getMessage()); + } finally { + try { + if (document != null) + document.close(); + } catch (IOException e) { + throw new ExtractorException(e.getMessage()); + } } + } public static void main(String[] args) throws Exception --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]