Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust log output level and override default method (#960)(#959) #961

Merged
merged 1 commit into from
Nov 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
}
}