XStream
  1. XStream
  2. XSTR-244

Exception when close() called twice

    Details

    • Type: Bug Bug
    • Status: Closed Closed
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 1.2
    • Component/s: None
    • Labels:
      None
    • JDK version and platform:
      1.5.0_02 for Macintosh

      Description

      Calling close() multiple times on an ObjectOutputStream created by calling XStream.createObjectOutputStream(...) results in an ArrayIndexOutOfBoundsException. It should detect that it has already been closed and ignore the call.

      Here's a test case that can be put in XStreamTest.java:

      public void testMultipleClose() {
      try

      { StringWriter sout = new StringWriter(); ObjectOutputStream oout = xstream.createObjectOutputStream( sout ); oout.writeObject( new Integer( 1 ) ); oout.close(); oout.close(); }

      catch( Exception ex )

      { ex.printStackTrace(); fail( ex.toString() ); }

      }

      A patch for the fix is attached.

      1. patch.txt
        4 kB
        Guilherme Silveira
      2. patch.txt
        5 kB
        Guilherme Silveira
      3. patch.txt
        11 kB
        Guilherme Silveira
      4. XStream.java.patch
        0.5 kB
        Rob Eden

        People

        • Assignee:
          Unassigned
          Reporter:
          Rob Eden
        • Votes:
          0 Vote for this issue
          Watchers:
          0 Start watching this issue

          Dates

          • Created:
            Updated:
            Resolved: