@@ -61,15 +61,14 @@ public Object postProcessBeforeInitialization(Object bean, String beanName) {
6161 @ Override
6262 public Object postProcessAfterInitialization (Object bean , String beanName ) throws BeansException {
6363 if (bean instanceof DynamicThreadPoolExecutor || DynamicThreadPoolAdapterChoose .match (bean )) {
64- DynamicThreadPool dynamicThreadPool ;
6564 try {
66- dynamicThreadPool = ApplicationContextHolder .findAnnotationOnBean (beanName , DynamicThreadPool .class );
65+ DynamicThreadPool dynamicThreadPool =
66+ Optional .ofNullable (ApplicationContextHolder .findAnnotationOnBean (beanName ,
67+ DynamicThreadPool .class ))
68+ .orElse (DynamicThreadPoolAnnotationUtil .findAnnotationOnBean (beanName ,
69+ DynamicThreadPool .class ));
6770 if (Objects .isNull (dynamicThreadPool )) {
68- // Adapt to lower versions of SpringBoot.
69- dynamicThreadPool = DynamicThreadPoolAnnotationUtil .findAnnotationOnBean (beanName , DynamicThreadPool .class );
70- if (Objects .isNull (dynamicThreadPool )) {
71- return bean ;
72- }
71+ return bean ;
7372 }
7473 } catch (Exception ex ) {
7574 log .error ("Failed to create dynamic thread pool in annotation mode." , ex );
@@ -79,7 +78,8 @@ public Object postProcessAfterInitialization(Object bean, String beanName) throw
7978 if ((dynamicThreadPoolExecutor = DynamicThreadPoolAdapterChoose .unwrap (bean )) == null ) {
8079 dynamicThreadPoolExecutor = (DynamicThreadPoolExecutor ) bean ;
8180 }
82- DynamicThreadPoolWrapper wrap = new DynamicThreadPoolWrapper (dynamicThreadPoolExecutor .getThreadPoolId (), dynamicThreadPoolExecutor );
81+ DynamicThreadPoolWrapper wrap = new DynamicThreadPoolWrapper (dynamicThreadPoolExecutor .getThreadPoolId (),
82+ dynamicThreadPoolExecutor );
8383 ThreadPoolExecutor remoteThreadPoolExecutor = fillPoolAndRegister (wrap );
8484 DynamicThreadPoolAdapterChoose .replace (bean , remoteThreadPoolExecutor );
8585 return DynamicThreadPoolAdapterChoose .match (bean ) ? bean : remoteThreadPoolExecutor ;
@@ -168,7 +168,8 @@ private ExecutorProperties buildDefaultExecutorProperties(String threadPoolId, T
168168 * @param executorProperties executor properties
169169 */
170170 private void threadPoolParamReplace (ThreadPoolExecutor executor , ExecutorProperties executorProperties ) {
171- BlockingQueue workQueue = BlockingQueueTypeEnum .createBlockingQueue (executorProperties .getBlockingQueue (), executorProperties .getQueueCapacity ());
171+ BlockingQueue workQueue = BlockingQueueTypeEnum .createBlockingQueue (executorProperties .getBlockingQueue (),
172+ executorProperties .getQueueCapacity ());
172173 ReflectUtil .setFieldValue (executor , "workQueue" , workQueue );
173174 executor .setCorePoolSize (executorProperties .getCorePoolSize ());
174175 executor .setMaximumPoolSize (executorProperties .getMaximumPoolSize ());
@@ -205,7 +206,8 @@ private ExecutorProperties buildExecutorProperties(ExecutorProperties executorPr
205206 .orElseGet (() -> Optional .ofNullable (configProperties .getDefaultExecutor ()).map (each -> each .getQueueCapacity ()).get ()))
206207 .rejectedHandler (Optional .ofNullable (executorProperties .getRejectedHandler ())
207208 .orElseGet (() -> Optional .ofNullable (configProperties .getDefaultExecutor ()).map (each -> each .getRejectedHandler ()).get ()))
208- .threadNamePrefix (StringUtil .isBlank (executorProperties .getThreadNamePrefix ()) ? executorProperties .getThreadPoolId () : executorProperties .getThreadNamePrefix ())
209+ .threadNamePrefix (StringUtil .isBlank (executorProperties .getThreadNamePrefix ()) ?
210+ executorProperties .getThreadPoolId () : executorProperties .getThreadNamePrefix ())
209211 .threadPoolId (executorProperties .getThreadPoolId ())
210212 .build ();
211213 return newExecutorProperties ;
@@ -218,7 +220,8 @@ private ExecutorProperties buildExecutorProperties(ExecutorProperties executorPr
218220 * @return thread-pool notify alarm
219221 */
220222 private ThreadPoolNotifyAlarm buildThreadPoolNotifyAlarm (ExecutorProperties executorProperties ) {
221- DynamicThreadPoolNotifyProperties notify = Optional .ofNullable (executorProperties ).map (ExecutorProperties ::getNotify ).orElse (null );
223+ DynamicThreadPoolNotifyProperties notify =
224+ Optional .ofNullable (executorProperties ).map (ExecutorProperties ::getNotify ).orElse (null );
222225 boolean isAlarm = Optional .ofNullable (executorProperties .getAlarm ())
223226 .orElseGet (() -> Optional .ofNullable (configProperties .getDefaultExecutor ()).map (ExecutorProperties ::getAlarm ).orElse (true ));
224227 int activeAlarm = Optional .ofNullable (executorProperties .getActiveAlarm ())
0 commit comments