Skip to content

Commit

Permalink
Add unit test for OOME in readObject.
Browse files Browse the repository at this point in the history
  • Loading branch information
joehni committed Jul 26, 2021
1 parent 7af4ee0 commit aa25350
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2004, 2005 Joe Walnes.
* Copyright (C) 2006, 2007, 2014, 2018 XStream Committers.
* Copyright (C) 2006, 2007, 2014, 2018, 2021 XStream Committers.
* All rights reserved.
*
* The software in this package is published under the terms of the BSD
Expand All @@ -19,6 +19,7 @@
import java.io.Serializable;

import com.thoughtworks.acceptance.objects.StatusEnum;
import com.thoughtworks.xstream.converters.ConversionException;


/**
Expand Down Expand Up @@ -84,4 +85,24 @@ public void testResolveToNull() throws IOException, ClassNotFoundException {
xstream.alias("toNull", ResolveToNull.class);
assertNull(xstream.fromXML("<toNull><name>test</name></toNull>"));
}

public void testOutOfMemoryInReadObject() {
final String xml = ""
+ "<java.util.PriorityQueue serialization='custom'>\n"
+ " <unserializable-parents/>\n"
+ " <java.util.PriorityQueue>\n"
+ " <default>\n"
+ " <size>2147483647</size>\n"
+ " </default>\n"
+ " <int>2</int>\n"
+ " </java.util.PriorityQueue>\n"
+ "</java.util.PriorityQueue>";

try {
xstream.fromXML(xml);
fail("Thrown " + ConversionException.class.getName() + " expected");
} catch (final ConversionException e) {
// OK
}
}
}

0 comments on commit aa25350

Please sign in to comment.