提交 675e3468 编写于 作者: K kohsuke

Intercept an exception so that the stack trace shows how we end up marshalling...

Intercept an exception so that the stack trace shows how we end up marshalling the object in question.

See http://www.nabble.com/Trouble-configuring-Ldap-in-Hudson-running-on-JBoss-5.0.0.GA-td21849403.html

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15097 71c3de6d-444a-0410-be80-ed276b4c234a
上级 41ad84ad
......@@ -135,25 +135,30 @@ public class RobustReflectionConverter implements Converter {
}
private void writeField(String fieldName, String aliasName, Class fieldType, Class definedIn, Object newObj) {
if (!mapper.shouldSerializeMember(definedIn, aliasName)) {
return;
}
ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(definedIn, aliasName), fieldType);
try {
if (!mapper.shouldSerializeMember(definedIn, aliasName)) {
return;
}
ExtendedHierarchicalStreamWriterHelper.startNode(writer, mapper.serializedMember(definedIn, aliasName), fieldType);
Class actualType = newObj.getClass();
Class actualType = newObj.getClass();
Class defaultType = mapper.defaultImplementationOf(fieldType);
if (!actualType.equals(defaultType)) {
writer.addAttribute(mapper.aliasForAttribute("class"), mapper.serializedClass(actualType));
}
Class defaultType = mapper.defaultImplementationOf(fieldType);
if (!actualType.equals(defaultType)) {
writer.addAttribute(mapper.aliasForAttribute("class"), mapper.serializedClass(actualType));
}
if (seenFields.contains(aliasName)) {
writer.addAttribute(mapper.aliasForAttribute("defined-in"), mapper.serializedClass(definedIn));
}
if (seenFields.contains(aliasName)) {
writer.addAttribute(mapper.aliasForAttribute("defined-in"), mapper.serializedClass(definedIn));
}
Field field = reflectionProvider.getField(definedIn,fieldName);
marshallField(context, newObj, field);
writer.endNode();
Field field = reflectionProvider.getField(definedIn,fieldName);
marshallField(context, newObj, field);
writer.endNode();
} catch (RuntimeException e) {
// intercept an exception so that the stack trace shows how we end up marshalling the object in question
throw new RuntimeException("Failed to serialize "+definedIn.getName()+"#"+fieldName+" for "+source.getClass(),e);
}
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册