@@ -380,20 +380,19 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
380380 conversionOccurred |= (argument != arguments [i ]);
381381 }
382382
383- Class <?> varArgClass = methodHandleType .lastParameterType (). componentType () ;
383+ Class <?> varArgClass = methodHandleType .lastParameterType ();
384384 ResolvableType varArgResolvableType = ResolvableType .forClass (varArgClass );
385- TypeDescriptor targetType = new TypeDescriptor (varArgResolvableType , varArgClass , null );
385+ TypeDescriptor targetType = new TypeDescriptor (varArgResolvableType , varArgClass . componentType () , null );
386386 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" );
389388
390389 // If the target is varargs and there is just one more argument, then convert it here.
391390 if (varargsPosition == arguments .length - 1 ) {
392391 Object argument = arguments [varargsPosition ];
393392 TypeDescriptor sourceType = TypeDescriptor .forObject (argument );
394393 if (argument == null ) {
395394 // Perform the equivalent of GenericConversionService.convertNullSource() for a single argument.
396- if (componentTypeDesc != null && componentTypeDesc .getObjectType () == Optional .class ) {
395+ if (componentTypeDesc .getObjectType () == Optional .class ) {
397396 arguments [varargsPosition ] = Optional .empty ();
398397 conversionOccurred = true ;
399398 }
@@ -402,7 +401,7 @@ public static boolean convertAllMethodHandleArguments(TypeConverter converter, O
402401 // convert it or wrap it in an array. For example, using StringToArrayConverter to
403402 // convert a String containing a comma would result in the String being split and
404403 // 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 )) {
406405 arguments [varargsPosition ] = converter .convertValue (argument , sourceType , targetType );
407406 }
408407 // Possible outcomes of the above if-else block:
@@ -420,7 +419,7 @@ else if (componentTypeDesc != null && !sourceType.isAssignableTo(componentTypeDe
420419 else {
421420 for (int i = varargsPosition ; i < arguments .length ; i ++) {
422421 Object argument = arguments [i ];
423- arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), targetType );
422+ arguments [i ] = converter .convertValue (argument , TypeDescriptor .forObject (argument ), componentTypeDesc );
424423 conversionOccurred |= (argument != arguments [i ]);
425424 }
426425 }
0 commit comments