You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2025/08/02 10:56:58 UTC

(commons-compress) branch master updated (d999990ff -> f58f37594)

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

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


    from d999990ff Sort members
     new 30e33f680 Fix parameter name
     new f58f37594 Fix kilobyte to kibibyte conversion

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 src/changes/changes.xml                               |  3 +++
 .../commons/compress/archivers/sevenz/SevenZFile.java | 19 +++++++++++++------
 2 files changed, 16 insertions(+), 6 deletions(-)


(commons-compress) 02/02: Fix kilobyte to kibibyte conversion

Posted by gg...@apache.org.
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 f58f3759492981a46bea4d2631c23d16734346ca
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 2 06:56:52 2025 -0400

    Fix kilobyte to kibibyte conversion
    
    - Fix kilobyte to kibibyte conversion in
    org.apache.commons.compress.archivers.sevenz.SevenZFile.ArchiveStatistics.assertValidity(int)
    - Fix kilobyte to kibibyte conversion in
    org.apache.commons.compress.archivers.sevenz.SevenZFile.ArchiveStatistics.toString()
    - Fix kilobyte to kibibyte conversion in
    org.apache.commons.compress.archivers.sevenz.SevenZFile.Builder.setMaxMemoryLimitKb(int)
---
 src/changes/changes.xml                                    |  3 +++
 .../commons/compress/archivers/sevenz/SevenZFile.java      | 14 +++++++++++---
 2 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index c5c437178..b163847f4 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -46,6 +46,9 @@ The <action> type attribute can be add,update,fix,remove.
       <!-- FIX -->
       <action type="fix" dev="ggregory" due-to="Piotr P. Karwasz, Gary Gregory">Add missing Javadoc @since tag to org.apache.commons.compress.compressors.lz77support.LZ77Compressor.AbstractReference.</action>
       <action type="fix" issue="COMPRESS-702" dev="ggregory" due-to="Zhang Di, Lastoneee">Performance issue in SevenZFile #681.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix kilobyte to kibibyte conversion in org.apache.commons.compress.archivers.sevenz.SevenZFile.ArchiveStatistics.assertValidity(int).</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix kilobyte to kibibyte conversion in org.apache.commons.compress.archivers.sevenz.SevenZFile.ArchiveStatistics.toString().</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix kilobyte to kibibyte conversion in org.apache.commons.compress.archivers.sevenz.SevenZFile.Builder.setMaxMemoryLimitKb(int).</action>
       <!-- ADD -->
       <!-- UPDATE -->
     </release>
diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index c29771348..9865db0b9 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -110,7 +110,7 @@ void assertValidity(final int maxMemoryLimitKiB) throws IOException {
             if (numberOfEntriesWithStream > numberOfUnpackSubStreams) {
                 throw new IOException("archive doesn't contain enough substreams for entries");
             }
-            final long memoryNeededInKiB = estimateSize() / 1024;
+            final long memoryNeededInKiB = kbToKiB(estimateSize());
             if (maxMemoryLimitKiB < memoryNeededInKiB) {
                 throw new MemoryLimitException(memoryNeededInKiB, maxMemoryLimitKiB);
             }
@@ -171,7 +171,7 @@ private long streamMapSize() {
 
         @Override
         public String toString() {
-            return String.format("Archive with %,d entries in %,d folders, estimated size %,d KiB.", numberOfEntries, numberOfFolders, estimateSize() / 1024L);
+            return String.format("Archive with %,d entries in %,d folders, estimated size %,d KiB.", numberOfEntries, numberOfFolders, kbToKiB(estimateSize()));
         }
     }
 
@@ -239,7 +239,7 @@ public Builder setDefaultName(final String defaultName) {
          * @return {@code this} instance.
          */
         public Builder setMaxMemoryLimitKb(final int maxMemoryLimitKb) {
-            this.maxMemoryLimitKiB = maxMemoryLimitKb / 1024;
+            this.maxMemoryLimitKiB = kbToKiB(maxMemoryLimitKb);
             return this;
         }
 
@@ -387,6 +387,14 @@ private static int getUnsignedByte(final ByteBuffer buf) throws EOFException {
         return buf.get() & 0xff;
     }
 
+    private static int kbToKiB(final int kilobytes) {
+        return kilobytes * 1000 / 1024;
+    }
+
+    private static long kbToKiB(final long kilobytes) {
+        return kilobytes * 1000 / 1024;
+    }
+
     /**
      * Checks if the signature matches what is expected for a 7z file.
      *


(commons-compress) 01/02: Fix parameter name

Posted by gg...@apache.org.
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 30e33f680f7a26cc614c72609095c3914bc61060
Author: Gary D. Gregory <ga...@gmail.com>
AuthorDate: Sat Aug 2 06:41:15 2025 -0400

    Fix parameter name
---
 .../org/apache/commons/compress/archivers/sevenz/SevenZFile.java   | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
index db61cb3ce..c29771348 100644
--- a/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
+++ b/src/main/java/org/apache/commons/compress/archivers/sevenz/SevenZFile.java
@@ -235,11 +235,11 @@ public Builder setDefaultName(final String defaultName) {
          * Not all codecs honor this setting. Currently only LZMA and LZMA2 are supported.
          * </p>
          *
-         * @param maxMemoryLimitKiB the max memory limit in kilobytes.
+         * @param maxMemoryLimitKb the max memory limit in kilobytes.
          * @return {@code this} instance.
          */
-        public Builder setMaxMemoryLimitKb(final int maxMemoryLimitKiB) {
-            this.maxMemoryLimitKiB = maxMemoryLimitKiB / 1024;
+        public Builder setMaxMemoryLimitKb(final int maxMemoryLimitKb) {
+            this.maxMemoryLimitKiB = maxMemoryLimitKb / 1024;
             return this;
         }
 
@@ -452,7 +452,6 @@ private static long skipBytesFully(final ByteBuffer input, long bytesToSkip) {
     private final ArrayList<InputStream> deferredBlockStreams = new ArrayList<>();
     private final int maxMemoryLimitKiB;
     private final boolean useDefaultNameForUnnamedEntries;
-
     private final boolean tryToRecoverBrokenArchives;
 
     /**