From 9f8638e5570ead0458e7132905fe3827455e73f2 Mon Sep 17 00:00:00 2001 From: Keith Donald Date: Sun, 12 Jul 2009 18:29:19 +0000 Subject: [PATCH] fixed element type bug --- .../springframework/core/convert/support/ObjectToArray.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArray.java b/org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArray.java index 5174114274..cb15f9ae45 100644 --- a/org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArray.java +++ b/org.springframework.core/src/main/java/org/springframework/core/convert/support/ObjectToArray.java @@ -22,6 +22,7 @@ import org.springframework.core.convert.TypeDescriptor; /** * Converts an object to a single-element array. + * TODO - this class throws cryptic exception if it can't convert to required target array element type. * @author Keith Donald * @since 3.0 */ @@ -39,8 +40,9 @@ class ObjectToArray implements ConversionExecutor { } public Object execute(Object source) throws ConversionFailedException { - Object array = Array.newInstance(targetArrayType.getType(), 1); - Array.set(array, 0, elementConverter.execute(source)); + Object array = Array.newInstance(targetArrayType.getElementType(), 1); + Object element = elementConverter.execute(source); + Array.set(array, 0, element); return array; }