fixed element type bug

master
Keith Donald 15 years ago
parent 5904814ec6
commit 9f8638e557
  1. 6
      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. * 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 * @author Keith Donald
* @since 3.0 * @since 3.0
*/ */
@ -39,8 +40,9 @@ class ObjectToArray implements ConversionExecutor {
} }
public Object execute(Object source) throws ConversionFailedException { public Object execute(Object source) throws ConversionFailedException {
Object array = Array.newInstance(targetArrayType.getType(), 1); Object array = Array.newInstance(targetArrayType.getElementType(), 1);
Array.set(array, 0, elementConverter.execute(source)); Object element = elementConverter.execute(source);
Array.set(array, 0, element);
return array; return array;
} }

Loading…
Cancel
Save