From 90220fa4545c99873f7e1adda5d43eb5f1efae63 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E6=88=90=E5=85=B4?= <49221670+Createsequence@users.noreply.github.com> Date: Wed, 9 Nov 2022 18:39:22 +0800 Subject: [PATCH] fix: Adjust log output level and override default method (#960)(#959) (#961) --- ...ThreadPoolPluginRegisterPostProcessor.java | 30 +++++++++++++++---- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/ThreadPoolPluginRegisterPostProcessor.java b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/ThreadPoolPluginRegisterPostProcessor.java index 6f48e8fc..262cd268 100644 --- a/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/ThreadPoolPluginRegisterPostProcessor.java +++ b/hippo4j-spring-boot/hippo4j-spring-boot-starter/src/main/java/cn/hippo4j/springboot/starter/support/ThreadPoolPluginRegisterPostProcessor.java @@ -88,7 +88,9 @@ public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPo } } if (Objects.isNull(beanType)) { - log.warn("cannot resolve type for bean [{}]", beanName); + if (log.isDebugEnabled()) { + log.debug("Cannot resolve type for bean [{}]", beanName); + } return bean; } @@ -103,7 +105,7 @@ public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPo if (ThreadPoolPluginSupport.class.isAssignableFrom(beanType)) { ThreadPoolPluginSupport support = (ThreadPoolPluginSupport) bean; if (registerThreadPoolPluginSupport(support) && log.isDebugEnabled()) { - log.info("register ThreadPoolPluginSupport [{}]", support.getThreadPoolId()); + log.debug("Register ThreadPoolPluginSupport [{}]", support.getThreadPoolId()); } } } @@ -112,7 +114,7 @@ public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPo if (ThreadPoolPlugin.class.isAssignableFrom(beanType)) { ThreadPoolPlugin plugin = (ThreadPoolPlugin) bean; if (enableThreadPoolPlugin(plugin) && log.isDebugEnabled()) { - log.info("register ThreadPoolPlugin [{}]", plugin.getId()); + log.debug("Register ThreadPoolPlugin [{}]", plugin.getId()); } } } @@ -121,7 +123,7 @@ public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPo if (ThreadPoolPluginRegistrar.class.isAssignableFrom(beanType)) { ThreadPoolPluginRegistrar registrar = (ThreadPoolPluginRegistrar) bean; if (enableThreadPoolPluginRegistrar(registrar) && log.isDebugEnabled()) { - log.info("register ThreadPoolPluginRegistrar [{}]", registrar.getId()); + log.debug("Register ThreadPoolPluginRegistrar [{}]", registrar.getId()); } } } @@ -145,8 +147,26 @@ public class ThreadPoolPluginRegisterPostProcessor extends DefaultGlobalThreadPo AutowireCapableBeanFactory factory = applicationContext.getAutowireCapableBeanFactory(); Assert.isTrue( factory instanceof ConfigurableListableBeanFactory, - "factory cannot cast to ConfigurableListableBeanFactory"); + "Factory cannot cast to ConfigurableListableBeanFactory"); this.beanFactory = (ConfigurableListableBeanFactory) factory; } + /** + * Apply this {@code BeanPostProcessor} to the given new bean instance before any bean + * initialization callbacks (like InitializingBean's {@code afterPropertiesSet} + * or a custom init-method). The bean will already be populated with property values. + * The returned bean instance may be a wrapper around the original. + *

The default implementation returns the given {@code bean} as-is. + * + * @param bean the new bean instance + * @param beanName the name of the bean + * @return the bean instance to use, either the original or a wrapped one; + * if {@code null}, no subsequent BeanPostProcessors will be invoked + * @throws BeansException in case of errors + * @see InitializingBean#afterPropertiesSet + */ + @Override + public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException { + return bean; + } }