jackrabbit-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mreut...@apache.org
Subject svn commit: r495663 - /jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java
Date Fri, 12 Jan 2007 17:55:58 GMT
Author: mreutegg
Date: Fri Jan 12 09:55:58 2007
New Revision: 495663

URL: http://svn.apache.org/viewvc?view=rev&rev=495663
Log:
JCR-705: PdfTextExtractor does not close temp file in case of an error

Modified:
    jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java

Modified: jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java
URL: http://svn.apache.org/viewvc/jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java?view=diff&rev=495663&r1=495662&r2=495663
==============================================================================
--- jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java
(original)
+++ jackrabbit/trunk/jackrabbit-text-extractors/src/main/java/org/apache/jackrabbit/extractor/PdfTextExtractor.java
Fri Jan 12 09:55:58 2007
@@ -57,10 +57,9 @@
                               String encoding) throws IOException {
         try {
             PDFParser parser = new PDFParser(new BufferedInputStream(stream));
-            parser.parse();
-
-            PDDocument document = parser.getPDDocument();
             try {
+                parser.parse();
+                PDDocument document = parser.getPDDocument();
                 CharArrayWriter writer = new CharArrayWriter();
 
                 PDFTextStripper stripper = new PDFTextStripper();
@@ -69,7 +68,10 @@
 
                 return new CharArrayReader(writer.toCharArray());
             } finally {
-                document.close();
+                PDDocument doc = parser.getPDDocument();
+                if (doc != null) {
+                    doc.close();
+                }
             }
         } catch (Exception e) {
             // it may happen that PDFParser throws a runtime



Mime
View raw message