8000 Generic type resolve broken after migrate from 3.4.2 to 3.4.3 · Issue #34520 · spring-projects/spring-framework · GitHub
[go: up one dir, main page]

Skip to content
Generic type resolve broken after migrate from 3.4.2 to 3.4.3 #34520
@rmartcas

Description

@rmartcas

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    in: coreIssues in core modules (aop, beans, core, context, expression)status: duplicateA duplicate of another issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0