Menu

#112 DOMInput and DOMOutput implementations have broken schematic

open
nobody
None
5
2012-08-13
2012-08-13
No

(Javax)DOMInput and (Javax)DOMOutput implementations have broken schematics.

DOMOutput domo = new JavaxDOMOutput(...);
ArrayList list1 = new ArrayList();
ArrayList list2 = new ArrayList();

// Equals returns true, like it should
assert list1.equals(list2);

// But using the class like
domo.writeObject(list1);
domo.writeObject(list2);

// Produces
<arraylist id="1">...</arraylist>
<arraylist ref="1"/>
// This is wrong: after reading both objects reference the same instance of ArrayList, even tough originally they were two separate objects

This badness is easy to fix: replace all references to HashMap in both JavaxDOMInput and JavaxDOMOutput with JDK standard IdentityHashMap.

Discussion


Log in to post a comment.

MongoDB Logo MongoDB