Skip to content

Do not warn if first parameter of GetMapping is of type URL#1327

Merged
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
ryanjbaxter:deal-with-warning-uri-param
Feb 18, 2026
Merged

Do not warn if first parameter of GetMapping is of type URL#1327
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
ryanjbaxter:deal-with-warning-uri-param

Conversation

@ryanjbaxter
Copy link
Copy Markdown
Contributor

Fixes #1326

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes incorrect startup warning emitted by SpringMvcContract for @GetMapping methods whose only parameter is a dynamic java.net.URI (the case described in #1326).

Changes:

  • Adjust GET/unannotated-parameter warning logic to skip a leading URI parameter when deciding whether to warn.
  • Add contract tests that capture log output to verify warning/no-warning behavior for URI and non-URI parameters.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
spring-cloud-openfeign-core/src/main/java/org/springframework/cloud/openfeign/support/SpringMvcContract.java Refactors warning condition into shouldWarnAboutUnannotatedGetParameters() and suppresses warnings for single-URI GET methods.
spring-cloud-openfeign-core/src/test/java/org/springframework/cloud/openfeign/support/SpringMvcContractTests.java Adds OutputCaptureExtension and new tests asserting warning behavior for URI vs. unannotated params.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +260 to +266
private boolean shouldWarnAboutUnannotatedGetParameters(Method method) {
Parameter[] params = method.getParameters();
if (params.length == 1 && params[0].getType() == URI.class) {
return false;
}
int fromIndex = (params.length > 0 && params[0].getType() == URI.class) ? 1 : 0;
return !hasHttpAnnotations(method, fromIndex);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR title mentions the first parameter being of type URL, but the implementation and tests only special-case java.net.URI. Either update the PR title (and/or issue reference) to say URI, or extend the implementation to also treat java.net.URL (if that’s the intended supported dynamic-target parameter type) the same way to avoid user confusion and incomplete coverage of the reported behavior.

Copilot uses AI. Check for mistakes.
@ryanjbaxter ryanjbaxter force-pushed the deal-with-warning-uri-param branch from ed3f41d to 0b1397f Compare February 18, 2026 21:41
@ryanjbaxter ryanjbaxter marked this pull request as ready for review February 18, 2026 21:42
@ryanjbaxter ryanjbaxter merged commit a91d8f5 into spring-cloud:4.3.x Feb 18, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature "warn when GET method has unannotated parameters" causes incorrect warning for methods with a single URI parameter.

4 participants