-
Notifications
You must be signed in to change notification settings - Fork 628
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
Question: Limitations of argument type inferral from target method signature #1269
Comments
Would you mind to show the code produces the problem for you? I'm not sure what drove you to use The reason for the limitation is really about a multi-parameter methods when we can't decide which one is intended for payload injection. |
Env: Spring Boot 2.3.4.RELEASE with spring-boot-starter-amqp Before (working):
Then (broken):
Finally (working again):
The
Exactly, if the reason is about multi-parameter methods, then why are you introducing the requirement for "no annotation" for single parameter methods? This is exactly my question. |
Well, we probably didn't think about any other possible annotation on the single parameter. We indeed going to look into the solution and take away that limitation, so you still can use |
That would be great. I am pretty sure this annotation works, but I can only guess how exactly. Probably some AOP magic that uses the annotation to wrap the class. There are even tutorials out there that are suggesting the double annotation. They probably all have gone through the same route:
The second link suggests that there is validation within the Spring Messaging framework: See |
Ah, right! I forgot that If you have an idea what and where to do already, feel free to contribute the fix! |
…ameter type inference
@artembilan Please have a look at my proposal #1270. I did not have time to change/extend tests though. Sorry. |
FYI, we have test cases at the message handler level, but not for the type inference: Lines 564 to 566 in 60b7a58
Lines 336 to 363 in 60b7a58
|
I found a regression caused by this #1215 while testing this; so I will take this over. |
Resolves spring-projects#1269 Previously, a parameter annotated with a "foreign" annoation (e.g. `@Validated`) would not be considered as an eligible payload conversion target; it must also have been annotated with `@Payload`. - remove the check for zero annotations - add a check that the method is not annotated with both `@Payload` and `@Header` - ignore if it does, with a warn log, to be consistent with previous behavior. - in a future release we might consider this to be fatal. **cherry-pick to 2.2.x**
Regression was a false alarm. New PR issued. |
Resolves #1269 Previously, a parameter annotated with a "foreign" annoation (e.g. `@Validated`) would not be considered as an eligible payload conversion target; it must also have been annotated with `@Payload`. - remove the check for zero annotations - add a check that the method is not annotated with both `@Payload` and `@Header` - ignore if it does, with a warn log, to be consistent with previous behavior. - in a future release we might consider this to be fatal. **cherry-pick to 2.2.x**
Resolves #1269 Previously, a parameter annotated with a "foreign" annoation (e.g. `@Validated`) would not be considered as an eligible payload conversion target; it must also have been annotated with `@Payload`. - remove the check for zero annotations - add a check that the method is not annotated with both `@Payload` and `@Header` - ignore if it does, with a warn log, to be consistent with previous behavior. - in a future release we might consider this to be fatal. **cherry-pick to 2.2.x**
…ated parameter type inference" This reverts commit 040ffb2.
This is just a question: In #390 you created the mechanism for inferring the argument type from the target method signature. You introduced the following limitation:
What is the reasoning for limiting the feature for "single unannotated parameter" methods as opposed to simply "single parameter" methods?
I constantly run into the problem of breaking my listeners when I add a
@Valid
annotation to the input parameter. Then I have to analyze for hours what the problem is until I find the solution of also having to add a@Payload
annotation to make it work again.This is why I came to this question. Is this limitation really necessary? If so, why?
The text was updated successfully, but these errors were encountered: