On Tue, 24 Mar 2026 12:07:49 GMT, Eirik Bjørsnøs <[email protected]> wrote:

>> Please review this PR which updates the specification of 
>> `ZipOutputStream.setComment(String)` to match the long-standing behavior of 
>> throwing `IllegalArgumentException` when a comment contains characters which 
>> are unmappable using the `Charset` passed in the constructor.
>> 
>> A new tests is added to reproduce calling setComment with unmappable 
>> characters and verify that it throws IAE.
>> 
>> A CSR has been drafted. Its specification section will be updated after an 
>> initial round of review of the specification text in this PR.
>
> Eirik Bjørsnøs has updated the pull request incrementally with one additional 
> commit since the last revision:
> 
>   Lift null and empty string note into the method description

Thanks for the reviews!

Now that we converged on phrasing, should we consider including the similar 
change to `ZipEntry::setComment` with this PR/CSR, as mentioned by Lance here:

> I am wondering if we should add similar wordsmithing to ZipEntry::setComment 
> as part of this PR or in a separate PR

The null/empty string clarification in `ZipEntry::setComment` would be very 
similar to the one in `ZipOutputStream::setComment`.

Include it here or defer to a separate follup-up?

The change could look something like:


Index: src/java.base/share/classes/java/util/zip/ZipEntry.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/java.base/share/classes/java/util/zip/ZipEntry.java 
b/src/java.base/share/classes/java/util/zip/ZipEntry.java
--- a/src/java.base/share/classes/java/util/zip/ZipEntry.java   (revision 
a891743b062d076e4db96764f6d8bfafc6251407)
+++ b/src/java.base/share/classes/java/util/zip/ZipEntry.java   (date 
1774422476820)
@@ -651,8 +651,9 @@
     }
 
     /**
-     * Sets the optional comment string for the entry.
-     * @param comment the comment string
+     * Sets the optional comment string for the entry. If {@code comment} is 
the
+     * empty string or {@code null} then the entry will have no comment.
+     * @param comment the comment string, or an empty string or null for no 
comment
      * @throws IllegalArgumentException if the combined length
      * of the specified entry comment, the {@linkplain #getName() entry name},
      * the {@linkplain #getExtra() extra field data}, and the

-------------

PR Comment: https://git.openjdk.org/jdk/pull/30338#issuecomment-4124294477

Reply via email to