-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Regression in 6.2.3: No unique bean available for injection point with unresolvable generics #34541
Comments
Thanks for raising the issue, @ML-Marco. I have confirmed that your sample application works with
We'll look into it. |
@sbrannen It doesn't fail with 6.2.2. This might help to find the commit that broke it. |
I apologize: I was unclear. In my tests, it fails against So, it appears that the regression was introduced during the 6.2 milestone/RC phases. |
It's worth noting that the algorithm actually finds two candidates rather than none, so it's a not-unique scenario where it ends up with two candidates which are considered equivalent in terms of the type match. From an initial glance at the repro project, it's not clear to me which one of the two beans is actually meant to be injected there (i.e. which one got injected with the algorithm as it was in 6.1) since both of them look like a match to me. Any insight in terms of the intended design there from your side, @ML-Marco? |
@jhoeller I corrected my statement above. The reproducer does work with 6.2.2 and fails with 6.2.3. |
Oops. I need to correct my above statement as well. I must have had an issue with caching or something. Here are my findings.
And when I say "works", I simply mean it did not throw a |
Given the actual regression in 6.2.3, I have a suspicion that it's caused by #34300 where the handling of nested variable bounds became stricter. I'll try to reproduce this in a unit test. |
A quick update before I resume tomorrow: This turns out to be rather puzzling. Of the 4 The good news is that I can reproduce this with plain PaymentCreator<? extends Payment, PaymentCreatorParameter<? extends Payment>> paymentCreator;
@Test
void testResolvableType() throws Exception {
ResolvableType field = ResolvableType.forField(getClass().getDeclaredField("paymentCreator"));
System.out.println("BankTransferCreator: " + field.isAssignableFrom(BankTransferCreator.class));
System.out.println("DirectDebitCreator: " + field.isAssignableFrom(DirectDebitCreator.class));
System.out.println("ElectronicCashPaymentCreator: " + field.isAssignableFrom(ElectronicCashPaymentCreator.class));
System.out.println("PaymentCreator: " + field.isAssignableFrom(PaymentCreator.class));
} |
Indeed, in Java source code only the concrete The other 3 beans would only be assignable if the declaration of that field were changed to use For example, the following 4 assignments compile for me. PaymentCreator<? extends Payment, PaymentCreatorParameter<? extends Payment>> paymentCreator = new PaymentCreator();
PaymentCreator<? extends Payment, ? extends PaymentCreatorParameter<? extends Payment>> directDebitCreator = new DirectDebitCreator();
PaymentCreator<? extends Payment, ? extends PaymentCreatorParameter<? extends Payment>> bankTransferCreator = new BankTransferCreator();
PaymentCreator<? extends Payment, ? extends PaymentCreatorParameter<? extends Payment>> electronicCashPaymentCreator = new ElectronicCashPaymentCreator(); |
As far as I see now, we tolerate a direct So for some reason, we lost that tolerance for the plain |
The revision is available in the latest 6.2.4 snapshot now. Please give it an early try if you have the chance... |
Tried it, works! Thanks a lot for the quick response. |
Good to hear! Thanks for the immediate feedback. |
Autowiring does not find a suitable candidate in 6.2.3 any more. Throws an exception on startup. This used to work with all previous versions, including 6.2.2.
Reproducer: bug.zip
The text was updated successfully, but these errors were encountered: