Testcontainers is a Java library that supports JUnit tests, providing lightweight, throwaway instances of common databases, Selenium web browsers, or anything else that can run in a Docker container.
for some reason, the HttpWaitStrategy reads the response line by line, but does not save the line break characters. In some cases it is really bad, for example, parsing the prometheus metric of springboot application becomes a nightmare.
from org.testcontainers.containers.wait.strategy.HttpWaitStrategy
private String getResponseBody(HttpURLConnection connection) throws IOException {
BufferedReader reader;
if (200 <= connection.getResponseCode() && connection.getResponseCode() <= 299) {
reader = new BufferedReader(new InputStreamReader((connection.getInputStream())));
} else {
reader = new BufferedReader(new InputStreamReader((connection.getErrorStream())));
}
StringBuilder builder = new StringBuilder();
String line;
while ((line = reader.readLine()) != null) {
builder.append(line); // THIS ROW!!!!!!!
}
return builder.toString();
}
Module
Core
Testcontainers version
1.18.3
Using the latest Testcontainers version?
Yes
Host OS
Linux
Host Arch
x86
Docker version
What happened?
for some reason, the
HttpWaitStrategy
reads the response line by line, but does not save the line break characters. In some cases it is really bad, for example, parsing the prometheus metric of springboot application becomes a nightmare.from
org.testcontainers.containers.wait.strategy.HttpWaitStrategy
Relevant log output
No response
Additional Information
No response