From c2d0ab29dcb90c64385ad0387f6656845f71d99e Mon Sep 17 00:00:00 2001 From: Joakim Erdfelt Date: Tue, 12 Mar 2024 17:00:15 -0500 Subject: [PATCH] Issue #11510 - Prevent NPE in ClassMatcher.match() --- .../main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java | 3 +++ .../main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java | 3 +++ 2 files changed, 6 insertions(+) diff --git a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java index f7334e8c337f..a79a8783fb9a 100644 --- a/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java +++ b/jetty-ee10/jetty-ee10-webapp/src/main/java/org/eclipse/jetty/ee10/webapp/ClassMatcher.java @@ -751,6 +751,9 @@ public boolean match(Class clazz) public boolean match(String name, URL url) { + if (url == null) + return false; + // Strip class suffix for name matching if (name.endsWith(".class")) name = name.substring(0, name.length() - 6); diff --git a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java index 148486e5ba42..84d05c2a9cf9 100644 --- a/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java +++ b/jetty-ee9/jetty-ee9-webapp/src/main/java/org/eclipse/jetty/ee9/webapp/ClassMatcher.java @@ -733,6 +733,9 @@ public boolean match(Class clazz) public boolean match(String name, URL url) { + if (url == null) + return false; + // Strip class suffix for name matching if (name.endsWith(".class")) name = name.substring(0, name.length() - 6);