pull/1073/head
yangsanity 2 years ago committed by GitHub
parent d05efb466b
commit 10c1ab10fb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -171,8 +171,14 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
private void threadPoolParamReplace(ThreadPoolExecutor executor, ExecutorProperties executorProperties) { private void threadPoolParamReplace(ThreadPoolExecutor executor, ExecutorProperties executorProperties) {
BlockingQueue workQueue = BlockingQueueTypeEnum.createBlockingQueue(executorProperties.getBlockingQueue(), executorProperties.getQueueCapacity()); BlockingQueue workQueue = BlockingQueueTypeEnum.createBlockingQueue(executorProperties.getBlockingQueue(), executorProperties.getQueueCapacity());
ReflectUtil.setFieldValue(executor, "workQueue", workQueue); ReflectUtil.setFieldValue(executor, "workQueue", workQueue);
executor.setCorePoolSize(executorProperties.getCorePoolSize()); // fix https://github.com/opengoofy/hippo4j/issues/1063
executor.setMaximumPoolSize(executorProperties.getMaximumPoolSize()); if (executorProperties.getCorePoolSize() > executor.getMaximumPoolSize()) {
executor.setMaximumPoolSize(executorProperties.getMaximumPoolSize());
executor.setCorePoolSize(executorProperties.getCorePoolSize());
} else {
executor.setCorePoolSize(executorProperties.getCorePoolSize());
executor.setMaximumPoolSize(executorProperties.getMaximumPoolSize());
}
executor.setKeepAliveTime(executorProperties.getKeepAliveTime(), TimeUnit.SECONDS); executor.setKeepAliveTime(executorProperties.getKeepAliveTime(), TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(executorProperties.getAllowCoreThreadTimeOut()); executor.allowCoreThreadTimeOut(executorProperties.getAllowCoreThreadTimeOut());
executor.setRejectedExecutionHandler(RejectedPolicyTypeEnum.createPolicy(executorProperties.getRejectedHandler())); executor.setRejectedExecutionHandler(RejectedPolicyTypeEnum.createPolicy(executorProperties.getRejectedHandler()));

@ -178,8 +178,14 @@ public final class DynamicThreadPoolPostProcessor implements BeanPostProcessor {
private void threadPoolParamReplace(ThreadPoolExecutor executor, ThreadPoolParameterInfo threadPoolParameterInfo) { private void threadPoolParamReplace(ThreadPoolExecutor executor, ThreadPoolParameterInfo threadPoolParameterInfo) {
BlockingQueue workQueue = BlockingQueueTypeEnum.createBlockingQueue(threadPoolParameterInfo.getQueueType(), threadPoolParameterInfo.getCapacity()); BlockingQueue workQueue = BlockingQueueTypeEnum.createBlockingQueue(threadPoolParameterInfo.getQueueType(), threadPoolParameterInfo.getCapacity());
ReflectUtil.setFieldValue(executor, "workQueue", workQueue); ReflectUtil.setFieldValue(executor, "workQueue", workQueue);
executor.setCorePoolSize(threadPoolParameterInfo.corePoolSizeAdapt()); // fix https://github.com/opengoofy/hippo4j/issues/1063
executor.setMaximumPoolSize(threadPoolParameterInfo.maximumPoolSizeAdapt()); if (threadPoolParameterInfo.getCorePoolSize() > executor.getMaximumPoolSize()) {
executor.setMaximumPoolSize(threadPoolParameterInfo.maximumPoolSizeAdapt());
executor.setCorePoolSize(threadPoolParameterInfo.corePoolSizeAdapt());
} else {
executor.setCorePoolSize(threadPoolParameterInfo.corePoolSizeAdapt());
executor.setMaximumPoolSize(threadPoolParameterInfo.maximumPoolSizeAdapt());
}
executor.setKeepAliveTime(threadPoolParameterInfo.getKeepAliveTime(), TimeUnit.SECONDS); executor.setKeepAliveTime(threadPoolParameterInfo.getKeepAliveTime(), TimeUnit.SECONDS);
executor.allowCoreThreadTimeOut(EnableEnum.getBool(threadPoolParameterInfo.getAllowCoreThreadTimeOut())); executor.allowCoreThreadTimeOut(EnableEnum.getBool(threadPoolParameterInfo.getAllowCoreThreadTimeOut()));
executor.setRejectedExecutionHandler(RejectedPolicyTypeEnum.createPolicy(threadPoolParameterInfo.getRejectedType())); executor.setRejectedExecutionHandler(RejectedPolicyTypeEnum.createPolicy(threadPoolParameterInfo.getRejectedType()));

Loading…
Cancel
Save