Details
-
Type: Improvement
-
Status: Closed
-
Resolution: Fixed
-
Affects Version/s: None
-
Fix Version/s: None
-
Component/s: None
-
Labels:None
Description
We're using BSFramework to connect our fat clients to EJBs. We are planning to use XStream as an alternate serializer to Java serialization for no-java clients.
It works fine but I'm having a problem with this code:
XStream xstream = new XStream();
xstream.setMode(XStream.NO_REFERENCES);
OutputStream outputStream = response.getOutputStream();
Writer oos = new OutputStreamWriter(outputStream); xstream.toXML(httpServiceResponse, oos);
oos.write(xstream.toXML(httpServiceResponse));
oos.close();
The problem with the code is that though toXML method finishes in (for instance) 1,5 seconds, our clients receive the http response in about 20 seconds.
The problem can be solved easily with this other code:
oos.write(xstream.toXML(httpServiceResponse));
For the meantime we can use this method but it requires more memory and that could became a problem for us with high load.
I think there is a problem on PrettyPrintPrinter.endNode(), there is a "writer.flush();" line that in my opinion should not be there because in Http connections xstream flushes the connection and data is sent back to the client for each node that is created.
Diego,
The latest snapshot has some code in it that causes flush() to only be called at the end of the document.
http://dist.codehaus.org/xstream/jars/xstream-SNAPSHOT.jar
Does this resolve your problem?
cheers
-Joe