提交 1874b397 编写于 作者: K kohsuke

fixing the de-serialization of AxisList.

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@11148 71c3de6d-444a-0410-be80-ed276b4c234a
上级 f1062a0a
......@@ -4,6 +4,8 @@ import com.thoughtworks.xstream.alias.CannotResolveClassException;
import com.thoughtworks.xstream.converters.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext;
import com.thoughtworks.xstream.converters.reflection.SerializableConverter;
import com.thoughtworks.xstream.converters.reflection.ReflectionProvider;
import com.thoughtworks.xstream.converters.collections.AbstractCollectionConverter;
import com.thoughtworks.xstream.io.HierarchicalStreamReader;
import com.thoughtworks.xstream.io.HierarchicalStreamWriter;
......@@ -87,8 +89,10 @@ public class AxisList extends ArrayList<Axis> {
* {@link Converter} implementation for XStream.
*/
public static final class ConverterImpl extends AbstractCollectionConverter {
public ConverterImpl(Mapper mapper) {
private final SerializableConverter sc;
public ConverterImpl(Mapper mapper, ReflectionProvider reflectionProvider) {
super(mapper);
sc = new SerializableConverter(mapper,reflectionProvider);
}
public boolean canConvert(Class type) {
......@@ -102,6 +106,13 @@ public class AxisList extends ArrayList<Axis> {
@SuppressWarnings("unchecked")
public AxisList unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
// AxisList used to serialize as custom serialization,
// so read it in a compatible fashion.
String s = reader.getAttribute("serialization");
if(s!=null && s.equals("custom")) {
return (AxisList)sc.unmarshal(reader,context);
}
// read the items from xml into a list
List items = new ArrayList();
while (reader.hasMoreChildren()) {
......
......@@ -47,7 +47,7 @@ public class XStream2 extends XStream {
registerConverter(new RobustCollectionConverter(getMapper(),getReflectionProvider()),10);
registerConverter(new CopyOnWriteList.ConverterImpl(getMapper()),10);
registerConverter(new DescribableList.ConverterImpl(getMapper()),10);
registerConverter(new AxisList.ConverterImpl(getMapper()),10);
registerConverter(new AxisList.ConverterImpl(getMapper(),getReflectionProvider()),10);
registerConverter(new CopyOnWriteMap.Tree.ConverterImpl(getMapper()),10); // needs to override MapConverter
// this should come after all the XStream's default simpler converters,
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册