Skip to content

Commit d7d1afb

Browse files
committed
8206447: InflaterInputStream.skip receives long but it's limited to Integer.MAX_VALUE
Reviewed-by: lancea, alanb
1 parent 7acfba2 commit d7d1afb

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

src/java.base/share/classes/java/util/zip/DeflaterInputStream.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -212,15 +212,17 @@ public int read(byte[] b, int off, int len) throws IOException {
212212

213213
/**
214214
* Skips over and discards data from the input stream.
215-
* This method may block until the specified number of bytes are read and
216-
* skipped. <em>Note:</em> While {@code n} is given as a {@code long},
217-
* the maximum number of bytes which can be skipped is
218-
* {@code Integer.MAX_VALUE}.
215+
* This method may block until the specified number of bytes are skipped
216+
* or end of stream is reached.
219217
*
220-
* @param n number of bytes to be skipped
221-
* @return the actual number of bytes skipped
218+
* @implNote
219+
* This method skips at most {@code Integer.MAX_VALUE} bytes.
220+
*
221+
* @param n number of bytes to be skipped. If {@code n} is zero then no bytes are skipped.
222+
* @return the actual number of bytes skipped, which might be zero
222223
* @throws IOException if an I/O error occurs or if this stream is
223-
* already closed
224+
* already closed
225+
* @throws IllegalArgumentException if {@code n < 0}
224226
*/
225227
public long skip(long n) throws IOException {
226228
if (n < 0) {

src/java.base/share/classes/java/util/zip/InflaterInputStream.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,9 +208,16 @@ public int available() throws IOException {
208208

209209
/**
210210
* Skips specified number of bytes of uncompressed data.
211-
* @param n the number of bytes to skip
212-
* @return the actual number of bytes skipped.
213-
* @throws IOException if an I/O error has occurred
211+
* This method may block until the specified number of bytes are skipped
212+
* or end of stream is reached.
213+
*
214+
* @implNote
215+
* This method skips at most {@code Integer.MAX_VALUE} bytes.
216+
*
217+
* @param n the number of bytes to skip. If {@code n} is zero then no bytes are skipped.
218+
* @return the actual number of bytes skipped, which might be zero
219+
* @throws IOException if an I/O error occurs or if this stream is
220+
* already closed
214221
* @throws IllegalArgumentException if {@code n < 0}
215222
*/
216223
public long skip(long n) throws IOException {

0 commit comments

Comments
 (0)