From 61272ef11d9edc8e80702beab4b58a37e6fa1cf1 Mon Sep 17 00:00:00 2001 From: huangchengxing <841396397@qq.com> Date: Wed, 9 Nov 2022 18:27:08 +0800 Subject: [PATCH] fix: Adjust log output level and override default method (#960)(#959) --- ...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 6f48e8fc49..262cd26884 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 Object postProcessAfterInitialization(Object bean, String beanName) throw } } 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 @@ private void registerThreadPoolPluginSupportIfNecessary(Object bean, Class be 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 @@ private void registerThreadPoolPluginIfNecessary(Object bean, Class beanType) 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 @@ private void registerThreadPoolPluginRegistrarIfNecessary(Object bean, Class 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 void setApplicationContext(ApplicationContext applicationContext) throws 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; + } }