-
Notifications
You must be signed in to change notification settings - Fork 813
feat: warn when GET method has unannotated parameters #1194
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
feat: warn when GET method has unannotated parameters #1194
Conversation
Signed-off-by: JuHyeong <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @dkswnkk, thanks for submitting the PR. Have added a comment. Please address it.
| MethodMetadata metadata = super.parseAndValidateMetadata(targetType, method); | ||
|
|
||
| if (isGetMethod(metadata) && method.getParameterCount() > 0 && !hasHttpAnnotations(method)) { | ||
| LOG.warn(String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use if (LOG.isWarnEnabled())[...]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your feedback.
I've updated the code to include the LOG.isWarnEnabled() check as you suggested.
Let me know if you have any further comments!
Signed-off-by: JuHyeong <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM.
Summary
This PR addresses issue #1191 by adding a warning when a
@FeignClientmethod is declared asGETbut has one or more parameters that are not annotated with any supported HTTP binding annotations (e.g.,@RequestParam,@RequestHeader,@PathVariable,@SpringQueryMap, etc.).Context
When no annotations are present, Feign may attempt to treat those parameters as a request body. For
GETmethods, this leads to a body-lessPOSTdue to underlying HTTP client behavior (e.g.,HttpURLConnection), which causes a discrepancy:GETPOSTContent-Length: 0)This is difficult to debug and confusing in real-world applications.
Related core issue: OpenFeign/feign#2872
Implementation Details
SpringMvcContract#parseAndValidateMetadata()to check for:GET