Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Occasional NPE in ClassMatcher.match() from WebAppClassLoader.loadClass() usage #11510

Closed
joakime opened this issue Mar 12, 2024 · 0 comments · Fixed by #11511
Closed

Occasional NPE in ClassMatcher.match() from WebAppClassLoader.loadClass() usage #11510

joakime opened this issue Mar 12, 2024 · 0 comments · Fixed by #11511
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@joakime
Copy link
Contributor

joakime commented Mar 12, 2024

Jetty version(s)
12.0.x

Jetty Environment
All

Java version/vendor (use: java -version)
All

OS type/version
All

Description
While testing things for the Cross Context Dispatch PR, I came across this NPE twice.

2024-03-12 16:52:01.522:INFO :oejtt.ProcessWrapper:process/err: java.lang.NullPointerException: Cannot invoke "java.net.URL.toURI()" because "url" is null
2024-03-12 16:52:01.522:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.ClassMatcher.lambda$match$4(ClassMatcher.java:765)
2024-03-12 16:52:01.522:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.ClassMatcher.combine(ClassMatcher.java:799)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.ClassMatcher.match(ClassMatcher.java:761)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.WebAppContext.isSystemResource(WebAppContext.java:720)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.loadAsResource(WebAppClassLoader.java:551)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.WebAppClassLoader.loadClass(WebAppClassLoader.java:487)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:520)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.util.Loader.loadClass(Loader.java:58)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.StandardDescriptorProcessor.visitServlet(StandardDescriptorProcessor.java:282)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:77)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at java.base/java.lang.reflect.Method.invoke(Method.java:568)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.IterativeDescriptorProcessor.visit(IterativeDescriptorProcessor.java:81)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.IterativeDescriptorProcessor.process(IterativeDescriptorProcessor.java:69)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.MetaData.resolve(MetaData.java:475)
2024-03-12 16:52:01.523:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.webapp.WebAppContext.startContext(WebAppContext.java:1222)
2024-03-12 16:52:01.524:INFO :oejtt.ProcessWrapper:process/err: ?at org.eclipse.jetty.ee10.servlet.ServletContextHandler.lambda$doStart$0(ServletContextHandler.java:1043)

Note: the line numbers are off as i'm in the middle of debugging a few things.

This is easily preventable, just don't debug the WebAppClassLoader codebase.
We can also make the ClassMatch.match() NPE safe (even while debugging).

@joakime joakime added the Bug For general bugs on Jetty side label Mar 12, 2024
@joakime joakime self-assigned this Mar 12, 2024
@joakime joakime moved this to 🏗 In progress in Jetty 12.0.8 - FROZEN Mar 12, 2024
@joakime joakime changed the title Occasional NPE in ClassMatcher.match() from WebAPpClassLoader.loadClass() usage. Occasional NPE in ClassMatcher.match() from WebAppClassLoader.loadClass() usage. Mar 12, 2024
@joakime joakime changed the title Occasional NPE in ClassMatcher.match() from WebAppClassLoader.loadClass() usage. Occasional NPE in ClassMatcher.match() from WebAppClassLoader.loadClass() usage Mar 12, 2024
joakime added a commit that referenced this issue Mar 13, 2024
@github-project-automation github-project-automation bot moved this from 🏗 In progress to ✅ Done in Jetty 12.0.8 - FROZEN Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Status: ✅ Done
Development

Successfully merging a pull request may close this issue.

1 participant