Details
-
Type: Bug
-
Status: 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
catch( Exception ex )
{ ex.printStackTrace(); fail( ex.toString() ); }}
A patch for the fix is attached.
1. test case for two closes without any exception (thats the correct writer behaviour, check javadocs), test case for close+flush --> exception (same comment)
2. changed QuickWriter to be Writer-compliant (same comment)
3. kept PrettyWriter as XStream-compliant (StreamException)
4. kept CompactPrettyWriter as XStream-compliant (StreamException)