提交 683f1fcb 编写于 作者: M mindless

[FIXED HUDSON-8006] fix serialization of array containing null elements,

based on patch from alexlehm


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@36992 71c3de6d-444a-0410-be80-ed276b4c234a
上级 fc6b7d39
......@@ -113,7 +113,7 @@ public class XStream2 extends XStream {
Mapper m = new CompatibilityMapper(new MapperWrapper(next) {
@Override
public String serializedClass(Class type) {
if (ImmutableMap.class.isAssignableFrom(type))
if (type != null && ImmutableMap.class.isAssignableFrom(type))
return super.serializedClass(ImmutableMap.class);
else
return super.serializedClass(type);
......
......@@ -164,4 +164,10 @@ public class XStream2Test extends TestCase {
assertSame(m.getClass(),a.m.getClass()); // should get back the exact same type, not just a random map
assertEquals(m,a.m);
}
// @Bug(8006) -- Previously a null entry in an array caused NPE
public void testEmptyStack() {
assertEquals("<object-array><null/><null/></object-array>",
Run.XSTREAM.toXML(new Object[2]).replaceAll("[ \n\r\t]+", ""));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册