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