When an object which extends ConcurrentHashMap is converted to xml and back, then an MissingFieldException is thrown.
The issue come with Java 8 when segmentMask and other properties were defined in serialPersistentFields.
import java.util.concurrent.ConcurrentHashMap;
import com.thoughtworks.xstream.XStream;
public class ConcurrentHashMapTest {
public static void main(String[] args) {
ConcurrentHashMap<String, Integer> map = new ConcurrentHashMap<String, Integer>() {
private static final long serialVersionUID = 1L;
};
XStream xstream = new XStream();
@SuppressWarnings("unchecked")
ConcurrentHashMap<String, Integer> copyOfMap = (ConcurrentHashMap<String, Integer>) xstream.fromXML(xstream.toXML(map));
assert(copyOfMap.equals(map));
}
}
Note: the issue appear only if ConcurrentHashMap is extended.
Tested on XStream 1.4.7, JDK 1.8.0_05.
You found actually a corner case where the serialPersistentFields were used to ignore fields at deserialization. Fixed in trunk.