diff --git a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/spi/rejected/CustomRejectedExecutionHandler.java b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/spi/rejected/CustomRejectedExecutionHandler.java index 05840b64..7cb297fb 100644 --- a/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/spi/rejected/CustomRejectedExecutionHandler.java +++ b/dynamic-threadpool-spring-boot-starter/src/main/java/io/dynamic/threadpool/starter/spi/rejected/CustomRejectedExecutionHandler.java @@ -1,9 +1,5 @@ package io.dynamic.threadpool.starter.spi.rejected; -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.Setter; - import java.util.concurrent.RejectedExecutionHandler; /** @@ -15,20 +11,17 @@ import java.util.concurrent.RejectedExecutionHandler; public interface CustomRejectedExecutionHandler { /** - * 生成拒绝策略 + * 获取类型 * * @return */ - RejectedExecutionHandlerWrap generateRejected(); - - @Getter - @Setter - @AllArgsConstructor - class RejectedExecutionHandlerWrap { + Integer getType(); - private Integer type; - - private RejectedExecutionHandler rejectedExecutionHandler; + /** + * 生成拒绝策略 + * + * @return + */ + RejectedExecutionHandler generateRejected(); - } } 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 5764fa69..abec6258 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 @@ -72,9 +72,8 @@ public enum RejectedTypeEnum { Collection customRejectedExecutionHandlers = DynamicTpServiceLoader .getSingletonServiceInstances(CustomRejectedExecutionHandler.class); Optional customRejected = customRejectedExecutionHandlers.stream() - .map(each -> each.generateRejected()) .filter(each -> Objects.equals(type, each.getType())) - .map(each -> each.getRejectedExecutionHandler()) + .map(each -> each.generateRejected()) .findFirst(); return customRejected.orElse(ABORT_POLICY.rejectedHandler);