Skip to content

Fix type-variable resolution across sibling generic interfaces#36931

Open
xfocus3 wants to merge 1 commit into
spring-projects:mainfrom
xfocus3:fix-36890-generic-type-resolver-232839
Open

Fix type-variable resolution across sibling generic interfaces#36931
xfocus3 wants to merge 1 commit into
spring-projects:mainfrom
xfocus3:fix-36890-generic-type-resolver-232839

Conversation

@xfocus3

@xfocus3 xfocus3 commented Jun 15, 2026

Copy link
Copy Markdown

Summary

  • Ensure GenericTypeResolver.resolveType(Type, Class) only resolves a TypeVariable against a parameterized context that declares that same variable.
  • Prevent a sibling generic interface with the same type-variable name from supplying an unrelated binding.
  • Add regression coverage for a controller implementing Search<String, Long> and Create<Long, Long>, where Create's input variable must resolve to Long.

Testing

  • Confirmed the new regression test failed before the fix with expected: java.lang.Long but was: java.lang.String.
  • ./gradlew :spring-core:test --tests org.springframework.core.GenericTypeResolverTests.resolveTypeVariableCollisionAcrossInterfaces
  • ./gradlew :spring-core:test --tests org.springframework.core.GenericTypeResolverTests
  • ./gradlew :spring-core:test
  • ./gradlew :spring-core:check
  • git diff --check

Closes gh-36890

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Jun 15, 2026
@xfocus3 xfocus3 force-pushed the fix-36890-generic-type-resolver-232839 branch from c5d9636 to 2a04d9e Compare June 16, 2026 11:11
Signed-off-by: Ahmed El amraouiyine <amraouiyine@gmail.com>
@xfocus3 xfocus3 force-pushed the fix-36890-generic-type-resolver-232839 branch from 2a04d9e to 143287d Compare June 16, 2026 11:39
@sbrannen sbrannen requested a review from jhoeller June 17, 2026 12:58
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-triage An issue we've not yet triaged or decided on

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GenericTypeResolver.resolveType picks a sibling interface's binding when two interfaces share a type-variable name (breaks @RequestBody deserialization)

3 participants