Hi Boris, Boris Partensky wrote:
> Hello, I just looked into upgrading from 1.2.1 to the latest. The > change below seems to have broken compatibility with the old client as > empty collections are now aliased. What is the best way to proceed here? > Upgrade to 1.4.1 and call it done or is there a workaround somewhere. > Thanks! > > http://jira.codehaus.org/browse/XSTR-673 > call stack - > > > Caused by: com.thoughtworks.xstream.mapper.CannotResolveClassException: > empty-list : empty-list > at > com.thoughtworks.xstream.mapper.DefaultMapper.realClass(DefaultMapper.java:49) > at [snip] XStream is normally downward compatible i.e. the newest version can in general read XML generated by an older version out of the box. However, this is not true in the other direction. So if your clients use the old XStream version and your server the new one, the client might fail - this seems your use case here. However, you may create in many cases an XStream instance that will behave nevertheless like the older version. For the empty list you may simply "undo" the alias and the registration of the new converter by overriding both of them with an identity alias and the registration of the converter that handles the type in the old version: Class emptyListType = Collections.EMPTY_LIST.getClass(); xstream.alias(emptyListType.getName(), emptyListType); xstream.registerConverter( new ReflectionConverter(xstream.getMapper(), xstream.getReflectionProvider()) { boolean canConverter(Class type) { return type == emptyListType; } }); Hope this helps, Jörg --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email