Skip to content

Commit abcc1df

Browse files
committed
Review usage of BindingReflectionHintsRegistrar#registerReflectionHints
Closes gh-32753
1 parent 47c5cd2 commit abcc1df

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

Diff for: spring-core/src/main/java/org/springframework/aot/hint/BindingReflectionHintsRegistrar.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public class BindingReflectionHintsRegistrar {
6262
* @param hints the hints instance to use
6363
* @param types the types to register
6464
*/
65-
public void registerReflectionHints(ReflectionHints hints, @Nullable Type... types) {
65+
public void registerReflectionHints(ReflectionHints hints, Type... types) {
6666
Set<Type> seen = new LinkedHashSet<>();
6767
for (Type type : types) {
6868
registerReflectionHints(hints, seen, type);

Diff for: spring-messaging/src/main/java/org/springframework/messaging/handler/annotation/MessageMappingReflectiveProcessor.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -83,7 +83,10 @@ protected void registerParameterHints(ReflectionHints hints, Method method) {
8383
for (Parameter parameter : method.getParameters()) {
8484
MethodParameter methodParameter = MethodParameter.forParameter(parameter);
8585
if (Message.class.isAssignableFrom(methodParameter.getParameterType())) {
86-
this.bindingRegistrar.registerReflectionHints(hints, getMessageType(methodParameter));
86+
Type messageType = getMessageType(methodParameter);
87+
if (messageType != null) {
88+
this.bindingRegistrar.registerReflectionHints(hints, messageType);
89+
}
8790
}
8891
else if (couldBePayload(methodParameter)) {
8992
this.bindingRegistrar.registerReflectionHints(hints, methodParameter.getGenericParameterType());

Diff for: spring-web/src/main/java/org/springframework/web/bind/annotation/ControllerMappingReflectiveProcessor.java

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2023 the original author or authors.
2+
* Copyright 2002-2024 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -84,7 +84,10 @@ protected void registerParameterTypeHints(ReflectionHints hints, MethodParameter
8484
this.bindingRegistrar.registerReflectionHints(hints, methodParameter.getGenericParameterType());
8585
}
8686
else if (HttpEntity.class.isAssignableFrom(methodParameter.getParameterType())) {
87-
this.bindingRegistrar.registerReflectionHints(hints, getHttpEntityType(methodParameter));
87+
Type httpEntityType = getHttpEntityType(methodParameter);
88+
if (httpEntityType != null) {
89+
this.bindingRegistrar.registerReflectionHints(hints, httpEntityType);
90+
}
8891
}
8992
}
9093

@@ -94,7 +97,10 @@ protected void registerReturnTypeHints(ReflectionHints hints, MethodParameter re
9497
this.bindingRegistrar.registerReflectionHints(hints, returnTypeParameter.getGenericParameterType());
9598
}
9699
else if (HttpEntity.class.isAssignableFrom(returnTypeParameter.getParameterType())) {
97-
this.bindingRegistrar.registerReflectionHints(hints, getHttpEntityType(returnTypeParameter));
100+
Type httpEntityType = getHttpEntityType(returnTypeParameter);
101+
if (httpEntityType != null) {
102+
this.bindingRegistrar.registerReflectionHints(hints, httpEntityType);
103+
}
98104
}
99105
}
100106

0 commit comments

Comments
 (0)