pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From le...@apache.org
Subject svn commit: r1687905 - in /pdfbox/trunk/pdfbox/src: main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java
Date Sat, 27 Jun 2015 10:33:51 GMT
Author: lehmi
Date: Sat Jun 27 10:33:50 2015
New Revision: 1687905

URL: http://svn.apache.org/r1687905
Log:
PDFBOX-2301: handle empty buffers within SequenceRandomAccessRead

Modified:
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java
    pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
    pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java?rev=1687905&r1=1687904&r2=1687905&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java (original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/io/SequenceRandomAccessRead.java Sat
Jun 27 10:33:50 2015
@@ -92,6 +92,11 @@ public class SequenceRandomAccessRead im
         if (currentIndex < maxIndex)
         {
             switchBuffer(currentIndex + 1);
+            // skip empty buffers
+            if (currentBufferLength == 0)
+            {
+                return nextBuffer();
+            }
             return true;
         }
         return false;

Modified: pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java?rev=1687905&r1=1687904&r2=1687905&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
(original)
+++ pdfbox/trunk/pdfbox/src/main/java/org/apache/pdfbox/pdmodel/common/COSStreamArray.java
Sat Jun 27 10:33:50 2015
@@ -174,17 +174,12 @@ public class COSStreamArray extends COSS
         for( int i=0;i<streams.size(); i++ )
         {
             COSStream stream = (COSStream)streams.getObject( i );
-            RandomAccessRead randomAccess = stream.getUnfilteredRandomAccess();
-            // omit empty streams
-            if (randomAccess.length() > 0)
-            {
-                input.add( randomAccess );
-                //handle the case where there is no whitespace in the
-                //between streams in the contents array, without this
-                //it is possible that two operators will get concatenated
-                //together
-                input.add( new RandomAccessBuffer( inbetweenStreamBytes ) );
-            }
+            input.add( stream.getUnfilteredRandomAccess() );
+            //handle the case where there is no whitespace in the
+            //between streams in the contents array, without this
+            //it is possible that two operators will get concatenated
+            //together
+            input.add( new RandomAccessBuffer( inbetweenStreamBytes ) );
         }
         return new SequenceRandomAccessRead(input);
     }

Modified: pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java?rev=1687905&r1=1687904&r2=1687905&view=diff
==============================================================================
--- pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java (original)
+++ pdfbox/trunk/pdfbox/src/test/java/org/apache/pdfbox/io/TestRandomAccessBuffer.java Sat
Jun 27 10:33:50 2015
@@ -18,6 +18,7 @@
 package org.apache.pdfbox.io;
 
 import java.io.IOException;
+import java.nio.Buffer;
 import java.util.Vector;
 
 import junit.framework.TestCase;
@@ -294,8 +295,10 @@ public class TestRandomAccessBuffer exte
         buffer3.write(new byte[] {5,6,7});
         RandomAccessBuffer buffer4 = new RandomAccessBuffer();
         buffer4.write(new byte[] {8,9,10,11,12});
+        RandomAccessBuffer bufferEmpty = new RandomAccessBuffer();
         Vector<RandomAccessRead> buffers = new Vector<RandomAccessRead>();
         buffers.add(buffer1);
+        buffers.add(bufferEmpty);
         buffers.add(buffer2);
         buffers.add(buffer3);
         buffers.add(buffer4);
@@ -311,6 +314,7 @@ public class TestRandomAccessBuffer exte
         sequenceBuffer.close();
         buffers = new Vector<RandomAccessRead>();
         buffers.add(buffer1);
+        buffers.add(bufferEmpty);
         buffers.add(buffer2);
         buffers.add(buffer3);
         buffers.add(buffer4);
@@ -348,6 +352,7 @@ public class TestRandomAccessBuffer exte
         buffer2.close();
         buffer3.close();
         buffer4.close();
+        bufferEmpty.close();
     }
     
     public void testPDFBOX1490() throws Exception



Mime
View raw message