changeset 14255:54d479662492

8129952: Ensure thread consistency Reviewed-by: alanb, ahgross, skoivu
author chegar
date Wed, 20 Jan 2016 20:51:45 +0000
parents bb1ac1663380
children 1ad61546516d
files src/java.base/share/classes/java/io/ObjectInputStream.java
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/java.base/share/classes/java/io/ObjectInputStream.java	Wed Jan 13 11:24:11 2016 -0800
+++ b/src/java.base/share/classes/java/io/ObjectInputStream.java	Wed Jan 20 20:51:45 2016 +0000
@@ -1915,6 +1915,8 @@
                 if (obj == null || handles.lookupException(passHandle) != null) {
                     defaultReadFields(null, slotDesc); // skip field values
                 } else if (slotDesc.hasReadObjectMethod()) {
+                    ThreadDeath t = null;
+                    boolean reset = false;
                     SerialCallbackContext oldContext = curContext;
                     if (oldContext != null)
                         oldContext.check();
@@ -1933,10 +1935,19 @@
                          */
                         handles.markException(passHandle, ex);
                     } finally {
-                        curContext.setUsed();
-                        if (oldContext!= null)
-                            oldContext.check();
-                        curContext = oldContext;
+                        do {
+                            try {
+                                curContext.setUsed();
+                                if (oldContext!= null)
+                                    oldContext.check();
+                                curContext = oldContext;
+                                reset = true;
+                            } catch (ThreadDeath x) {
+                                t = x;  // defer until reset is true
+                            }
+                        } while (!reset);
+                        if (t != null)
+                            throw t;
                     }
 
                     /*