OpenJDK / jdk / jdk
changeset 9534:080badb816ac
7038843: IIOP serialization fails with NullPointerException when serializing Throwable
Reviewed-by: dholmes, mchung
author | darcy |
---|---|
date | Thu, 28 Apr 2011 17:51:25 -0700 |
parents | 13cc5e8eb9f1 |
children | d930011fd275 |
files | jdk/src/share/classes/java/lang/Throwable.java |
diffstat | 1 files changed, 10 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/jdk/src/share/classes/java/lang/Throwable.java Fri Apr 29 00:21:54 2011 +0100 +++ b/jdk/src/share/classes/java/lang/Throwable.java Thu Apr 28 17:51:25 2011 -0700 @@ -848,10 +848,9 @@ throw new NullPointerException("stackTrace[" + i + "]"); } - if (this.stackTrace == null) // Immutable stack - return; - synchronized (this) { + if (this.stackTrace == null) // Immutable stack + return; this.stackTrace = defensiveCopy; } } @@ -958,18 +957,15 @@ // trace field is a valid value indicating the stack trace // should not be set. getOurStackTrace(); - ObjectOutputStream.PutField fields = s.putFields(); - fields.put("detailMessage", detailMessage); - fields.put("cause", cause); - // Serialize a null stacktrace using the stack trace sentinel. - if (stackTrace == null) - fields.put("stackTrace", SentinelHolder.STACK_TRACE_SENTINEL); - else - fields.put("stackTrace", stackTrace); - fields.put("suppressedExceptions", suppressedExceptions); - - s.writeFields(); + StackTraceElement[] oldStackTrace = stackTrace; + try { + if (stackTrace == null) + stackTrace = SentinelHolder.STACK_TRACE_SENTINEL; + s.defaultWriteObject(); + } finally { + stackTrace = oldStackTrace; + } } /**