Closed hpoettker closed 1 month ago
@OlgaMaciaszek done
@hpoettker Had to revert these changes as, unfortunately, they were messing up native images: https://ge.spring.io/s/elz5iwbaoj2me . Have tried using an ObjectProvider
instead of @Lazy
, but that also hasn't fixed the issue.
@OlgaMaciaszek Thanks for the notice.
I think we've run into https://github.com/spring-projects/spring-framework/issues/29309.
I could reproduce the problem locally. The ObjectProvider
is a great idea and it actually fixes the issue for me. In the linked commit, you applied the change to LoadBalancerBeanPostProcessorAutoConfiguration
. But to fix the AOT smoke test, it must be applied to LoadBalancerAutoConfiguration
as the exception in the build log is about lbRestClientPostProcessor
.
Are you interested in a PR with the ObjectProvider
applied to both auto-configurations?
@hpoettker - yes, that's right. This should fix it: https://github.com/spring-cloud/spring-cloud-commons/tree/use-object-provider-for-lb-restclient-postprocessor
Introduction
The PR resolves the remaining warnings about beans not being eligible for getting processed by all
BeanPostProcessor
s. Similar warnings have been reported in #1315 and fixed in #1319.The warnings do not indicate a severe issue. But they lead to confusion among users and bad getting started experiences. And as the size of the PR shows, the required change is rather small.
Reproducing the issue
The effectiveness of the change can be seen in the following tests:
LoadBalancerRequestFactoryConfigurationTests
ReactorLoadBalancerClientAutoConfigurationTests
Without the change, the test
LoadBalancerRequestFactoryConfigurationTests
logs the following warnings:Without the change, the test
ReactorLoadBalancerClientAutoConfigurationTests
logs the following warnings:With the change, no such warnings appear.
How it works
The PR works by using two mechanisms:
static
, the respective configuration class no longer needs to be instantiated before the methods are invoked.DeferringLoadBalancerInterceptor
orDeferringLoadBalancerExchangeFilterFunction
themselves but only pass on references to builders. Therefore their injection points can be declared to be lazy.