You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pdfbox.apache.org by le...@apache.org on 2024/08/01 05:37:22 UTC

svn commit: r1919610 - /pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java

Author: lehmi
Date: Thu Aug  1 05:37:22 2024
New Revision: 1919610

URL: http://svn.apache.org/viewvc?rev=1919610&view=rev
Log:
PDFBOX-5675: never re-thrown a DataFormatException, simply use the already read data or an empty stream

Modified:
    pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java

Modified: pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java
URL: http://svn.apache.org/viewvc/pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java?rev=1919610&r1=1919609&r2=1919610&view=diff
==============================================================================
--- pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java (original)
+++ pdfbox/branches/3.0/pdfbox/src/main/java/org/apache/pdfbox/filter/FlateFilterDecoderStream.java Thu Aug  1 05:37:22 2024
@@ -44,7 +44,6 @@ public final class FlateFilterDecoderStr
     private byte[] decodedData = new byte[4096];
     // use nowrap mode to bypass zlib-header and checksum to avoid a DataFormatException
     private final Inflater inflater = new Inflater(true);
-    private boolean dataDecoded = false;
 
     /**
      * Constructor.
@@ -84,22 +83,14 @@ public final class FlateFilterDecoderStr
         try
         {
             bytesDecoded = inflater.inflate(decodedData);
-            dataDecoded |= bytesDecoded > 0;
         }
         catch (DataFormatException exception)
         {
             isEOF = true;
-            if (dataDecoded)
-            {
-                // some data could be decoded -> don't throw an exception
-                LOG.warn("FlateFilter: premature end of stream due to a DataFormatException");
-                return false;
-            }
-            else
-            {
-                // nothing could be read -> re-throw exception wrapped in an IOException
-                throw new IOException(exception);
-            }
+            // don't throw an exception, use the already read data or an empty stream
+            LOG.warn("FlateFilter: premature end of stream due to a DataFormatException = "
+                    + exception.getMessage());
+            return false;
         }
         return true;
     }