pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jahew...@apache.org
Subject svn commit: r1697483 - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/cos/COSInputStream.java test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Date Mon, 24 Aug 2015 19:15:52 GMT
Author: jahewson
Date: Mon Aug 24 19:15:52 2015
New Revision: 1697483

URL: http://svn.apache.org/r1697483
Log:
PDFBOX-2893: Close scratch buffer after it has been read

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInputStream.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInputStream.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInputStream.java?rev=1697483&r1=1697482&r2=1697483&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInputStream.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/cos/COSInputStream.java Mon Aug 24
19:15:52 2015
@@ -65,11 +65,17 @@ public final class COSInputStream extend
                 if (scratchFile != null)
                 {
                     // scratch file
-                    RandomAccess buffer = scratchFile.createBuffer();
+                    final RandomAccess buffer = scratchFile.createBuffer();
                     DecodeResult result = filters.get(i).decode(input, new RandomAccessOutputStream(buffer),
parameters, i);
                     results.add(result);
-                    input = new RandomAccessInputStream(buffer);
-                    buffer.close();
+                    input = new RandomAccessInputStream(buffer)
+                    {
+                        @Override
+                        public void close() throws IOException
+                        {
+                            buffer.close();
+                        }
+                    };
                 }
                 else
                 {

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java?rev=1697483&r1=1697482&r2=1697483&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
(original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/multipdf/PDFMergerUtilityTest.java
Mon Aug 24 19:15:52 2015
@@ -70,6 +70,21 @@ public class PDFMergerUtilityTest extend
                 true);
     }
 
+    // see PDFBOX-2893
+    public void testPDFMergerUtility2() throws IOException
+    {
+        checkMergeIdentical("PDFBox.GlobalResourceMergeTest.Doc01.pdf",
+                "PDFBox.GlobalResourceMergeTest.Doc02.pdf",
+                "GlobalResourceMergeTestResult.pdf",
+                false);
+
+        // once again, with scratch file
+        checkMergeIdentical("PDFBox.GlobalResourceMergeTest.Doc01.pdf",
+                "PDFBox.GlobalResourceMergeTest.Doc02.pdf",
+                "GlobalResourceMergeTestResult2.pdf",
+                true);
+    }
+
     // checks that the result file of a merge has the same rendering as the two
     // source files
     private void checkMergeIdentical(String filename1, String filename2, String mergeFilename,




Mime
View raw message