[Bug] When the thread context classloader is null the InstanceMethodInterTemplate class will throw NullPointerException #13461
Unanswered
sweetcczhang
asked this question in
Q&A
Replies: 1 comment 3 replies
-
We never threw an agent core internal error to the use codes. What is point of that? |
Beta Was this translation helpful? Give feedback.
3 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Search before asking
Apache SkyWalking Component
Java Agent (apache/skywalking-java)
What happened
when I add jdk-forkjoinpool plugin in my skywalking-java agent and there are code in my application like below:
Accessing this endpoint via HTTP requests will cause the requests to hang. and the application log is below:
As indicated by the logs, a NullPointerException was thrown at line 131 of the InstanceMethodInterTemplate class. The relevant code is shown below
As evidenced by the InstanceMethodInterTemplate code, when loader == null, the LOGGER is not initialized, thus invoking logging operations will throw a NullPointerException. And This exception will be propagated to the user program, disrupting the execution of business logic.
What you expected to happen
As indicated by the above description, this issue is caused by loader == null. Examining the code of the getAgentClassLoader method in the BootstrapInterRuntimeAssist class reveals that when the thread context ClassLoader is null, this situation occurs. the code is below:
In the test case, without adding the SkyWalking agent and printing the thread context ClassLoader as follows:. The logs show that the ClassLoader of threads in the ForkJoin pool is null.
the test code is below:
and the log is below:
How to reproduce
jdk:1.8.0_431
spring boot : 2.5.9
tomcat: 9.0.108
skywalking-java: latest version. And you need to put the jdk-forkjoinpool plugin jar file into /plugins.
test application code:
attention: This issue only occurs when the application is packaged as a WAR file and deployed to Tomcat, whereas it does not occur when directly using Spring Boot's embedded Tomcat.
Anything else
No response
Are you willing to submit a pull request to fix on your own?
Code of Conduct
Beta Was this translation helpful? Give feedback.
All reactions