changeset 8419:3b8dad189d9f

8129952: Ensure thread consistency Reviewed-by: chegar
author robm
date Mon, 25 Jan 2016 14:07:01 +0000
parents e6b915424d43
children f9046a92fd12
files src/share/classes/java/io/ObjectInputStream.java
diffstat 1 files changed, 15 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/io/ObjectInputStream.java	Fri Jan 22 18:06:43 2016 +0300
+++ b/src/share/classes/java/io/ObjectInputStream.java	Mon Jan 25 14:07:01 2016 +0000
@@ -1887,6 +1887,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();
@@ -1905,10 +1907,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;
                     }
 
                     /*