Merge pull request #11511 from jetty/fix/12.0.x/classmatcher-match-npe

Issue #11510 - Prevent NPE in ClassMatcher.match()
This commit is contained in:
Joakim Erdfelt 2024-03-13 13:47:29 -05:00 committed by GitHub
commit d07d13f30a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -751,6 +751,9 @@ public class ClassMatcher extends AbstractSet<String>
public boolean match(String name, URL url) public boolean match(String name, URL url)
{ {
if (url == null)
return false;
// Strip class suffix for name matching // Strip class suffix for name matching
if (name.endsWith(".class")) if (name.endsWith(".class"))
name = name.substring(0, name.length() - 6); name = name.substring(0, name.length() - 6);

View File

@ -733,6 +733,9 @@ public class ClassMatcher extends AbstractSet<String>
public boolean match(String name, URL url) public boolean match(String name, URL url)
{ {
if (url == null)
return false;
// Strip class suffix for name matching // Strip class suffix for name matching
if (name.endsWith(".class")) if (name.endsWith(".class"))
name = name.substring(0, name.length() - 6); name = name.substring(0, name.length() - 6);