Remove struts2 latest dep restriction (#5289)

This commit is contained in:
Lauri Tulmin 2022-02-01 19:52:23 +02:00 committed by GitHub
parent 022914139e
commit 3cb1efceb3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 8 deletions

View File

@ -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")

View File

@ -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()

View File

@ -7,6 +7,7 @@
<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>