XStream
  1. XStream
  2. XSTR-680

Concurrent use of XStream instance with shared output stream leads to exception

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Priority: Major Major
    • Resolution: Not A Bug
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: Core, IO
    • Labels:
      None
    • JDK version and platform:
      Java HotSpot Server VM "1.6.0_07"; Linux

      Description

      Hi,

      I get an exception when using an XStream instance from different threads that pass the same output stream to the XStream instance. I'll attach a small example to illustrate the problem. Please see the stack trace below.

      Is this a bug or am I misreading the documentation? It says that the XStream instance can be shared across multiple threads and doesn't specify any constraints on the parameters given to the serializing/deserializing methods.

      Thanks!

      Exception in thread "Thread-19" com.thoughtworks.xstream.io.StreamException: : Writing text without an opened node
      at com.thoughtworks.xstream.io.StatefulWriter.setValue(StatefulWriter.java:120)
      at com.thoughtworks.xstream.io.WriterWrapper.setValue(WriterWrapper.java:45)
      at com.thoughtworks.xstream.converters.extended.EncodedByteArrayConverter.marshal(EncodedByteArrayConverter.java:43)
      at com.thoughtworks.xstream.core.AbstractReferenceMarshaller.convert(AbstractReferenceMarshaller.java:69)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:59)
      at com.thoughtworks.xstream.core.TreeMarshaller.convertAnother(TreeMarshaller.java:44)
      at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:79)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:877)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:866)
      at com.thoughtworks.xstream.XStream$1.writeToStream(XStream.java:1626)
      at com.thoughtworks.xstream.core.util.CustomObjectOutputStream.write(CustomObjectOutputStream.java:138)
      at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:202)
      at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:272)
      at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:276)
      at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:122)
      at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:212)
      at com.thoughtworks.xstream.core.util.QuickWriter.flush(QuickWriter.java:75)
      at com.thoughtworks.xstream.io.xml.PrettyPrintWriter.endNode(PrettyPrintWriter.java:316)
      at com.thoughtworks.xstream.io.WriterWrapper.endNode(WriterWrapper.java:37)
      at com.thoughtworks.xstream.io.path.PathTrackingWriter.endNode(PathTrackingWriter.java:48)
      at com.thoughtworks.xstream.core.TreeMarshaller.start(TreeMarshaller.java:80)
      at com.thoughtworks.xstream.core.AbstractTreeMarshallingStrategy.marshal(AbstractTreeMarshallingStrategy.java:37)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:877)
      at com.thoughtworks.xstream.XStream.marshal(XStream.java:866)
      at com.thoughtworks.xstream.XStream.toXML(XStream.java:854)
      at XStreamTest4$2.run(XStreamTest4.java:27)
      at java.lang.Thread.run(Thread.java:619)
      Caused by: java.lang.IllegalStateException: Writing text without an opened node
      ... 28 more

        People

        • Assignee:
          Jörg Schaible
          Reporter:
          Michael Pradel
        • Votes:
          0 Vote for this issue
          Watchers:
          1 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: