update bugfix NullPointerException

pull/159/head
weihu 3 years ago
parent 3d6a238c4b
commit d3dc463172

@ -1,9 +1,12 @@
package cn.hippo4j.core.starter.config; package cn.hippo4j.core.starter.config;
import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm; import cn.hippo4j.common.notify.ThreadPoolNotifyAlarm;
import com.google.common.collect.Maps;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
import java.util.Map;
/** /**
* Executor properties. * Executor properties.
* *
@ -69,4 +72,8 @@ public class ExecutorProperties {
*/ */
private ThreadPoolNotifyAlarm notify; private ThreadPoolNotifyAlarm notify;
public Map<String, String> receives() {
return this.notify.getReceives() == null ? Maps.newHashMap() : this.notify.getReceives();
}
} }

@ -3,6 +3,7 @@ package cn.hippo4j.core.starter.notify;
import cn.hippo4j.common.api.NotifyConfigBuilder; import cn.hippo4j.common.api.NotifyConfigBuilder;
import cn.hippo4j.common.notify.AlarmControlHandler; import cn.hippo4j.common.notify.AlarmControlHandler;
import cn.hippo4j.common.notify.NotifyConfigDTO; import cn.hippo4j.common.notify.NotifyConfigDTO;
import cn.hippo4j.common.toolkit.CollectionUtil;
import cn.hippo4j.core.starter.config.BootstrapCoreProperties; import cn.hippo4j.core.starter.config.BootstrapCoreProperties;
import cn.hippo4j.core.starter.config.ExecutorProperties; import cn.hippo4j.core.starter.config.ExecutorProperties;
import cn.hippo4j.core.starter.config.NotifyPlatformProperties; import cn.hippo4j.core.starter.config.NotifyPlatformProperties;
@ -100,14 +101,14 @@ public class CoreNotifyConfigBuilder implements NotifyConfigBuilder {
if (StrUtil.isBlank(receive)) { if (StrUtil.isBlank(receive)) {
receive = bootstrapCoreProperties.getReceive(); receive = bootstrapCoreProperties.getReceive();
if (StrUtil.isBlank(receive)) { if (StrUtil.isBlank(receive)) {
Map<String, String> receives = executor.getNotify().getReceives(); Map<String, String> receives = executor.receives();
receive = receives.get(platformProperties.getPlatform()); receive = receives.get(platformProperties.getPlatform());
} }
} }
} else { } else {
receive = bootstrapCoreProperties.getReceive(); receive = bootstrapCoreProperties.getReceive();
if (StrUtil.isBlank(receive)) { if (StrUtil.isBlank(receive)) {
Map<String, String> receives = executor.getNotify().getReceives(); Map<String, String> receives = executor.receives();
receive = receives.get(platformProperties.getPlatform()); receive = receives.get(platformProperties.getPlatform());
} }
} }

@ -89,7 +89,7 @@ public abstract class AbstractCoreThreadPoolDynamicRefresh implements ThreadPool
); );
threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval()); threadPoolNotifyAlarm.setInterval(executorProperties.getNotify().getInterval());
threadPoolNotifyAlarm.setReceives(executorProperties.getNotify().getReceives()); threadPoolNotifyAlarm.setReceives(executorProperties.receives());
GlobalNotifyAlarmManage.put(executorProperties.getThreadPoolId(), threadPoolNotifyAlarm); GlobalNotifyAlarmManage.put(executorProperties.getThreadPoolId(), threadPoolNotifyAlarm);
}); });
} }

Loading…
Cancel
Save