After upgrading to Sprint Boot 3.4.0, I got this error:
> Task :compileAotTestJava FAILED
C:\Users\fouad\IdeaProjects\spring-boot-3.4-bug\build\generated\aotTestSources\io\fouad\SecurityConfig__TestContext001_BeanDefinitions.java:34: error: incompatible types: BeanInstanceSupplier<SecurityConfig$$SpringCGLIB$$0> cannot be converted to InstanceSupplier<SecurityConfig>
InstanceSupplier<SecurityConfig> instanceSupplier = getSecurityConfigInstanceSupplier();
^
Here is a reproducer: https://github.com/Eng-Fouad/spring-boot-3.4-bug
Comment From: snicoll
@Eng-Fouad thanks for the sample, I can reproduce the problem.
I suppose the actual code is more involved but mixing autowiring like that is a bit strange, especially if you target native images as you may want your config arrangement to be as lean as possible. Rather than mixing things, you could rewrite the constructor as follows:
public SecurityConfig(OAuth2AuthEntryPoint oAuth2AuthEntryPoint, @Value("${app.jwt.signature.public-key}") jwtSignaturePublicKeyBase64) {
this.oAuth2AuthEntryPoint = oAuth2AuthEntryPoint;
this.jwtSignaturePublicKeyBase64 = jwtSignaturePublicKeyBase64;
}
And make jwtSignaturePublicKeyBase64
final. Once you've done that, you can switch @Configuration
to use proxyBeanMethods = false
and it won't have to create a CGLIB proxy for it.
Comment From: Eng-Fouad
@Eng-Fouad thanks for the sample, I can reproduce the problem.
I suppose the actual code is more involved but mixing autowiring like that is a bit strange, especially if you target native images as you may want your config arrangement to be as lean as possible. Rather than mixing things, you could rewrite the constructor as follows:
java public SecurityConfig(OAuth2AuthEntryPoint oAuth2AuthEntryPoint, @Value("${app.jwt.signature.public-key}") jwtSignaturePublicKeyBase64) { this.oAuth2AuthEntryPoint = oAuth2AuthEntryPoint; this.jwtSignaturePublicKeyBase64 = jwtSignaturePublicKeyBase64; }
And make
jwtSignaturePublicKeyBase64
final. Once you've done that, you can switch@Configuration
to useproxyBeanMethods = false
and it won't have to create a CGLIB proxy for it.
Thanks for the tips.
Comment From: snicoll
This regression has a larger scope but you're affected specifically due to the mixed nature of autowiring.