You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@poi.apache.org by fa...@apache.org on 2025/03/25 16:08:59 UTC

svn commit: r1924593 - in /poi/trunk: poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java poi/src/main/java/org/apache/poi/util/IOUtils.java

Author: fanningpj
Date: Tue Mar 25 16:08:59 2025
New Revision: 1924593

URL: http://svn.apache.org/viewvc?rev=1924593&view=rev
Log:
[bug-69628] make ZipArchiveFakeEntry.setMaxEntrySize publicly accessible

Modified:
    poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
    poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java

Modified: poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java?rev=1924593&r1=1924592&r2=1924593&view=diff
==============================================================================
--- poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java (original)
+++ poi/trunk/poi-ooxml/src/main/java/org/apache/poi/openxml4j/util/ZipArchiveFakeEntry.java Tue Mar 25 16:08:59 2025
@@ -35,7 +35,7 @@ import org.apache.poi.util.TempFile;
  *  close this as soon as you can!
  * @see ZipInputStreamZipEntrySource#setThresholdBytesForTempFiles(int)
  */
-/* package */ class ZipArchiveFakeEntry extends ZipArchiveEntry implements Closeable {
+public final class ZipArchiveFakeEntry extends ZipArchiveEntry implements Closeable {
     private static final Logger LOG = PoiLogManager.getLogger(ZipArchiveFakeEntry.class);
 
     // how large a single entry in a zip-file should become at max

Modified: poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java?rev=1924593&r1=1924592&r2=1924593&view=diff
==============================================================================
--- poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java (original)
+++ poi/trunk/poi/src/main/java/org/apache/poi/util/IOUtils.java Tue Mar 25 16:08:59 2025
@@ -209,6 +209,27 @@ public final class IOUtils {
     }
 
     /**
+     * Reads up to {@code length} bytes from the input stream, and returns the bytes read.
+     *
+     * @param stream The byte stream of data to read.
+     * @param length The maximum length to read, use {@link Integer#MAX_VALUE} to read the stream
+     *               until EOF
+     * @param maxLength if the input is equal to/longer than {@code maxLength} bytes,
+     *                  then throw an {@link IOException} complaining about the length.
+     *                  use {@link Integer#MAX_VALUE} to disable the check - if {@link #setByteArrayMaxOverride(int)} is
+     *                  set then that max of that value and this maxLength is used
+     * @return A byte array with the read bytes.
+     * @throws IOException If reading data fails or EOF is encountered too early for the given length.
+     * @throws RecordFormatException If the requested length is invalid.
+     * @since POI 5.4.1
+     */
+    public static byte[] toByteArray(InputStream stream, final long length, final int maxLength) throws IOException {
+        return toByteArray(stream,
+                length > Integer.MAX_VALUE ? Integer.MAX_VALUE : (int) length,
+                maxLength, true, length != Integer.MAX_VALUE);
+    }
+
+    /**
      * Reads the input stream, and returns the bytes read.
      *
      * @param stream The byte stream of data to read.



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org