Skip to content

Commit

Permalink
Improve tomcat version detection (#11936)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurit authored Aug 1, 2024
1 parent f8c383c commit 4d41ca5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,13 @@ public Tomcat10InstrumentationModule() {
@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// only matches tomcat 10.0+
return hasClassesNamed("jakarta.servlet.http.HttpServletRequest");
return hasClassesNamed("jakarta.servlet.http.HttpServletRequest")
.and(
// tomcat 10 has at least one of these two classes. Cache$EvictionOrder is present in
// 10.0.0, but is removed before 10.1.0. GenericUser is added before Cache$EvictionOrder
// is removed
hasClassesNamed("org.apache.catalina.users.GenericUser")
.or(hasClassesNamed("org.apache.catalina.webresources.Cache$EvictionOrder")));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ public Tomcat7InstrumentationModule() {
@Override
public ElementMatcher.Junction<ClassLoader> classLoaderMatcher() {
// does not match tomcat 10.0+
return hasClassesNamed("javax.servlet.http.HttpServletRequest");
return hasClassesNamed(
"javax.servlet.http.HttpServletRequest", "org.apache.catalina.loader.Constants");
}

@Override
Expand Down

0 comments on commit 4d41ca5

Please sign in to comment.