From 29b94bc1787c5007bc5f3b15b1fa39316ae20dbe Mon Sep 17 00:00:00 2001 From: pellmont <dev+github@ppo2.ch> Date: Sat, 1 Apr 2023 08:23:48 +0200 Subject: [PATCH] added test for handler chain order --- .../src/test/groovy/TestWsServlet.groovy | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/test/groovy/TestWsServlet.groovy b/instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/test/groovy/TestWsServlet.groovy index d8cd8064fc90..7b230415b11b 100644 --- a/instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/test/groovy/TestWsServlet.groovy +++ b/instrumentation/jaxws/jaxws-2.0-cxf-3.0/javaagent/src/test/groovy/TestWsServlet.groovy @@ -4,7 +4,13 @@ */ import hello.HelloServiceImpl +import io.opentelemetry.api.trace.Span +import io.opentelemetry.context.Context +import io.opentelemetry.instrumentation.api.instrumenter.LocalRootSpan import org.apache.cxf.jaxws.EndpointImpl +import org.apache.cxf.message.Message +import org.apache.cxf.phase.AbstractPhaseInterceptor +import org.apache.cxf.phase.Phase import org.apache.cxf.transport.servlet.CXFNonSpringServlet import javax.servlet.ServletConfig @@ -18,5 +24,14 @@ class TestWsServlet extends CXFNonSpringServlet { Object implementor = new HelloServiceImpl() EndpointImpl endpoint = new EndpointImpl(bus, implementor) endpoint.publish("/HelloService") + endpoint.getOutInterceptors().add(new AbstractPhaseInterceptor<Message>(Phase.SETUP) { + @Override + void handleMessage(Message message) { + Context context = Context.current() + if (LocalRootSpan.fromContext(context) != Span.fromContext(context)) { + throw new IllegalStateException("handler span should not be ended before outgoing interceptors") + } + } + }); } }