# HG changeset patch # User robm # Date 1453730821 0 # Node ID 4138b3f27ffea524185a604c3f4f149c7e5ba780 # Parent afcbabfb116d7534161354851570e8f4b6c5019f 8129952: Ensure thread consistency Reviewed-by: chegar diff -r afcbabfb116d -r 4138b3f27ffe src/share/classes/java/io/ObjectInputStream.java --- 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; } /*