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


The following commit(s) were added to refs/heads/master by this push:
     new 445adeaed Fix Javadoc and names to reflect kibibytes scale
445adeaed is described below

commit 445adeaed1889bd0e2d74093bf55f0b0e96498a0
Author: Gary D. Gregory <garydgreg...@gmail.com>
AuthorDate: Sat Jan 4 09:55:16 2025 -0500

    Fix Javadoc and names to reflect kibibytes scale
---
 src/changes/changes.xml                            |  4 +++-
 .../compress/archivers/sevenz/LZMA2Decoder.java    |  6 +++---
 .../compress/compressors/lzw/LZWInputStream.java   | 22 ++++++++++++++--------
 .../compressors/z/ZCompressorInputStream.java      | 19 ++++++++++++++++---
 .../commons/compress/utils/BitInputStream.java     |  4 ++--
 5 files changed, 38 insertions(+), 17 deletions(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 32eaca06a..8bb3e72c1 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -62,7 +62,9 @@ The <action> type attribute can be add,update,fix,remove.
       <action type="fix" dev="ggregory" due-to="Gary 
Gregory">CpioArchiveInputStream.read(byte[], int, int) now throws an 
IOException on a data pad count mismatch.</action>
       <action type="fix" dev="ggregory" due-to="Gary 
Gregory">CpioArchiveInputStream.readNewEntry(boolean) now throws an IOException 
on a header pad count mismatch.</action>
       <action type="fix" dev="ggregory" due-to="Gary 
Gregory">CpioArchiveInputStream.readOldBinaryEntry(boolean) now throws an 
IOException on a header pad count mismatch.</action>
-      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc in 
org.apache.commons.compress.archivers.sevenz package to specify kibibyte scale 
in memory limits.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc and 
names in the org.apache.commons.compress.archivers.sevenz package to specify 
kibibyte scale in memory limits.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc and 
names in the org.apache.commons.compress.compressors.lzw package to specify 
kibibyte scale in memory limits.</action>
+      <action type="fix" dev="ggregory" due-to="Gary Gregory">Fix Javadoc and 
names in the org.apache.commons.compress.compressors.z package to specify 
kibibyte scale in memory limits.</action>
       <!-- ADD -->
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
GzipParameters.getModificationInstant().</action>
       <action type="add" dev="ggregory" due-to="Gary Gregory">Add 
GzipParameters.setModificationInstant(Instant).</action>
diff --git 
a/src/main/java/org/apache/commons/compress/archivers/sevenz/LZMA2Decoder.java 
b/src/main/java/org/apache/commons/compress/archivers/sevenz/LZMA2Decoder.java
index 59c595692..4056f9a4f 100644
--- 
a/src/main/java/org/apache/commons/compress/archivers/sevenz/LZMA2Decoder.java
+++ 
b/src/main/java/org/apache/commons/compress/archivers/sevenz/LZMA2Decoder.java
@@ -38,9 +38,9 @@ final class LZMA2Decoder extends AbstractCoder {
             final int maxMemoryLimitKiB) throws IOException {
         try {
             final int dictionarySize = getDictionarySize(coder);
-            final int memoryUsageInKb = 
LZMA2InputStream.getMemoryUsage(dictionarySize);
-            if (memoryUsageInKb > maxMemoryLimitKiB) {
-                throw new MemoryLimitException(memoryUsageInKb, 
maxMemoryLimitKiB);
+            final int memoryUsageInKiB = 
LZMA2InputStream.getMemoryUsage(dictionarySize);
+            if (memoryUsageInKiB > maxMemoryLimitKiB) {
+                throw new MemoryLimitException(memoryUsageInKiB, 
maxMemoryLimitKiB);
             }
             return new LZMA2InputStream(in, dictionarySize);
         } catch (final IllegalArgumentException ex) { // NOSONAR
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java 
b/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java
index 4faf364a7..0aa346854 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/lzw/LZWInputStream.java
@@ -53,6 +53,12 @@ public abstract class LZWInputStream extends 
CompressorInputStream implements In
     private byte[] outputStack;
     private int outputStackLocation;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param inputStream The underlying input stream.
+     * @param byteOrder the input byte order.
+     */
     protected LZWInputStream(final InputStream inputStream, final ByteOrder 
byteOrder) {
         this.in = new BitInputStream(inputStream, byteOrder);
     }
@@ -192,23 +198,23 @@ public abstract class LZWInputStream extends 
CompressorInputStream implements In
      * Initializes the arrays based on the maximum code size. First checks 
that the estimated memory usage is below memoryLimitInKb
      *
      * @param maxCodeSize     maximum code size
-     * @param memoryLimitInKb maximum allowed estimated memory usage in Kb
-     * @throws MemoryLimitException     if estimated memory usage is greater 
than memoryLimitInKb
+     * @param memoryLimitInKiB maximum allowed estimated memory usage in 
kibibytes.
+     * @throws MemoryLimitException     if estimated memory usage is greater 
than memoryLimitInKiB
      * @throws IllegalArgumentException if {@code maxCodeSize} is not bigger 
than 0
      */
-    protected void initializeTables(final int maxCodeSize, final int 
memoryLimitInKb) throws MemoryLimitException {
+    protected void initializeTables(final int maxCodeSize, final int 
memoryLimitInKiB) throws MemoryLimitException {
         if (maxCodeSize <= 0) {
             throw new IllegalArgumentException("maxCodeSize is " + maxCodeSize 
+ ", must be bigger than 0");
         }
 
-        if (memoryLimitInKb > -1) {
+        if (memoryLimitInKiB > -1) {
             final int maxTableSize = 1 << maxCodeSize;
             // account for potential overflow
-            final long memoryUsageInBytes = (long) maxTableSize * 6; // (4 
(prefixes) + 1 (characters) +1 (outputStack))
-            final long memoryUsageInKb = memoryUsageInBytes >> 10;
+            final long memoryUsageBytes = (long) maxTableSize * 6; // (4 
(prefixes) + 1 (characters) +1 (outputStack))
+            final long memoryUsageKiB = memoryUsageBytes >> 10;
 
-            if (memoryUsageInKb > memoryLimitInKb) {
-                throw new MemoryLimitException(memoryUsageInKb, 
memoryLimitInKb);
+            if (memoryUsageKiB > memoryLimitInKiB) {
+                throw new MemoryLimitException(memoryUsageKiB, 
memoryLimitInKiB);
             }
         }
         initializeTables(maxCodeSize);
diff --git 
a/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java
 
b/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java
index 04104261f..63ded15e1 100644
--- 
a/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java
+++ 
b/src/main/java/org/apache/commons/compress/compressors/z/ZCompressorInputStream.java
@@ -31,6 +31,7 @@ import 
org.apache.commons.compress.compressors.lzw.LZWInputStream;
  * @since 1.7
  */
 public class ZCompressorInputStream extends LZWInputStream {
+
     private static final int MAGIC_1 = 0x1f;
     private static final int MAGIC_2 = 0x9d;
     private static final int BLOCK_MODE_MASK = 0x80;
@@ -50,14 +51,26 @@ public class ZCompressorInputStream extends LZWInputStream {
 
     private final boolean blockMode;
     private final int maxCodeSize;
-
     private long totalCodesRead;
 
+    /**
+     * Constructs a new instance.
+     *
+     * @param inputStream The underlying input stream.
+     * @throws IOException if an I/O error occurs.
+     */
     public ZCompressorInputStream(final InputStream inputStream) throws 
IOException {
         this(inputStream, -1);
     }
 
-    public ZCompressorInputStream(final InputStream inputStream, final int 
memoryLimitInKb) throws IOException {
+    /**
+     * Constructs a new instance.
+     *
+     * @param inputStream The underlying input stream.
+     * @param memoryLimitInKiB maximum allowed estimated memory usage in 
kibibytes.
+     * @throws IOException if an I/O error occurs.
+     */
+    public ZCompressorInputStream(final InputStream inputStream, final int 
memoryLimitInKiB) throws IOException {
         super(inputStream, ByteOrder.LITTLE_ENDIAN);
         final int firstByte = (int) in.readBits(8);
         final int secondByte = (int) in.readBits(8);
@@ -70,7 +83,7 @@ public class ZCompressorInputStream extends LZWInputStream {
         if (blockMode) {
             setClearCode(DEFAULT_CODE_SIZE);
         }
-        initializeTables(maxCodeSize, memoryLimitInKb);
+        initializeTables(maxCodeSize, memoryLimitInKiB);
         clearEntries();
     }
 
diff --git 
a/src/main/java/org/apache/commons/compress/utils/BitInputStream.java 
b/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
index cc1f3f4c1..a71d9a58d 100644
--- a/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
+++ b/src/main/java/org/apache/commons/compress/utils/BitInputStream.java
@@ -107,7 +107,7 @@ public class BitInputStream implements Closeable {
      *
      * @param count
      * @return return true, when EOF
-     * @throws IOException
+     * @throws IOException if an I/O error occurs.
      */
     private boolean ensureCache(final int count) throws IOException {
         while (bitsCachedSize < count && bitsCachedSize < 57) {
@@ -173,7 +173,7 @@ public class BitInputStream implements Closeable {
      * @param count the number of bits to read, must be a positive number not 
bigger than 63.
      * @return the bits concatenated as a long using the stream's byte order. 
-1 if the end of the underlying stream has been reached before reading the
      *         requested number of bits
-     * @throws IOException on error
+     * @throws IOException if an I/O error occurs.
      */
     public long readBits(final int count) throws IOException {
         if (count < 0 || count > MAXIMUM_CACHE_SIZE) {

Reply via email to