This is an automated email from the ASF dual-hosted git repository.

pjfanning pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/poi.git


The following commit(s) were added to refs/heads/trunk by this push:
     new ec22f33563 javadoc
ec22f33563 is described below

commit ec22f335638aa50f9ce40c3972badf91ba4c9361
Author: PJ Fanning <[email protected]>
AuthorDate: Thu Jun 4 13:20:09 2026 +0100

    javadoc
---
 poi/src/main/java/org/apache/poi/util/ArrayUtil.java | 12 ++++++++++++
 poi/src/main/java/org/apache/poi/util/IOUtils.java   | 18 ++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/poi/src/main/java/org/apache/poi/util/ArrayUtil.java 
b/poi/src/main/java/org/apache/poi/util/ArrayUtil.java
index 54f88bd492..504b80e625 100644
--- a/poi/src/main/java/org/apache/poi/util/ArrayUtil.java
+++ b/poi/src/main/java/org/apache/poi/util/ArrayUtil.java
@@ -83,6 +83,18 @@ public final class ArrayUtil {
         // We're done - array will now have everything moved as required
     }
 
+    /**
+     * This method is targeted at doing length checks for generic array 
creations.
+     * {@link IOUtils#safelyAllocateCheck(long, int, String)} is aimed at byte 
array based
+     * checks (or equivalents streams of bytes). Arrays of object instances 
will take up
+     * a lot more memory than the same number of bytes. So the limits applied 
in ArrayUtil
+     * are intended to be a lot lower than the IOUtil ones.
+     *
+     * @param length
+     * @param maxLength
+     * @param limitMethod name of method that can be used to change the limit
+     * @throws RecordFormatException if the length is negative or too long
+     */
     public static void safelyAllocateCheck(long length, int maxLength, String 
limitMethod) {
         if (length < 0L) {
             throw new RecordFormatException("Can't allocate an array of length 
< 0, but had " + length + " and " + maxLength);
diff --git a/poi/src/main/java/org/apache/poi/util/IOUtils.java 
b/poi/src/main/java/org/apache/poi/util/IOUtils.java
index 01e758fdbf..bc36232251 100644
--- a/poi/src/main/java/org/apache/poi/util/IOUtils.java
+++ b/poi/src/main/java/org/apache/poi/util/IOUtils.java
@@ -605,6 +605,13 @@ public final class IOUtils {
         }
     }
 
+    /**
+     * This method is targeted at byte array based checks (or equivalents 
streams of bytes).
+     * Arrays of object instances will take up a lot more memory than the same 
number of bytes.
+     * So we have {@link ArrayUtil#safelyAllocateCheck(long, int, String)} for 
generic array creations
+     * and the limits applied in ArrayUtil are intended to be a lot lower than 
the IOUtil ones.
+     * @throws RecordFormatException if the length is negative or too long
+     */
     public static void safelyAllocateCheck(long length, int maxLength) {
         if (length < 0L) {
             throw new RecordFormatException("Can't allocate an array of length 
< 0, but had " + length + " and " + maxLength);
@@ -615,6 +622,17 @@ public final class IOUtils {
         checkLength(length, maxLength);
     }
 
+    /**
+     * This method is targeted at byte array based checks (or equivalents 
streams of bytes).
+     * Arrays of object instances will take up a lot more memory than the same 
number of bytes.
+     * So we have {@link ArrayUtil#safelyAllocateCheck(long, int, String)} for 
generic array creations
+     * and the limits applied in ArrayUtil are intended to be a lot lower than 
the IOUtil ones.
+     *
+     * @param length
+     * @param maxLength
+     * @param limitMethod name of method that can be used to change the limit
+     * @throws RecordFormatException if the length is negative or too long
+     */
     public static void safelyAllocateCheck(long length, int maxLength, String 
limitMethod) {
         if (length < 0L) {
             throw new RecordFormatException("Can't allocate an array of length 
< 0, but had " + length + " and " + maxLength);


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to