Fix [JACKSON-689]
diff --git a/src/mapper/java/org/codehaus/jackson/map/ser/BasicSerializerFactory.java b/src/mapper/java/org/codehaus/jackson/map/ser/BasicSerializerFactory.java
index 0ad25bc..a3bff5a 100644
--- a/src/mapper/java/org/codehaus/jackson/map/ser/BasicSerializerFactory.java
+++ b/src/mapper/java/org/codehaus/jackson/map/ser/BasicSerializerFactory.java
@@ -339,8 +339,10 @@
return buildIteratorSerializer(config, javaType, beanDesc, property, staticTyping);
}
if (Iterable.class.isAssignableFrom(type)) {
+System.err.println("DEBUG: iterable "+type+"? YES");
return buildIterableSerializer(config, javaType, beanDesc, property, staticTyping);
}
+System.err.println("DEBUG: iterable "+type+"? no");
if (CharSequence.class.isAssignableFrom(type)) {
return ToStringSerializer.instance;
}
diff --git a/src/mapper/java/org/codehaus/jackson/map/type/SimpleType.java b/src/mapper/java/org/codehaus/jackson/map/type/SimpleType.java
index dfc3dee..5377228 100644
--- a/src/mapper/java/org/codehaus/jackson/map/type/SimpleType.java
+++ b/src/mapper/java/org/codehaus/jackson/map/type/SimpleType.java
@@ -67,6 +67,19 @@
protected JavaType _narrow(Class<?> subclass)
{
// Should we check that there is a sub-class relationship?
+ /* As per [JACKSON-689], Iterable-to-Collection can be problematic;
+ * needs handling. Not very clean, but can't think of better way
+ * quite yet... revisit if/when we find other special cases
+ */
+ if (_class == Iterable.class) {
+ // Specific issue here: should call TypeFactory, but we have no access...
+ if (Collection.class.isAssignableFrom(subclass)) {
+ JavaType elemType = (_typeParameters == null) ?
+ constructUnsafe(Object.class) : _typeParameters[0];
+ // this is unclean too, ref to other impl type...
+ return CollectionType.construct(subclass, elemType);
+ }
+ }
return new SimpleType(subclass, _typeNames, _typeParameters, _valueHandler, _typeHandler);
}