diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java index abec6258..ed208402 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/toolkit/thread/RejectedTypeEnum.java @@ -3,7 +3,9 @@ package io.dynamic.threadpool.starter.toolkit.thread; import io.dynamic.threadpool.starter.spi.DynamicTpServiceLoader; import io.dynamic.threadpool.starter.spi.rejected.CustomRejectedExecutionHandler; -import java.util.*; +import java.util.Collection; +import java.util.Objects; +import java.util.Optional; import java.util.concurrent.RejectedExecutionHandler; import java.util.concurrent.ThreadPoolExecutor; import java.util.stream.Stream; @@ -61,6 +63,10 @@ public enum RejectedTypeEnum { this.rejectedHandler = rejectedHandler; } + static { + DynamicTpServiceLoader.register(CustomRejectedExecutionHandler.class); + } + public static RejectedExecutionHandler createPolicy(Integer type) { Optional rejectedTypeEnum = Stream.of(RejectedTypeEnum.values()) .filter(each -> Objects.equals(type, each.type))