diff --git a/src/changes/changes.xml b/src/changes/changes.xml index 696f56aaeb5..a8af8751e9e 100644 --- a/src/changes/changes.xml +++ b/src/changes/changes.xml @@ -52,7 +52,8 @@ The type attribute can be add,update,fix,remove. CompressorException extends IOException #605, see also https://github.com/apache/httpcomponents-client/pull/580. Update outdated descriptions in IOUtils and IOUtilsTest #612. Remove unused local variable in ZipFile #615. - Optimize ZipEightByteInteger #614. + Optimize ZipEightByteInteger #614. + ZipEightByteInteger.toString() now returns a number string without text prefix, like BigInteger. Add GzipParameters.getModificationInstant(). Add GzipParameters.setModificationInstant(Instant). 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 0e205e49bde..63562b03af9 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 @@ */ 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 int hashCode() { @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 41d531660d7..83a686695a3 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 void testSign() { */ @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()); } /**