Skip to content

Commit d803a06

Browse files
committed
Update AbstractJdkHttpServerTest.java
1 parent 1a37d5f commit d803a06

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

instrumentation/java-http-server/testing/src/main/java/io/opentelemetry/instrumentation/httpserver/AbstractJdkHttpServerTest.java

+7-14
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.CAPTURE_HEADERS;
99
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.ERROR;
10-
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.EXCEPTION;
1110
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.INDEXED_CHILD;
1211
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.PATH_PARAM;
1312
import static io.opentelemetry.instrumentation.testing.junit.http.ServerEndpoint.QUERY_PARAM;
@@ -108,17 +107,6 @@ protected HttpServer setupServer() throws IOException {
108107
"controller", () -> sendResponse(ctx, ERROR.getStatus(), ERROR.getBody())));
109108

110109
contexts.add(context);
111-
context =
112-
server.createContext(
113-
EXCEPTION.getPath(),
114-
ctx ->
115-
testing()
116-
.runWithSpan(
117-
"controller",
118-
() -> {
119-
throw new IllegalStateException(EXCEPTION.getBody());
120-
}));
121-
contexts.add(context);
122110
context =
123111
server.createContext(
124112
"/query",
@@ -221,10 +209,15 @@ public void doFilter(HttpExchange exchange, Chain chain) throws IOException {
221209
}
222210
exchange.getResponseHeaders().set("decoratingfunction", "ok");
223211
exchange.getResponseHeaders().set("decoratinghttpservicefunction", "ok");
224-
chain.doFilter(exchange);
225212

226-
// server will hang if nothing is sent
213+
try {
214+
chain.doFilter(exchange);
215+
} catch (Exception e) {
216+
sendResponse(exchange, 500, e.getMessage());
217+
}
218+
227219
if (exchange.getResponseCode() == -1) {
220+
228221
sendResponse(exchange, 500, "nothing");
229222
}
230223
}

0 commit comments

Comments
 (0)