# HG changeset patch # User igerasim # Date 1429532242 -10800 # Node ID d97b57cab0204d39562418674a3b32efb9b8df09 # Parent f35c646e6cc1cc00b3740abd581be893bc466cd2 8076405: Improve serial serialization Reviewed-by: alanb, chegar diff -r f35c646e6cc1 -r d97b57cab020 src/share/classes/java/io/ObjectInputStream.java --- a/src/share/classes/java/io/ObjectInputStream.java Sun Apr 19 21:08:00 2015 +0300 +++ b/src/share/classes/java/io/ObjectInputStream.java Mon Apr 20 15:17:22 2015 +0300 @@ -1826,6 +1826,8 @@ throws IOException { SerialCallbackContext oldContext = curContext; + if (oldContext != null) + oldContext.check(); curContext = null; try { boolean blocked = desc.hasBlockExternalData(); @@ -1850,6 +1852,8 @@ skipCustomData(); } } finally { + if (oldContext != null) + oldContext.check(); curContext = oldContext; } /* @@ -1885,7 +1889,8 @@ handles.lookupException(passHandle) == null) { SerialCallbackContext oldContext = curContext; - + if (oldContext != null) + oldContext.check(); try { curContext = new SerialCallbackContext(obj, slotDesc); @@ -1902,6 +1907,8 @@ handles.markException(passHandle, ex); } finally { curContext.setUsed(); + if (oldContext!= null) + oldContext.check(); curContext = oldContext; } diff -r f35c646e6cc1 -r d97b57cab020 src/share/classes/java/io/SerialCallbackContext.java --- a/src/share/classes/java/io/SerialCallbackContext.java Sun Apr 19 21:08:00 2015 +0300 +++ b/src/share/classes/java/io/SerialCallbackContext.java Mon Apr 20 15:17:22 2015 +0300 @@ -60,6 +60,13 @@ return desc; } + public void check() throws NotActiveException { + if (thread != null && thread != Thread.currentThread()) { + throw new NotActiveException( + "expected thread: " + thread + ", but got: " + Thread.currentThread()); + } + } + private void checkAndSetUsed() throws NotActiveException { if (thread != Thread.currentThread()) { throw new NotActiveException(