java - XStream corrupting values on load and save -


my team has inherited codebase utilizes xstream 1.4.7 load , save xml configuration settings de-/serializes them from/to custom pocos. problem we're having of values getting corrupted during reads or writes. isn't consistently occurring either makes more unusual. in cases, works fine exact same xml , exact same pocos.

a simplified example (i can't post exact code , it's quite bit more complex i'm going easy way explain we're seeing) given xml:

  <monitor>     <autostart>true</autostart>     <name>myvalue</name>   </monitor> 

mapped poco:

public class monitorentry {   public boolean autostart;   public string name; } 

loaded xstream:

xstream xstream = new xstream(new domdriver()); xstream.alias("monitor", monitorentry.class); monitor monitor = (monitor)xstream.fromxml(myfile); 

the value of name in monitor object read in arvalue instead of myvalue. garbage characters @ beginning throws things off. more strangely, if change value of <autostart> element false xml mapped correctly , garbage characters not appear.

to add mystery, on our end we're seeing corruption on loading xml objects, on 1 particular customer system seeing corruption when saving xml objects. in case, it's opposite of above scenario. given same poco name set myvalue, actual xml written xml file becomes:

  <monitor>     <autostart>true</autostart>     <name>arvalue</name>   </monitor> 

now string value such name isn't of functional issue it's name spelled wrong becomes problem when mapping xml value to, example, enum , mapping can't find enum value.

an example being if there enum:

public enum type { value1, value2 }; 

and poco is:

public class monitorentry {   public boolean autostart;   public string name;   public type type; } 

with xml:

  <monitor>     <autostart>true</autostart>     <name>myname</name>     <type>value2</type>   </monitor> 

but xml value being read xstream erlue2 xstream mapping won't able match correct enum value , throws exception such as:

no enum const class com.sample.monitorentry$type.erlue2 

we tried updating xstream 1.4.8 see if perhaps had been fixed behavior persists. codebase set compile java 1.6 we've tried 1.6, 7, , 8 runtimes see if runtime bug or else environmental.

has else seen similar issues or have suggestions on might cause this? can further update post include more detail if necessary. we've used xstream quite bit before never had issues.

edit: not using custom converters in codebase, built-in xstream converters.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -