XStream

PropertiesConverter should sort by key

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.2.2
  • Fix Version/s: 1.3
  • Component/s: Converters
  • Labels:
    None
  • JDK version and platform:
    any

Description

The PropertiesConverter [1] currently serializes its map of key-value entries without ordering them first. Thus the resulting XML may change between runs, which is not very diff-friendly.

A possible solution could look like this (in PropertiesConverter.marshal(...)):

TreeSet s = new TreeSet(properties.keySet());

for (Iterator iterator = s.iterator(); iterator.hasNext() {
Object key = iterator.next();
Object value = properties.get(key);

Cheers,
Christopher

[1] - http://xstream.codehaus.org/javadoc/com/thoughtworks/xstream/converters/collections/PropertiesConverter.html

Activity

Hide
Joerg Schaible added a comment -

I've added this as optional functionality. Since the sorting will take time, is unnecessary regarding functionality and may be surprising for existing applications, you may now register a PropertyConverter instance on your own. The head revision supports a bool parameter to enable the sorting.

Show
Joerg Schaible added a comment - I've added this as optional functionality. Since the sorting will take time, is unnecessary regarding functionality and may be surprising for existing applications, you may now register a PropertyConverter instance on your own. The head revision supports a bool parameter to enable the sorting.
Hide
Joerg Schaible added a comment -

Closing issues before next release.

Show
Joerg Schaible added a comment - Closing issues before next release.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: