@@ -379,20 +379,19 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
379
379
conversionOccurred |= (argument != arguments [i ]);
380
380
}
381
381
382
- Class <?> varArgClass = methodHandleType .lastParameterType (). componentType () ;
382
+ Class <?> varArgClass = methodHandleType .lastParameterType ();
383
383
ResolvableType varArgResolvableType = ResolvableType .forClass (varArgClass );
384
- TypeDescriptor targetType = new TypeDescriptor (varArgResolvableType , varArgClass , null );
384
+ TypeDescriptor targetType = new TypeDescriptor (varArgResolvableType , varArgClass . componentType () , null );
385
385
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" );
388
387
389
388
// If the target is varargs and there is just one more argument, then convert it here.
390
389
if (varargsPosition == arguments .length - 1 ) {
391
390
Object argument = arguments [varargsPosition ];
392
391
TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
393
392
if (argument == null ) {
394
393
// Perform the equivalent of GenericConversionService.convertNullSource() for a single argument.
395
- if (componentTypeDesc != null && componentTypeDesc .getObjectType () == Optional .class ) {
394
+ if (componentTypeDesc .getObjectType () == Optional .class ) {
396
395
arguments [varargsPosition ] = Optional .empty ();
397
396
conversionOccurred = true ;
398
397
}
@@ -401,7 +400,7 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
401
400
// convert it or wrap it in an array. For example, using StringToArrayConverter to
402
401
// convert a String containing a comma would result in the String being split and
403
402
// 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 )) {
405
404
arguments [varargsPosition ] = converter .convertValue (argument , sourceType , targetType );
406
405
}
407
406
// Possible outcomes of the above if-else block:
@@ -419,7 +418,7 @@ else if (componentTypeDesc != null && !sourceType.isAssignableTo(componentTypeDe
419
418
else {
420
419
for (int i = varargsPosition ; i < arguments .length ; i ++) {
421
420
Object argument = arguments [i ];
422
- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
421
+ arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), componentTypeDesc );
423
422
conversionOccurred |= (argument != arguments [i ]);
424
423
}
425
424
}
0 commit comments