From df473df5c757e37666cc2804422c196f9174c954 Mon Sep 17 00:00:00 2001 From: idawda Date: Fri, 22 Nov 2024 16:36:20 +0530 Subject: [PATCH] Fix for NR-266822 where false APIs reported for servlet using applications --- .../instrumentation/apache/tomcat10/HttpServletHelper.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/instrumentation-security/apache-tomcat-10/src/main/java/com/newrelic/agent/security/instrumentation/apache/tomcat10/HttpServletHelper.java b/instrumentation-security/apache-tomcat-10/src/main/java/com/newrelic/agent/security/instrumentation/apache/tomcat10/HttpServletHelper.java index f27ae5e0c..7f17bf409 100644 --- a/instrumentation-security/apache-tomcat-10/src/main/java/com/newrelic/agent/security/instrumentation/apache/tomcat10/HttpServletHelper.java +++ b/instrumentation-security/apache-tomcat-10/src/main/java/com/newrelic/agent/security/instrumentation/apache/tomcat10/HttpServletHelper.java @@ -21,8 +21,10 @@ public class HttpServletHelper { public static void gatherURLMappings(ServletContext servletContext) { try { Map servletRegistrations = servletContext.getServletRegistrations(); - getJSPMappings(servletContext, SEPARATOR); - + String contextPath = StringUtils.removeStart(StringUtils.removeEnd(servletContext.getContextPath(), SEPARATOR), StringUtils.SEPARATOR); + if (!StringUtils.equalsAny(contextPath, "docs", "examples")) { + getJSPMappings(servletContext, SEPARATOR); + } for (ServletRegistration servletRegistration : servletRegistrations.values()) { for (String mapping : servletRegistration.getMappings()) { URLMappingsHelper.addApplicationURLMapping(new ApplicationURLMapping(WILDCARD, mapping, servletRegistration.getClassName()));