mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-01 03:39:05 +00:00
Prior to this commit, `adaptForAttribute(Method, Object)` created the wrapping array from `value.getClass()` when a single non-array value was provided for an array attribute. This worked for object array types but failed for primitive array types: wrapping a boxed value produced a boxed array, which then failed the compatibility check and threw an `IllegalStateException`. This commit derives the component type from the declared attribute type when it is assignable from the value type, falling back to `value.getClass()` otherwise. The existing adaptation path for object array types is therefore preserved, and all primitive array types now accept a single value. The accompanying test covers single-value wrapping for every array type declared by ArrayTypes. Closes gh-37349 Signed-off-by: Chengang Guan <guanchengang@qq.com>