Support conversion from primitive array to Object[] in ConversionService
Prior to this commit, the ConversionService failed to convert a primitive array (such as int[]) to an Object[] due to an error in the logic in ArrayToArrayConverter. This commit addresses this by augmenting the "can bypass conversion" check in ArrayToArrayConverter to ensure that the supplied source object is an instance of the target type (i.e., that the source array can be cast to the target type array without conversion). Closes gh-33212
This commit is contained in:
@@ -43,7 +43,6 @@ import java.util.UUID;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.core.MethodParameter;
|
||||
@@ -640,8 +639,7 @@ class DefaultConversionServiceTests {
|
||||
assertThat(result).containsExactly(1, 2, 3);
|
||||
}
|
||||
|
||||
@Disabled("Primitive array to Object[] conversion is not currently supported")
|
||||
@Test
|
||||
@Test // gh-33212
|
||||
void convertIntArrayToObjectArray() {
|
||||
Object[] result = conversionService.convert(new int[] {1, 2}, Object[].class);
|
||||
assertThat(result).containsExactly(1, 2);
|
||||
|
||||
Reference in New Issue
Block a user