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

ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-compress.git

commit bb6e97815cf8d4bf30be7c65490bdbba766d8889
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Wed Aug 27 11:33:58 2025 -0400

    Internal refactoring
---
 .../java/org/apache/commons/compress/MemoryLimitException.java | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git 
a/src/main/java/org/apache/commons/compress/MemoryLimitException.java 
b/src/main/java/org/apache/commons/compress/MemoryLimitException.java
index b84b5e7e4..10c5a9d4b 100644
--- a/src/main/java/org/apache/commons/compress/MemoryLimitException.java
+++ b/src/main/java/org/apache/commons/compress/MemoryLimitException.java
@@ -59,7 +59,7 @@ private static void check(final long request, final long max, 
final String scale
      * @since 1.29.0
      */
     public static int checkBytes(final int request, final long max) throws 
MemoryLimitException {
-        check(request, max, Runtime.getRuntime().maxMemory(), "max memory", 
BYTES);
+        check(request, max, maxMemory(), "max memory", BYTES);
         return request;
     }
 
@@ -73,7 +73,7 @@ public static int checkBytes(final int request, final long 
max) throws MemoryLim
      * @since 1.29.0
      */
     public static long checkBytes(final long request, final long max) throws 
MemoryLimitException {
-        check(request, max, Runtime.getRuntime().maxMemory(), "max memory", 
BYTES);
+        check(request, max, maxMemory(), "max memory", BYTES);
         return request;
     }
 
@@ -87,7 +87,11 @@ public static long checkBytes(final long request, final long 
max) throws MemoryL
      * @since 1.29.0
      */
     public static long checkKiB(final long request, final long max) throws 
MemoryLimitException {
-        return check(request, max, Runtime.getRuntime().maxMemory() / 1024, 
"max memory", KIB);
+        return check(request, max, maxMemory() / 1024, "max memory", KIB);
+    }
+
+    private static long maxMemory() {
+        return Runtime.getRuntime().maxMemory();
     }
 
     /** A long instead of int to account for overflow in corrupt files. */

Reply via email to