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 46f7bd8efdb8f120d621cdef0ed43e3c777c65a4 Author: Gary Gregory <garydgreg...@gmail.com> AuthorDate: Tue Nov 26 10:40:59 2024 -0500 ZipEightByteInteger.toString() now returns a number string without text prefix, like BigInteger --- src/changes/changes.xml | 3 ++- .../apache/commons/compress/archivers/zip/ZipEightByteInteger.java | 4 ++-- .../commons/compress/archivers/zip/ZipEightByteIntegerTest.java | 5 ++++- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 696f56aae..a8af8751e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -52,7 +52,8 @@ The <action> type attribute can be add,update,fix,remove. <action type="fix" dev="ggregory" due-to="Gary Gregory, Arturo Bernal">CompressorException extends IOException #605, see also https://github.com/apache/httpcomponents-client/pull/580.</action> <action type="fix" dev="ggregory" due-to="Glavo">Update outdated descriptions in IOUtils and IOUtilsTest #612.</action> <action type="fix" dev="ggregory" due-to="Glavo">Remove unused local variable in ZipFile #615.</action> - <action type="fix" dev="ggregory" due-to="Glavo, Gary Gregory">Optimize ZipEightByteInteger #614.</action> + <action type="fix" dev="ggregory" due-to="Glavo, Gary Gregory">Optimize ZipEightByteInteger #614.</action> + <action type="fix" dev="ggregory" due-to="Gary Gregory">ZipEightByteInteger.toString() now returns a number string without text prefix, like BigInteger.</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/zip/ZipEightByteInteger.java b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java index 0e205e49b..63562b03a 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/ZipEightByteInteger.java @@ -30,7 +30,7 @@ import java.nio.ByteOrder; */ public final class ZipEightByteInteger implements Serializable { - private static final int BYTES = 8; + static final int BYTES = 8; private static final long serialVersionUID = 1L; @@ -204,6 +204,6 @@ public final class ZipEightByteInteger implements Serializable { @Override public String toString() { - return "ZipEightByteInteger value: " + Long.toUnsignedString(value); + return Long.toUnsignedString(value); } } diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java index 41d531660..83a686695 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/ZipEightByteIntegerTest.java @@ -149,7 +149,10 @@ public class ZipEightByteIntegerTest { */ @Test public void testToString() { - assertEquals("ZipEightByteInteger value: 18446744073709551615", newMaxValue().toString()); + assertEquals("0", ZipEightByteInteger.ZERO.toString()); + assertEquals("0", ZipEightByteInteger.getValue(new byte[ZipEightByteInteger.BYTES]).toString()); + assertEquals(Long.toString(Long.MAX_VALUE), new ZipEightByteInteger(BigInteger.valueOf(Long.MAX_VALUE)).toString()); + assertEquals("18446744073709551615", newMaxValue().toString()); } /**