Details
-
Type: Bug
-
Status: Closed
-
Priority: Major
-
Resolution: Cannot Reproduce
-
Affects Version/s: 1.3.1
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
-
JDK version and platform:JDK1.6 , WebSpherer Application ServerV7.0.0.3 and Windows XP
Description
recently we are upgrade the XStream from v1.1.2 to v1.3.1 and we are facing the below problem.
we are running this application wiht WebSphere Application Server V7.0.0.3 JDK 1.6
code snippet:
Writer buffer = new StringWriter();
PureJavaReflectionProvider reflectionProvider = new PureJavaReflectionProvider();
XmlFriendlyReplacer xfr = new XmlFriendlyReplacer("$","_");
XStream xstream = new XStream(reflectionProvider,new XppDriver());
xstream.setMarshallingStrategy(new ReferenceByXPathMarshallingStrategy());
String tagname="HellowWorld";
String tagval="Hello srinivas";
HierarchicalStreamWriter writer=new PrettyPrintWriter(buffer,xfr);
//below statement is producsing double underscore
writer.startNode("ROOT_ELEMENT");
DataHolder dataHolder=xstream.newDataHolder();
dataHolder.put("OBJECT_NAME","HellowWorld");
xstream.marshal(tagval, writer,dataHolder);
writer.endNode();
writer.close();
String retval=buffer.toString();
System.out.println(""+buffer.toString());
out put from the above code :
<ROOT_ELEMENT>
<string>Hello srinivas</string>
</ROOT_ELEMENT>
but if you runt the same code wiht the XStream1.1.2 in JDK1.5 we are getting the below out put (we reqire the below output)
<ROOT_ELEMENT>
<HelloWorldString class="string">Hello from epc-srinivasv-wxp server </HelloWorldString>
</ROOT_ELEMENT>
is it the bug in wiht latest XStream jar or some thing wrong wiht the program
Well, I was not involved in XStream for 1.1.2, but I don't think that it worked that differently than now in this regard. You ask XStream to marshal a String object and that's exactly what you get. Since the StringConverter does not make usage of the DataHolder (and never has), I have no idea, why you expect a different output.