Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.3.1
-
Fix Version/s: None
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:java version "1.6.0_17" for mac
Description
From CollectionConverter (the super class)
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { Collection collection = (Collection) source; for (Iterator iterator = collection.iterator(); iterator.hasNext();) { Object item = iterator.next(); writeItem(item, context, writer); } }
the following code is commented out in IterableConverter
@Override public void marshal( final Object value, final HierarchicalStreamWriter writer, final MarshallingContext context ) { Iterable<?> it = (Iterable<?>) value; writer.startNode( "list" ); for( Object o : it ) { context.convertAnother( o ); } writer.endNode(); } ...
i'm not sure why the code two bits of code look so different, but a decent fix would seemingly be to cast to an Iterable in CollectionConverter as this will always work, and would otherwise leave code unchanged.
XStream does not contain an IterableConverter.