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

优化ThreadPoolNotifyAlarmHandler下的空指针异常 #188

Closed
zhuanghaozhe opened this issue Apr 19, 2022 · 0 comments
Closed

优化ThreadPoolNotifyAlarmHandler下的空指针异常 #188

zhuanghaozhe opened this issue Apr 19, 2022 · 0 comments
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@zhuanghaozhe
Copy link
Contributor

程序会监控线程池中每个任务的执行时间,如果执行时间超过了executeTimeOut,就会异步发送任务超时警告,执行ThreadPoolNotifyAlarmHandler类的asyncSendExecuteTimeOutAlarm方法。但如果此线程池在创建的时候,在DynamicThreadPoolPostProcessor类的postProcessAfterInitialization方法中向服务端请求该线程池的配置参数时发生错误。就会导致此线程池对应的threadPoolNotifyAlarm未被放入GlobalNotifyAlarmManageNOTIFY_ALARM_MAP当中,进而导致在异步发送任务超时警告ThreadPoolNotifyAlarmHandler类的asyncSendExecuteTimeOutAlarm方法时,发生空指针异常

相关代码:

ThreadPoolNotifyAlarm threadPoolNotifyAlarm = GlobalNotifyAlarmManage.get(threadPoolId);// null
if (!threadPoolNotifyAlarm.getIsAlarm()) {
    return;
}

异常如下:

Exception in thread "message-consume-3" java.lang.NullPointerException
	at cn.hippo4j.core.executor.ThreadPoolNotifyAlarmHandler.asyncSendExecuteTimeOutAlarm(ThreadPoolNotifyAlarmHandler.java:171)
	at cn.hippo4j.core.executor.DynamicThreadPoolExecutor.afterExecute(DynamicThreadPoolExecutor.java:100)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1157)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
zhuanghaozhe added a commit to zhuanghaozhe/hippo4j that referenced this issue Apr 19, 2022
@magestacks magestacks added the type: bug Something isn't working label Apr 20, 2022
magestacks added a commit that referenced this issue Apr 20, 2022
@magestacks magestacks added this to the 1.2.1 milestone Apr 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants