-
Bug
-
Resolution: Fixed
-
P4
-
11, 13, 14
-
b10
-
generic
-
generic
A DESCRIPTION OF THE PROBLEM :
When calling jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(byte[], int, int) with len = 0 an assertion fails because it requires len to be positive
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make sure to apply the -ea option to enable assertions
2. Create a HttpClient
3. send a request using BodyHandlers.ofInputStream() as the responseBodyHandler
4. Get the body from the response and call read(byte[], int, int) with len = 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The read method should just return without doing anything as stated by the JavaDoc on InputStream.read(byte[], int, int): "If len is zero, then no bytes are read and 0 is returned"
ACTUAL -
Exception in thread "main" java.lang.AssertionError
at java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(ResponseSubscribers.java:449)
at Main.main(Main.java:11)
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
public class Main {
public static void main (String[] args) {
try {
HttpClient.newHttpClient().send(HttpRequest.newBuilder(URI.create("https://www.example.com/")).build(), BodyHandlers.ofInputStream()).body().read(new byte[16], 0, 0);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
When calling jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(byte[], int, int) with len = 0 an assertion fails because it requires len to be positive
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Make sure to apply the -ea option to enable assertions
2. Create a HttpClient
3. send a request using BodyHandlers.ofInputStream() as the responseBodyHandler
4. Get the body from the response and call read(byte[], int, int) with len = 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
The read method should just return without doing anything as stated by the JavaDoc on InputStream.read(byte[], int, int): "If len is zero, then no bytes are read and 0 is returned"
ACTUAL -
Exception in thread "main" java.lang.AssertionError
at java.net.http/jdk.internal.net.http.ResponseSubscribers$HttpResponseInputStream.read(ResponseSubscribers.java:449)
at Main.main(Main.java:11)
---------- BEGIN SOURCE ----------
import java.io.IOException;
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse.BodyHandlers;
public class Main {
public static void main (String[] args) {
try {
HttpClient.newHttpClient().send(HttpRequest.newBuilder(URI.create("https://www.example.com/")).build(), BodyHandlers.ofInputStream()).body().read(new byte[16], 0, 0);
} catch (IOException | InterruptedException e) {
e.printStackTrace();
}
}
}
---------- END SOURCE ----------
FREQUENCY : always
- duplicates
-
JDK-8288591 Backport JDK-8228970 to Java 11
-
- Closed
-
-
JDK-8294773 j.l.AssertionError in ResponseSubscribers.HttpResponseInputStream.read() with J11
-
- Closed
-