-
CSR
-
Resolution: Approved
-
P4
-
None
-
behavioral
-
minimal
-
-
Java API
-
SE
Summary
The API specification of java.util.zip.InflaterInputStream.skip(long)
method will be updated to specify that it will skip at most Integer.MAX_VALUE
bytes.
Problem
InflaterInputStream.skip(long)
method takes a long
value representing the number of bytes to skip from the compressed stream. In its current implementation, the method skips at most Integer.MAX_VALUE
bytes, even when the compressed stream may have more bytes that could be skipped. This implementation detail isn't specified in the API documentation of that method.
java.util.zip.DeflaterInputStream
has a similar skip(long)
method whose implementation too takes a long
value and skips at most Integer.MAX_VALUE
bytes. That method however, clearly notes this detail in its API documentation which states (among other things):
<em>Note:</em> While {@code n} is given as a {@code long},
* the maximum number of bytes which can be skipped is
* {@code Integer.MAX_VALUE}.
Solution
The API specification of InflaterInputStream.skip(long)
will be updated to specify the current implementation detail that it will skip at most Integer.MAX_VALUE
bytes. While at it, the API documentation of this method will also be updated to state that method may block until the specified number of bytes are read and skipped. This change too is merely stating the current implementation detail, like what the DeflaterInputStream.skip(long)
already does.
Specification
diff --git a/src/java.base/share/classes/java/util/zip/DeflaterInputStream.java b/src/java.base/share/classes/java/util/zip/DeflaterInputStream.java
/**
* Skips over and discards data from the input stream.
- * This method may block until the specified number of bytes are read and
- * skipped. <em>Note:</em> While {@code n} is given as a {@code long},
- * the maximum number of bytes which can be skipped is
- * {@code Integer.MAX_VALUE}.
+ * This method may block until the specified number of bytes are skipped
+ * or end of stream is reached.
*
- * @param n number of bytes to be skipped
- * @return the actual number of bytes skipped
+ * @implNote
+ * This method skips at most {@code Integer.MAX_VALUE} bytes.
+ *
+ * @param n number of bytes to be skipped. If {@code n} is zero then no bytes are skipped.
+ * @return the actual number of bytes skipped, which might be zero
* @throws IOException if an I/O error occurs or if this stream is
- * already closed
+ * already closed
+ * @throws IllegalArgumentException if {@code n < 0}
*/
public long skip(long n) throws IOException {
diff --git a/src/java.base/share/classes/java/util/zip/InflaterInputStream.java b/src/java.base/share/classes/java/util/zip/InflaterInputStream.java
/**
* Skips specified number of bytes of uncompressed data.
- * @param n the number of bytes to skip
- * @return the actual number of bytes skipped.
- * @throws IOException if an I/O error has occurred
+ * This method may block until the specified number of bytes are skipped
+ * or end of stream is reached.
+ *
+ * @implNote
+ * This method skips at most {@code Integer.MAX_VALUE} bytes.
+ *
+ * @param n the number of bytes to skip. If {@code n} is zero then no bytes are skipped.
+ * @return the actual number of bytes skipped, which might be zero
+ * @throws IOException if an I/O error occurs or if this stream is
+ * already closed
* @throws IllegalArgumentException if {@code n < 0}
*/
public long skip(long n) throws IOException {
- csr of
-
JDK-8206447 InflaterInputStream.skip receives long but it's limited to Integer.MAX_VALUE
- Resolved