Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong response code if compile fails #1100

Merged
merged 1 commit into from
Mar 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public void testThatApplicationRecoversCompilationIssue() throws MavenInvocation
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> {
String content = getHttpResponse("/app/hello");
String content = getHttpResponse("/app/hello", true);
last.set(content);
return content.contains(uuid);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.TimeUnit;
Expand Down Expand Up @@ -159,13 +160,27 @@ static String getHttpResponse() {
}

static String getHttpResponse(String path) {
return getHttpResponse(path, false);
}

static String getHttpResponse(String path, boolean allowError) {
AtomicReference<String> resp = new AtomicReference<>();
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> {
try {
URL url = new URL("http://localhost:8080" + ((path.startsWith("/") ? path : "/" + path)));
String content = IOUtils.toString(url, "UTF-8");
String content;
if (!allowError) {
content = IOUtils.toString(url, "UTF-8");
} else {
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
if (conn.getResponseCode() >= 400) {
content = IOUtils.toString(conn.getErrorStream(), "UTF-8");
} else {
content = IOUtils.toString(conn.getInputStream(), "UTF-8");
}
}
resp.set(content);
return true;
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ public class ReplacementDebugPage {
"</style>";

public static void handleRequest(HttpServerExchange exchange, final Throwable exception) throws IOException {
exchange.setStatusCode(500);
StringBuilder sb = new StringBuilder();
//todo: make this good
sb.append("<html><head><title>ERROR</title>");
Expand Down