Skip to content

Commit ec037b1

Browse files
committed
Polish "Add support for multidimensional arrays"
See gh-34183
1 parent 68c1e2a commit ec037b1

File tree

2 files changed

+8
-13
lines changed

2 files changed

+8
-13
lines changed

spring-beans/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java

+7-12
Original file line numberDiff line numberDiff line change
@@ -933,21 +933,16 @@ else if (Map.class.isAssignableFrom(type)) {
933933
* @param arrayType the desired type of the target array
934934
* @return a new array instance
935935
*/
936-
private Object createArray(Class<?> arrayType) {
936+
private static Object createArray(Class<?> arrayType) {
937937
Assert.notNull(arrayType, "Array type must not be null");
938-
if (arrayType.isArray()) {
939-
Class<?> componentType = arrayType.componentType();
940-
if (componentType.isArray()) {
941-
Object array = Array.newInstance(componentType, 1);
942-
Array.set(array, 0, createArray(componentType));
943-
return array;
944-
}
945-
else {
946-
return Array.newInstance(componentType, 0);
947-
}
938+
Class<?> componentType = arrayType.componentType();
939+
if (componentType.isArray()) {
940+
Object array = Array.newInstance(componentType, 1);
941+
Array.set(array, 0, createArray(componentType));
942+
return array;
948943
}
949944
else {
950-
throw new IllegalArgumentException("Unsupported Array type: " + arrayType.getName());
945+
return Array.newInstance(componentType, 0);
951946
}
952947
}
953948

spring-beans/src/test/java/org/springframework/beans/BeanWrapperAutoGrowingTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2024 the original author or authors.
2+
* Copyright 2002-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)