Skip to content

Commit f7d4742

Browse files
committed
Merge branch '6.1.x'
2 parents 4de2aad + fa2a58b commit f7d4742

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

spring-expression/src/main/java/org/springframework/expression/spel/support/ReflectionHelper.java

+6-7
Original file line numberDiff line numberDiff line change
@@ -379,20 +379,19 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
379379
conversionOccurred |= (argument != arguments[i]);
380380
}
381381

382-
Class<?> varArgClass = methodHandleType.lastParameterType().componentType();
382+
Class<?> varArgClass = methodHandleType.lastParameterType();
383383
ResolvableType varArgResolvableType = ResolvableType.forClass(varArgClass);
384-
TypeDescriptor targetType = new TypeDescriptor(varArgResolvableType, varArgClass, null);
384+
TypeDescriptor targetType = new TypeDescriptor(varArgResolvableType, varArgClass.componentType(), null);
385385
TypeDescriptor componentTypeDesc = targetType.getElementTypeDescriptor();
386-
// TODO Determine why componentTypeDesc can be null.
387-
// Assert.state(componentTypeDesc != null, "Component type must not be null for a varargs array");
386+
Assert.state(componentTypeDesc != null, "Component type must not be null for a varargs array");
388387

389388
// If the target is varargs and there is just one more argument, then convert it here.
390389
if (varargsPosition == arguments.length - 1) {
391390
Object argument = arguments[varargsPosition];
392391
TypeDescriptor sourceType = TypeDescriptor.forObject(argument);
393392
if (argument == null) {
394393
// Perform the equivalent of GenericConversionService.convertNullSource() for a single argument.
395-
if (componentTypeDesc != null && componentTypeDesc.getObjectType() == Optional.class) {
394+
if (componentTypeDesc.getObjectType() == Optional.class) {
396395
arguments[varargsPosition] = Optional.empty();
397396
conversionOccurred = true;
398397
}
@@ -401,7 +400,7 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
401400
// convert it or wrap it in an array. For example, using StringToArrayConverter to
402401
// convert a String containing a comma would result in the String being split and
403402
// repackaged in an array when it should be used as-is.
404-
else if (componentTypeDesc != null && !sourceType.isAssignableTo(componentTypeDesc)) {
403+
else if (!sourceType.isAssignableTo(componentTypeDesc)) {
405404
arguments[varargsPosition] = converter.convertValue(argument, sourceType, targetType);
406405
}
407406
// Possible outcomes of the above if-else block:
@@ -419,7 +418,7 @@ else if (componentTypeDesc != null && !sourceType.isAssignableTo(componentTypeDe
419418
else {
420419
for (int i = varargsPosition; i < arguments.length; i++) {
421420
Object argument = arguments[i];
422-
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), targetType);
421+
arguments[i] = converter.convertValue(argument, TypeDescriptor.forObject(argument), componentTypeDesc);
423422
conversionOccurred |= (argument != arguments[i]);
424423
}
425424
}

0 commit comments

Comments
 (0)