Files
spring-framework/spring-core
Chengang Guan 6afb65b225 Fix single-value adaptation for primitive array types in TypeMappedAnnotation
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>
2026-09-30 13:37:25 +02:00
..