Skip to content

Commit

Permalink
fix: Adjust log output level and override default method (opengoofy#960
Browse files Browse the repository at this point in the history
  • Loading branch information
Createsequence committed Nov 9, 2022
1 parent ed08477 commit 61272ef
Showing 1 changed file with 25 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand All @@ -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());
}
}
}
Expand All @@ -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());
}
}
}
Expand All @@ -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());
}
}
}
Expand All @@ -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 <i>before</i> 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.
* <p>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;
}
}

0 comments on commit 61272ef

Please sign in to comment.