Remove struts2 latest dep restriction
MODIFY
instrumentation/struts-2.3/javaagent/build.gradle.kts
instrumentation/struts-2.3/javaagent/build.gradle.kts
@@ -15,12 +15,6 @@ dependencies {
library("org.apache.struts:struts2-core:2.3.1")
- // There was no 2.4 version at all.
- // In version 2.5 Struts Servlet Filter entry point was relocated.
- // This Servlet Filter is relevant only in setting up the test app and it is not used in
- // instrumentation. So fixing Struts library version for the test.
- latestDepTestLibrary("org.apache.struts:struts2-core:2.3.+")
-
testImplementation(project(":testing-common"))
testImplementation("org.eclipse.jetty:jetty-server:8.0.0.v20110901")
testImplementation("org.eclipse.jetty:jetty-servlet:8.0.0.v20110901")

MODIFY
instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy
instrumentation/struts-2.3/javaagent/src/test/groovy/Struts2ActionSpanTest.groovy
@@ -12,7 +12,6 @@ import io.opentelemetry.instrumentation.test.base.HttpServerTest
import io.opentelemetry.sdk.trace.data.SpanData
import io.opentelemetry.semconv.trace.attributes.SemanticAttributes
import io.opentelemetry.struts.GreetingServlet
-import org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.servlet.DefaultServlet
import org.eclipse.jetty.servlet.ServletContextHandler
@@ -116,7 +115,15 @@ class Struts2ActionSpanTest extends HttpServerTest<Server> implements AgentTestT
context.addServlet(DefaultServlet, "/")
context.addServlet(GreetingServlet, "/greetingServlet")
- context.addFilter(StrutsPrepareAndExecuteFilter, "/*", EnumSet.of(DispatcherType.REQUEST))
+ def strutsFilterClass = null
+ try {
+ // struts 2.3
+ strutsFilterClass = Class.forName("org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter")
+ } catch (ClassNotFoundException exception) {
+ // struts 2.5
+ strutsFilterClass = Class.forName("org.apache.struts2.dispatcher.filter.StrutsPrepareAndExecuteFilter")
+ }
+ context.addFilter(strutsFilterClass, "/*", EnumSet.of(DispatcherType.REQUEST))
server.start()

MODIFY
instrumentation/struts-2.3/javaagent/src/test/resources/struts.xml
instrumentation/struts-2.3/javaagent/src/test/resources/struts.xml
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.patternMatcher" value="namedVariable"/>
+ <constant name="struts.matcher.appendNamedParameters" value="true"/>
<package name="basic-struts2" extends="struts-default">
<global-results>

Remove struts2 latest dep restriction (#5289)