-
Notifications
You must be signed in to change notification settings - Fork 38.2k
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
Lambda proxy generation fix causes BeanNotOfRequiredTypeException #28209
Comments
Hi @oliverlockwood, Thanks for raising the issue. It may be a regression. To help use analyze this, can you please provide a minimal sample application (or test class) that reproduces the |
Yes @sbrannen. I have created repo https://github.com/oliverlockwood/spring-framework-issue-28209 which demonstrates this clearly. It turns out that the error case requires an AOP annotation to be applied to the interface being implemented (in this case, I've used Please let me know if you need any further information, but I think it should now be pretty clear. |
Thanks for creating the repo, @oliverlockwood. Much appreciated. We'll look into it. |
It's not because of the use of an annotation. Rather, the AOP advice for That's why the diagnostics generated by Spring Boot include the following.
Here we see that |
This commit extracts isLambda() from AopProxyUtils and makes it publicly available as ClassUtils.isLambdaClass(). This is a prerequisite for gh-28209.
This regression has been fixed in 6fad00e. @oliverlockwood, I tested your example application locally with a patch containing the fix, but it would be great if you could verify the fix on your end using an upcoming 5.3.19 snapshot build and let us know that it works for your. |
I hit the problem described in #27971.
Rather than just adding the
<argLine>--add-opens java.base/java.lang=ALL-UNNAMED</argLine>
to my Surefire configuration, I decided to upgrade to Spring-Boot 2.6.4 (from 2.6.3) to take the fix that was described (because Spring-Boot 2.6.4 uses Spring framework version 5.3.16).However, this led me to a different error, whereby we hit a
org.springframework.beans.factory.BeanNotOfRequiredTypeException
for the lambda bean, specifically:org.springframework.beans.factory.BeanNotOfRequiredTypeException: Bean named 'defaultMyThing' is expected to be of type 'com.oliverlockwood.MyThing' but was actually of type 'jdk.proxy2.$Proxy142'
At present, my not-so-pleasant options seem to come down to:
--add-opens
JVM argument, and get stuck on Spring Boot 2.6.3 (not great)I couldn't see a ticket representing this issue, and as Spring-Boot 2.6.4's only recently been released it is plausible that I might be the first person to hit this.
The text was updated successfully, but these errors were encountered: