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

recreate sechedule pool on context refreshed #529

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sage417
Copy link

@sage417 sage417 commented Feb 17, 2025

fix issue #528

@@ -73,6 +73,9 @@ public synchronized void onContextRefreshedEvent(CustomContextRefreshedEvent eve
if (monitorFuture != null) {
monitorFuture.cancel(true);
}
if (MONITOR_EXECUTOR == null || MONITOR_EXECUTOR.isShutdown() || MONITOR_EXECUTOR.isTerminated()) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里优化感也不是何必要,除非改成是否开启监控的配置决定出是否实例化

Copy link
Author

@sage417 sage417 Feb 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在多次执行onContextRefreshedEvent时这个判断是必要的,在dev tool classloader restart时,全局共享的MONITOR_EXECUTOR先会被shutdown,dtpmonitor创建新实例后重新执行onContextRefreshedEvent,这时复用老的MONITOR_EXECUTOR会发生RejectedExecutionException

简单来说dtpmonitor二次实例化会出现RejectedExecutionException

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

在多次执行onContextRefreshedEvent时这个判断是必要的,在dev tool classloader restart时,全局共享的MONITOR_EXECUTOR先会被shutdown,dtpmonitor创建新实例后重新执行onContextRefreshedEvent,这时复用老的MONITOR_EXECUTOR会发生RejectedExecutionException

简单来说dtpmonitor二次实例化会出现RejectedExecutionException

确实,在SmartLifecycle中stop的时候shutdown了,确实如果restart要这么处理

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

那就不只是DtpMonitor中静态线程池受影响,其他功能类中的也受影响吧。

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

很多框架好像对devtools支持都不太好

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants