Log Message
SerializableConverter is broken if the serialized type is the default implementation.
Modified Paths
Diff
Modified: trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SerializableConverter.java (1959 => 1960)
--- trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SerializableConverter.java 2012-02-15 14:54:03 UTC (rev 1959)
+++ trunk/xstream/src/java/com/thoughtworks/xstream/converters/reflection/SerializableConverter.java 2012-02-15 20:42:14 UTC (rev 1960)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004, 2005, 2006 Joe Walnes.
- * Copyright (C) 2006, 2007, 2008, 2010, 2011 XStream Committers.
+ * Copyright (C) 2006, 2007, 2008, 2010, 2011, 2012 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
@@ -220,6 +220,12 @@
if (serializationMethodInvoker.supportsWriteObject(currentType[0], false)) {
writtenClassWrapper[0] = true;
writer.startNode(mapper.serializedClass(currentType[0]));
+ if (currentType[0] != mapper.defaultImplementationOf(currentType[0])) {
+ String classAttributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
+ if (classAttributeName != null) {
+ writer.addAttribute(classAttributeName, currentType[0].getName());
+ }
+ }
CustomObjectOutputStream objectOutputStream = CustomObjectOutputStream.getInstance(context, callback);
serializationMethodInvoker.callWriteObject(currentType[0], source, objectOutputStream);
objectOutputStream.popCallback();
@@ -230,6 +236,12 @@
// serializable fields. This guarantees that readObject() will be called upon deserialization.
writtenClassWrapper[0] = true;
writer.startNode(mapper.serializedClass(currentType[0]));
+ if (currentType[0] != mapper.defaultImplementationOf(currentType[0])) {
+ String classAttributeName = mapper.aliasForSystemAttribute(ATTRIBUTE_CLASS);
+ if (classAttributeName != null) {
+ writer.addAttribute(classAttributeName, currentType[0].getName());
+ }
+ }
callback.defaultWriteObject();
writer.endNode();
} else {
Modified: trunk/xstream/src/test/com/thoughtworks/acceptance/SerializationNestedWriteObjectsTest.java (1959 => 1960)
--- trunk/xstream/src/test/com/thoughtworks/acceptance/SerializationNestedWriteObjectsTest.java 2012-02-15 14:54:03 UTC (rev 1959)
+++ trunk/xstream/src/test/com/thoughtworks/acceptance/SerializationNestedWriteObjectsTest.java 2012-02-15 20:42:14 UTC (rev 1960)
@@ -302,11 +302,10 @@
}
}
- public void todoTestNestedSerializationOfDefaultType() {
+ public void testNestedSerializationOfDefaultType() {
Calendar in = new MoscowCalendar();
in.setTimeInMillis(44444);
String xml = xstream.toXML(in);
- System.out.println(xml);
Calendar out = (Calendar) xstream.fromXML(xml);
assertEquals(in.getTime(), out.getTime());
}
Modified: trunk/xstream-distribution/src/content/changes.html (1959 => 1960)
--- trunk/xstream-distribution/src/content/changes.html 2012-02-15 14:54:03 UTC (rev 1959)
+++ trunk/xstream-distribution/src/content/changes.html 2012-02-15 20:42:14 UTC (rev 1960)
@@ -38,6 +38,7 @@
<li>JIRA:XSTR-688: Cannot omit XML elements from derived fields.</li>
<li>JIRA:XSTR-685: Deserialization from file or URL keeps stream open.</li>
<li>JIRA:XSTR-684: XML 1.0 character validation fails for characters from 0x10 to 0x1f.</li>
+ <li>SerializableConverter is broken if the serialized type is the default implementation.</li>
</ul>
<h1 id="1.4.2">1.4.2</h1>
To unsubscribe from this list please visit:
