在我的 GWT 项目中,我为要在服务调用中抛出的异常链创建了一个精心设计,结果发现getCause()
总是null
在客户端的onFailure()
方法中返回。
通过GWT序列化代码调试后,发现这段代码在SerializabilityUtil
:
private static boolean fieldQualifiesForSerialization(Field field) {
if (Throwable.class == field.getDeclaringClass()) {
/**
* Only serialize Throwable's detailMessage field; all others are ignored.
*
* NOTE: Changing the set of fields that we serialize for Throwable will
* necessitate a change to our JRE emulation's version of Throwable.
*/
if ("detailMessage".equals(field.getName())) {
assert (isNotStaticTransientOrFinal(field));
return true;
} else {
return false;
}
} else {
return isNotStaticTransientOrFinal(field);
}
}
任何人都可以在这里帮助我,为什么 GWT 设计人员会将其放入他们的代码中?真的有什么问题(或安全敏感)Throwable.cause
吗?
这被认为是理所当然的,我如何告诉 GWT 序列化为我的异常类创建一个异常?