Details
-
Type: Improvement
-
Status: Closed
-
Priority: Trivial
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: 1.4
-
Component/s: Converters
-
Labels:None
-
JDK version and platform:Sun 1.5_11 under windows
Description
I found it strange that a <no-comparator/> tag ended up in the XML for TreeMaps and TreeSets when the comparator itself was null. It seemed to break XStream's "don't include null values" philosophy which makes for more compact XML.
This patch removes the output of <no-comparator/> while retaining backward compatibility for reading old Tree* XML. It also includes updated test cases for reading XML with the <no-comparator/> for backwards compatibility, reading empty TreeMaps and TreeSets (which are now truly empty), and the various outputs when a comparator is not present.
The only issue is that now output from this converter will not be compatible with old converters. So if XML is written by this, old versions will not be able to read it.
It might be a better idea to make this available as an alternative converter which could be added by user preference. I'm not sure how this has been handled in the past, but I'd be willing to break these changes out into a new set of classes and test cases if that is preferred.
Jason
Issue Links
- relates to
-
XSTR-640 JettisonMappedXmlDriver does not correctly serialise java.util.TreeMap
Thanks for the patch. The code base was too different now, but I followed your implementation idea. Available in HEAD.