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

GenericTypeResolver Since 6.2.0, generics cannot be obtained correctly in multi-layer interface inheritance (possible regression of #24963) #34386

Closed
fangzhengjin opened this issue Feb 7, 2025 · 8 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) status: feedback-provided Feedback has been provided type: regression A bug that is also a regression
Milestone

Comments

@fangzhengjin
Copy link

fangzhengjin commented Feb 7, 2025

Minimal sample application: https://github.com/fangzhengjin/spring-framework-issues-34386

Start the program and execute the request below.

Observe the input arguments to the com.example.demo.IQueryController#test method.

curl -X POST 'localhost:8080/test' -H 'Content-Type: application/json' -d '{"data":{"name":"test"}}'

This problem occurs when the generic names declared by IQueryController and ICrudController are inconsistent in the example project.

Expected behavior:

public interface IQueryController<Entity>

public interface ICrudController<Entity> extends IQueryController<Entity>

Unexpected behavior:

public interface IQueryController<QueryParam>

public interface ICrudController<Entity> extends IQueryController<Entity>

6.2.x

Image

Image

6.1.x

Image

Image

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 7, 2025
@fangzhengjin fangzhengjin changed the title GenericTypeResolver Since 6.2.0, generics cannot be obtained correctly in multi-layer interface inheritance GenericTypeResolver Since 6.2.0, generics cannot be obtained correctly in multi-layer interface inheritance (possible regression of #24963) Feb 7, 2025
@jhoeller jhoeller added the in: core Issues in core modules (aop, beans, core, context, expression) label Feb 7, 2025
@jhoeller jhoeller self-assigned this Feb 7, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Feb 7, 2025

This looks like a variant of the recently fixed #34328. Could you try the latest 6.2.3 snapshot (overriding the framework version as stated in the comments on #34217) and see whether your specific problem still remains?

@jhoeller jhoeller added the status: waiting-for-feedback We need additional information before we can continue label Feb 7, 2025
@fangzhengjin
Copy link
Author

This looks like a variant of the recently fixed #34328. Could you try the latest 6.2.3 snapshot (overriding the framework version as stated in the comments on #34217) and see whether your specific problem still remains?

6.2.3 snapshot problem still remains.

Image

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Feb 7, 2025
@jhoeller
Copy link
Contributor

jhoeller commented Feb 7, 2025

Thanks for the immediate turnaround! I'll revisit what we do differently for mismatching type variable names then.

@jhoeller jhoeller added the type: regression A bug that is also a regression label Feb 7, 2025
@jhoeller jhoeller added this to the 6.2.3 milestone Feb 7, 2025
@fangzhengjin
Copy link
Author

This problem seems to be caused by this change e788aeb

@snicoll snicoll removed the status: waiting-for-triage An issue we've not yet triaged or decided on label Feb 10, 2025
@jhoeller
Copy link
Contributor

@fangzhengjin this should be fixed in the latest 6.2.3 snapshot, please give it another try if you have the chance...

@fangzhengjin
Copy link
Author

@fangzhengjin this should be fixed in the latest 6.2.3 snapshot, please give it another try if you have the chance...

Sorry I'm late, he works fine in spring-framework 6.2.3 and spring-boot 3.4.3

@jhoeller
Copy link
Contributor

No worries, thanks for the feedback!

@nealeu
Copy link

nealeu commented Feb 26, 2025

Just did my min reproducible app and found it fixed so I can confirm this scenario also fixed in 6.2.3

@SpringBootApplication
public class Application {
    public static void main(String[] args) {
        SpringApplication.run(Application.class, args);
    }

    @RestController
    public static class HelloController {
        /** Fails in Spring 6.2.2 with at <a href="http://localhost:8080/thing1">thing1</a> */
        @GetMapping("/{thing}")
        public <T> List<ThingConfig<T>> list(@PathVariable ConfigurableThing<T> thing) {
            return serviceMethod(thing.thingClass());
        }

        private <T> List<ThingConfig<T>> serviceMethod(Class<T> tClass) {
            return List.of( new ThingConfig<>(new ConfigurableThing<>(tClass)));
        }
    }

    @Component
    public static class String2ThingConverter implements Converter<String, ConfigurableThing<?>> {
        private final Map<String, ConfigurableThing<?>> thingsBySimpleClassName = Map.of("thing1", new ConfigurableThing<>(Object.class));

        @Override
        public ConfigurableThing<?> convert(@NonNull String source) {
            return thingsBySimpleClassName.get(source);
        }
    }

    public record ConfigurableThing<T>(Class<T> thingClass) {}
    public record ThingConfig<T>(ConfigurableThing<T> forThing) {}
}

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: feedback-provided Feedback has been provided type: regression A bug that is also a regression
Projects
None yet
Development

No branches or pull requests

5 participants