Browse Source

Review usage of BindingReflectionHintsRegistrar#registerReflectionHints

Closes gh-32753
pull/32864/head
Stéphane Nicoll 2 years ago
parent
commit
abcc1dfc6c
  1. 2
      spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java
  2. 7
      spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMappingReflectiveProcessor.java
  3. 12
      spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerMappingReflectiveProcessor.java

2
spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java

@ -62,7 +62,7 @@ public class BindingReflectionHintsRegistrar { @@ -62,7 +62,7 @@ public class BindingReflectionHintsRegistrar {
* @param hints the hints instance to use
* @param types the types to register
*/
public void registerReflectionHints(ReflectionHints hints, @Nullable Type... types) {
public void registerReflectionHints(ReflectionHints hints, Type... types) {
Set<Type> seen = new LinkedHashSet<>();
for (Type type : types) {
registerReflectionHints(hints, seen, type);

7
spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMappingReflectiveProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -83,7 +83,10 @@ public class MessageMappingReflectiveProcessor implements ReflectiveProcessor { @@ -83,7 +83,10 @@ public class MessageMappingReflectiveProcessor implements ReflectiveProcessor {
for (Parameter parameter : method.getParameters()) {
MethodParameter methodParameter = MethodParameter.forParameter(parameter);
if (Message.class.isAssignableFrom(methodParameter.getParameterType())) {
this.bindingRegistrar.registerReflectionHints(hints, getMessageType(methodParameter));
Type messageType = getMessageType(methodParameter);
if (messageType != null) {
this.bindingRegistrar.registerReflectionHints(hints, messageType);
}
}
else if (couldBePayload(methodParameter)) {
this.bindingRegistrar.registerReflectionHints(hints, methodParameter.getGenericParameterType());

12
spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerMappingReflectiveProcessor.java

@ -1,5 +1,5 @@ @@ -1,5 +1,5 @@
/*
* Copyright 2002-2023 the original author or authors.
* Copyright 2002-2024 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@ -84,7 +84,10 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor { @@ -84,7 +84,10 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor {
this.bindingRegistrar.registerReflectionHints(hints, methodParameter.getGenericParameterType());
}
else if (HttpEntity.class.isAssignableFrom(methodParameter.getParameterType())) {
this.bindingRegistrar.registerReflectionHints(hints, getHttpEntityType(methodParameter));
Type httpEntityType = getHttpEntityType(methodParameter);
if (httpEntityType != null) {
this.bindingRegistrar.registerReflectionHints(hints, httpEntityType);
}
}
}
@ -94,7 +97,10 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor { @@ -94,7 +97,10 @@ class ControllerMappingReflectiveProcessor implements ReflectiveProcessor {
this.bindingRegistrar.registerReflectionHints(hints, returnTypeParameter.getGenericParameterType());
}
else if (HttpEntity.class.isAssignableFrom(returnTypeParameter.getParameterType())) {
this.bindingRegistrar.registerReflectionHints(hints, getHttpEntityType(returnTypeParameter));
Type httpEntityType = getHttpEntityType(returnTypeParameter);
if (httpEntityType != null) {
this.bindingRegistrar.registerReflectionHints(hints, httpEntityType);
}
}
}

Loading…
Cancel
Save