changeset 11743:4138b3f27ffe jdk8u75-b05

8129952: Ensure thread consistency Reviewed-by: chegar
author robm
date Mon, 25 Jan 2016 14:07:01 +0000
parents afcbabfb116d
children affdf0935a10
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
@@ -1890,6 +1890,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();
@@ -1908,10 +1910,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;
                     }
 
                     /*