XStream
  1. XStream
  2. XSTR-146

Problem with toXML(Object, Writer) and http connections

    Details

    • Type: Improvement Improvement
    • Status: Closed 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.

        People

        • Assignee:
          Unassigned
          Reporter:
          Diego Lopez
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: