Skip to content
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

Generic type resolve broken after migrate from 3.4.2 to 3.4.3 #34520

Open
rmartcas opened this issue Feb 28, 2025 · 1 comment
Open

Generic type resolve broken after migrate from 3.4.2 to 3.4.3 #34520

rmartcas opened this issue Feb 28, 2025 · 1 comment
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: waiting-for-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on

Comments

@rmartcas
Copy link

After migrate spring from 3.4.2 to 3.4.3 the app is unable to resolve generics.

I have a base structure like that:

`
public abstract class Core implements Serializable {
private static final long serialVersionUID = 1L;
}

interface UpdateableController<T extends Core<?>> {

@PatchMapping(value = "/{id}", produces = MediaType.APPLICATION_JSON_VALUE,    consumes = MediaType.APPLICATION_JSON_VALUE)
public default <E extends Serializable> ResponseEntity<Void> update(@PathVariable E id, @RequestBody T dto, BindingResult bindingResult) {
    ...
}

}

interface CrudController<T extends Core<?>> extends UpdateableController {

}
`

All my controllers inherits from CrudController or other base interface (UpdateableController, InsertableController...), for example:

`
public class Foo extends Core {
private String fooName;
}

interface FooController extends CrudController {

}

@RestController
@RequestMapping("/foo")
class FooControllerImpl implements FooController {
...
}
`

In the previous version the Foo type was resolved and injected to the controller, but after the upgrade the parameter is resolved like Core<?> instead of "Foo".

In the image

Image

ResolvableType.forVariableBounds(typeVariable); is resolving with the generic instead of go to the parent interface to lookup the generic like before.

demo.zip

In the demo zip you can run the code and use the next curl command to test.

curl --location --request PATCH 'http://localhost:8080/foo/1'
--header 'Content-Type: application/json'
--data '{
"fooName": "Hello!"
}'

If you downgrade in the pom to 3.4.2 you can see that the request is resolved correctly.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 28, 2025
@jhoeller
Copy link
Contributor

This looks like a duplicate of #34504. Please try the latest Spring Framework 6.2.4 snapshot and see whether it works for you there...

@bclozel bclozel added status: waiting-for-feedback We need additional information before we can continue in: core Issues in core modules (aop, beans, core, context, expression) labels Feb 28, 2025
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-feedback We need additional information before we can continue status: waiting-for-triage An issue we've not yet triaged or decided on
Projects
None yet
Development

No branches or pull requests

4 participants