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 449564915fcf740f88e6d49cdd5b0dcf96e083fe Author: Gary Gregory <[email protected]> AuthorDate: Sun Dec 21 17:43:21 2025 -0500 Add UnsupportedZipFeatureException.Feature.toString() - Add other Javadoc --- .../zip/UnsupportedZipFeatureException.java | 23 +++++++++++++++++++++- .../archivers/zip/EncryptedArchiveTest.java | 6 +++--- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java index 791bb6369..e6db674fd 100644 --- a/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java +++ b/src/main/java/org/apache/commons/compress/archivers/zip/UnsupportedZipFeatureException.java @@ -63,21 +63,42 @@ public static class Feature implements Serializable { */ public static final Feature UNKNOWN_COMPRESSED_SIZE = new Feature("unknown compressed size"); + /** + * The name of the feature. + */ private final String name; + /** + * Constructs a new feature with the given name. + * + * @param name the name of the feature + */ private Feature(final String name) { this.name = name; } + /** + * {@inheritDoc} + * + * @since 1.29.0 + */ @Override public String toString() { - return name; + return super.toString() + "[" + name + "]"; } + } private static final long serialVersionUID = 20161219L; + + /** + * The unsupported feature. + */ private final Feature reason; + /** + * The entry that uses the unsupported feature. + */ private final transient ZipArchiveEntry entry; /** diff --git a/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java b/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java index 9fb7b9aad..0acdc99d2 100644 --- a/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java +++ b/src/test/java/org/apache/commons/compress/archivers/zip/EncryptedArchiveTest.java @@ -34,9 +34,7 @@ class EncryptedArchiveTest { @Test void testReadPasswordEncryptedEntryViaStream() throws IOException { - try (ZipArchiveInputStream zin = ZipArchiveInputStream.builder() - .setURI(getURI("password-encrypted.zip")) - .get()) { + try (ZipArchiveInputStream zin = ZipArchiveInputStream.builder().setURI(getURI("password-encrypted.zip")).get()) { final ZipArchiveEntry zae = zin.getNextZipEntry(); assertEquals("LICENSE.txt", zae.getName()); assertTrue(zae.getGeneralPurposeBit().usesEncryption()); @@ -47,6 +45,7 @@ void testReadPasswordEncryptedEntryViaStream() throws IOException { zin.read(buf, 0, buf.length); }, "expected an exception"); assertSame(UnsupportedZipFeatureException.Feature.ENCRYPTION, ex.getFeature()); + assertTrue(ex.getFeature().toString().contains("encryption")); } } @@ -59,6 +58,7 @@ void testReadPasswordEncryptedEntryViaZipFile() throws IOException { assertFalse(zf.canReadEntryData(zae)); final UnsupportedZipFeatureException ex = assertThrows(UnsupportedZipFeatureException.class, () -> zf.getInputStream(zae), "expected an exception"); assertSame(UnsupportedZipFeatureException.Feature.ENCRYPTION, ex.getFeature()); + assertTrue(ex.getFeature().toString().contains("encryption")); } } }
