-
Notifications
You must be signed in to change notification settings - Fork 38.4k
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
Comments
Thanks for the immediate turnaround! I'll revisit what we do differently for mismatching type variable names then. |
This problem seems to be caused by this change e788aeb |
@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 |
No worries, thanks for the feedback! |
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) {}
} |
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.This problem occurs when the generic names declared by IQueryController and ICrudController are inconsistent in the example project.
Expected behavior:
Unexpected behavior:
6.2.x
6.1.x
The text was updated successfully, but these errors were encountered: