We have an InputStream implementation that internally chunks data, so read sometimes returns less than the requested length. The changes in #1774 (commit ccbd65f) no longer limit the overall amount across multiple calls to read, so Jsoup.parse fails.
This following test passes with 1.15.1:
@Test
public void test() throws Exception {
class ShortReadInputStream extends InputStream {
final InputStream in;
ShortReadInputStream(InputStream in) { this.in = in; }
public int read() throws IOException { return in.read(); }
public int read(byte[] b) throws IOException { return in.read(b, 0, b.length); }
public int read(byte[] b, int off, int len) throws IOException { return in.read(b, off, Math.min(len, 10)); }
}
var in = new ShortReadInputStream(new ByteArrayInputStream(new byte[0x8000]));
Jsoup.parse(in, null, "", Parser.xmlParser());
}
...but it fails with 1.15.2:
java.io.IOException: Resetting to invalid mark
at java.base/java.io.BufferedInputStream.reset(BufferedInputStream.java:446)
at org.jsoup.internal.ConstrainableInputStream.reset(ConstrainableInputStream.java:117)
at org.jsoup.helper.DataUtil.parseInputStream(DataUtil.java:149)
at org.jsoup.helper.DataUtil.load(DataUtil.java:107)
at org.jsoup.Jsoup.parse(Jsoup.java:197)
at Test.test(Test.java:21)
We have an
InputStreamimplementation that internally chunks data, soreadsometimes returns less than the requested length. The changes in #1774 (commit ccbd65f) no longer limit the overall amount across multiple calls toread, soJsoup.parsefails.This following test passes with 1.15.1:
...but it fails with 1.15.2: