Skip to content

Commit cafe401

Browse files
committed
jetty12
1 parent ddcb12b commit cafe401

File tree

1 file changed

+8
-11
lines changed
  • instrumentation/servlet/servlet-5.0/jetty12-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/jetty12

1 file changed

+8
-11
lines changed

instrumentation/servlet/servlet-5.0/jetty12-testing/src/test/java/io/opentelemetry/javaagent/instrumentation/servlet/v5_0/jetty12/Jetty12Servlet5Test.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.eclipse.jetty.server.Server;
2626
import org.eclipse.jetty.server.handler.ErrorHandler;
2727
import org.eclipse.jetty.ee10.servlet.ServletContextHandler;
28+
import org.eclipse.jetty.util.Callback;
2829
import org.junit.jupiter.api.extension.RegisterExtension;
2930

3031
public abstract class Jetty12Servlet5Test
@@ -82,19 +83,15 @@ protected SpanDataAssert assertResponseSpan(
8283
protected Server setupServer() throws Exception {
8384
Server jettyServer = new Server(new InetSocketAddress("localhost", port));
8485

85-
ServletContextHandler servletContext = new ServletContextHandler(contextPath);
86-
servletContext.errorHandler = new Request.Handler() {
87-
88-
@Override
89-
boolean handle(Request request, Response response, Callback callback) throws Exception {
90-
String message = (String) request.getAttribute("org.eclipse.jetty.server.error_message")
86+
ServletContextHandler servletContext = new ServletContextHandler(getContextPath());
87+
servletContext.setErrorHandler((request,response,callback) -> {
88+
String message = (String) request.getAttribute("org.eclipse.jetty.server.error_message");
9189
if (message != null) {
92-
response.write(true, StandardCharsets.UTF_8.encode(message), Callback.NOOP)
90+
response.write(true, StandardCharsets.UTF_8.encode(message), Callback.NOOP);
9391
}
94-
callback.succeeded()
95-
return true
96-
}
97-
});
92+
callback.succeeded();
93+
return true;
94+
});
9895
setupServlets(servletContext);
9996
jettyServer.setHandler(servletContext);
10097

0 commit comments

Comments
 (0)