ApplicationContextHolder 适配非 Spring 环境.

pull/142/head
chen.ma 4 years ago
parent 24b7b2b0aa
commit 69973a8554

@ -91,7 +91,7 @@ public class DynamicThreadPoolExecutor extends AbstractDynamicExecutorSupport {
long endTime = System.currentTimeMillis(); long endTime = System.currentTimeMillis();
long executeTime; long executeTime;
boolean executeTimeAlarm = (executeTime = (endTime - startTime)) > executeTimeOut; boolean executeTimeAlarm = (executeTime = (endTime - startTime)) > executeTimeOut;
if (executeTimeAlarm) { if (executeTimeAlarm && ApplicationContextHolder.getInstance() != null) {
ThreadPoolNotifyAlarmHandler notifyAlarmHandler = ApplicationContextHolder.getBean(ThreadPoolNotifyAlarmHandler.class); ThreadPoolNotifyAlarmHandler notifyAlarmHandler = ApplicationContextHolder.getBean(ThreadPoolNotifyAlarmHandler.class);
if (notifyAlarmHandler != null) { if (notifyAlarmHandler != null) {
notifyAlarmHandler.asyncSendExecuteTimeOutAlarm(threadPoolId, executeTime, executeTimeOut, this); notifyAlarmHandler.asyncSendExecuteTimeOutAlarm(threadPoolId, executeTime, executeTimeOut, this);

@ -30,11 +30,7 @@ public class RejectedProxyInvocationHandler implements InvocationHandler {
if (ApplicationContextHolder.getInstance() != null) { if (ApplicationContextHolder.getInstance() != null) {
ThreadPoolNotifyAlarmHandler alarmHandler = ApplicationContextHolder.getBean(ThreadPoolNotifyAlarmHandler.class); ThreadPoolNotifyAlarmHandler alarmHandler = ApplicationContextHolder.getBean(ThreadPoolNotifyAlarmHandler.class);
try { alarmHandler.checkPoolRejectedAlarm(threadPoolId);
alarmHandler.checkPoolRejectedAlarm(threadPoolId);
} catch (Exception ignored) {
//ignored
}
} }
try { try {

Loading…
Cancel
Save