Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Warning message about bean post-processing and eager injection may suggest the wrong cause #33184

Closed
Assignees
jhoeller
Labels
in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement
Milestone
@wilkinsona

Description

@wilkinsona

Affects: 6.1

While looking at the sample for#33180 I noticed several warning messages related to eager injection and bean post-processing:

2024-07-10T09:55:40.473+01:00  WARN 593 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'application.SecurityConfig.OAuthSecurityConfig' of type [org.example.testsb.Application$SecurityConfig$OAuthSecurityConfig$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.2024-07-10T09:55:40.501+01:00  WARN 593 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'application.PermissionEvaluatorTest' of type [org.example.testsb.Application$PermissionEvaluatorTest] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.2024-07-10T09:55:40.504+01:00  WARN 593 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'methodSecurityExpressionHandler' of type [org.springframework.security.access.expression.method.DefaultMethodSecurityExpressionHandler] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.2024-07-10T09:55:40.505+01:00  WARN 593 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationManager' of type [org.example.testsb.Application$SecurityConfig$OAuthSecurityConfig$$Lambda$464/0x000000013c380b58] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.2024-07-10T09:55:40.507+01:00  WARN 593 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationEventPublisher' of type [org.springframework.security.authorization.SpringAuthorizationEventPublisher] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.

Each warning suggests that the declaration ofhealthEndpointGroupsBeanPostProcessor and its dependencies should be checked, but I don't think it's the culprit. In each case, the stack when the warning is logged is the following:

Thread [main] (Suspended (breakpoint at line 437 in PostProcessorRegistrationDelegate$BeanPostProcessorChecker))owns: ConcurrentHashMap<K,V>  (id=42)PostProcessorRegistrationDelegate$BeanPostProcessorChecker.postProcessAfterInitialization(Object, String) line: 437DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyBeanPostProcessorsAfterInitialization(Object, String) line: 438DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initializeBean(String, Object, RootBeanDefinition) line: 1789DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 600DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 522DefaultListableBeanFactory(AbstractBeanFactory).lambda$doGetBean$0(String, RootBeanDefinition, Object[]) line: 3260x000000013e1f97e8.getObject() line: not availableDefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory<?>) line: 234DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class<T>, Object[], boolean) line: 324DefaultListableBeanFactory(AbstractBeanFactory).getBean(String) line: 200ConstructorResolver.instantiateUsingFactoryMethod(String, RootBeanDefinition, Object[]) line: 409DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).instantiateUsingFactoryMethod(String, RootBeanDefinition, Object[]) line: 1335DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBeanInstance(String, RootBeanDefinition, Object[]) line: 1165DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 562DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 522DefaultListableBeanFactory(AbstractBeanFactory).lambda$doGetBean$0(String, RootBeanDefinition, Object[]) line: 3260x000000013e1f97e8.getObject() line: not availableDefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory<?>) line: 234DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class<T>, Object[], boolean) line: 324DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class<T>) line: 205AbstractAdvisorAutoProxyCreator$BeanFactoryAdvisorRetrievalHelperAdapter(BeanFactoryAdvisorRetrievalHelper).findAdvisorBeans() line: 91InfrastructureAdvisorAutoProxyCreator(AbstractAdvisorAutoProxyCreator).findCandidateAdvisors() line: 111InfrastructureAdvisorAutoProxyCreator(AbstractAdvisorAutoProxyCreator).findEligibleAdvisors(Class<?>, String) line: 96InfrastructureAdvisorAutoProxyCreator(AbstractAdvisorAutoProxyCreator).getAdvicesAndAdvisorsForBean(Class<?>, String, TargetSource) line: 78InfrastructureAdvisorAutoProxyCreator(AbstractAutoProxyCreator).wrapIfNecessary(Object, String, Object) line: 368InfrastructureAdvisorAutoProxyCreator(AbstractAutoProxyCreator).postProcessAfterInitialization(Object, String) line: 320DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).applyBeanPostProcessorsAfterInitialization(Object, String) line: 438DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).initializeBean(String, Object, RootBeanDefinition) line: 1789DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).doCreateBean(String, RootBeanDefinition, Object[]) line: 600DefaultListableBeanFactory(AbstractAutowireCapableBeanFactory).createBean(String, RootBeanDefinition, Object[]) line: 522DefaultListableBeanFactory(AbstractBeanFactory).lambda$doGetBean$0(String, RootBeanDefinition, Object[]) line: 3260x000000013e1f97e8.getObject() line: not availableDefaultListableBeanFactory(DefaultSingletonBeanRegistry).getSingleton(String, ObjectFactory<?>) line: 234DefaultListableBeanFactory(AbstractBeanFactory).doGetBean(String, Class<T>, Object[], boolean) line: 324DefaultListableBeanFactory(AbstractBeanFactory).getBean(String, Class<T>) line: 205PostProcessorRegistrationDelegate.registerBeanPostProcessors(ConfigurableListableBeanFactory, AbstractApplicationContext) line: 277AnnotationConfigServletWebServerApplicationContext(AbstractApplicationContext).registerBeanPostProcessors(ConfigurableListableBeanFactory) line: 805AnnotationConfigServletWebServerApplicationContext(AbstractApplicationContext).refresh() line: 608AnnotationConfigServletWebServerApplicationContext(ServletWebServerApplicationContext).refresh() line: 146SpringApplication.refresh(ConfigurableApplicationContext) line: 754SpringApplication.refreshContext(ConfigurableApplicationContext) line: 456SpringApplication.run(String...) line: 334SpringApplication.run(Class<?>[], String[]) line: 1354SpringApplication.run(Class<?>, String...) line: 1343Application.main(String[]) line: 34

It's finding eligible advisors that's causing the problem. This is happening throughAbstractAutoProxyCreator.postProcessAfterInitialization(Object, String) that's called afterhealthEndpointGroupsBeanPostProcessor has been created and initialized. The warnings can be reduced by marking the dependencies of the sample'sAdvisor bean,authorizationManagerBeforeMethodInterception, as@Lazy:

@Bean@Role(ROLE_INFRASTRUCTURE)publicAdvisorauthorizationManagerBeforeMethodInterception(@LazyAuthorizationManager<MethodInvocation>authorizationManager,@LazyAuthorizationEventPublisherpublisher) {AuthorizationManagerBeforeMethodInterceptorauthorizationManagerBeforeMethodInterceptor =AuthorizationManagerBeforeMethodInterceptor.preAuthorize(authorizationManager);authorizationManagerBeforeMethodInterceptor.setAuthorizationEventPublisher(publisher);returnauthorizationManagerBeforeMethodInterceptor;}

This reduces the warnings from five to two:

2024-07-10T10:05:55.107+01:00  WARN 3196 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'application.SecurityConfig.OAuthSecurityConfig' of type [org.example.testsb.Application$SecurityConfig$OAuthSecurityConfig$$SpringCGLIB$$0] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.2024-07-10T10:05:55.141+01:00  WARN 3196 --- [testSB3.3.1] [           main] trationDelegate$BeanPostProcessorChecker : Bean 'authorizationEventPublisher' of type [org.springframework.security.authorization.SpringAuthorizationEventPublisher] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying). Is this bean getting eagerly injected into a currently created BeanPostProcessor [healthEndpointGroupsBeanPostProcessor]? Check the corresponding BeanPostProcessor declaration and its dependencies.

Is it possible to detect the case whereAdvisor beans are involved and point people in that direction?

Metadata

Metadata

Assignees

Labels

in: coreIssues in core modules (aop, beans, core, context, expression)type: enhancementA general enhancement

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions


    [8]ページ先頭

    ©2009-2025 Movatter.jp