Improve GenericTypeResolver to resolve type variable recursively

Fix GH-24963
This commit is contained in:
Yanming Zhou
2023-03-08 12:55:49 +08:00
committed by Juergen Hoeller
parent 4b2e40153a
commit e788aeb25b
5 changed files with 45 additions and 8 deletions

View File

@@ -67,6 +67,7 @@ import org.springframework.util.StringUtils;
* @author Juergen Hoeller
* @author Sam Brannen
* @author Sebastien Deleuze
* @author Yanming Zhou
* @since 4.2
*/
public class ApplicationListenerMethodAdapter implements GenericApplicationListener {
@@ -177,13 +178,14 @@ public class ApplicationListenerMethodAdapter implements GenericApplicationListe
return true;
}
if (PayloadApplicationEvent.class.isAssignableFrom(eventType.toClass())) {
if (eventType.hasUnresolvableGenerics()) {
return true;
}
ResolvableType payloadType = eventType.as(PayloadApplicationEvent.class).getGeneric();
if (declaredEventType.isAssignableFrom(payloadType)) {
return true;
}
if (payloadType.resolve() == null) {
// Always accept such event when the type is erased
return true;
}
}
}
return false;