提交 175817fd 编写于 作者: D darcy

7038843: IIOP serialization fails with NullPointerException when serializing Throwable

Reviewed-by: dholmes, mchung
上级 1e875b07
...@@ -848,10 +848,9 @@ public class Throwable implements Serializable { ...@@ -848,10 +848,9 @@ public class Throwable implements Serializable {
throw new NullPointerException("stackTrace[" + i + "]"); throw new NullPointerException("stackTrace[" + i + "]");
} }
if (this.stackTrace == null) // Immutable stack
return;
synchronized (this) { synchronized (this) {
if (this.stackTrace == null) // Immutable stack
return;
this.stackTrace = defensiveCopy; this.stackTrace = defensiveCopy;
} }
} }
...@@ -958,18 +957,15 @@ public class Throwable implements Serializable { ...@@ -958,18 +957,15 @@ public class Throwable implements Serializable {
// trace field is a valid value indicating the stack trace // trace field is a valid value indicating the stack trace
// should not be set. // should not be set.
getOurStackTrace(); getOurStackTrace();
ObjectOutputStream.PutField fields = s.putFields();
fields.put("detailMessage", detailMessage); StackTraceElement[] oldStackTrace = stackTrace;
fields.put("cause", cause); try {
// Serialize a null stacktrace using the stack trace sentinel. if (stackTrace == null)
if (stackTrace == null) stackTrace = SentinelHolder.STACK_TRACE_SENTINEL;
fields.put("stackTrace", SentinelHolder.STACK_TRACE_SENTINEL); s.defaultWriteObject();
else } finally {
fields.put("stackTrace", stackTrace); stackTrace = oldStackTrace;
fields.put("suppressedExceptions", suppressedExceptions); }
s.writeFields();
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册