# HG changeset patch # User igerasim # Date 1429532242 -10800 # Node ID e0bf010f895b842e11a78db44871c7bcc8a7ac57 # Parent 0fe54aa739d4c89beaaa8bda6cd7c901e3d1fab7 8076405: Improve serial serialization Reviewed-by: alanb, chegar diff -r 0fe54aa739d4 -r e0bf010f895b src/share/classes/java/io/ObjectInputStream.java --- a/src/share/classes/java/io/ObjectInputStream.java Wed Apr 15 11:51:09 2015 +0200 +++ b/src/share/classes/java/io/ObjectInputStream.java Mon Apr 20 15:17:22 2015 +0300 @@ -1829,6 +1829,8 @@ throws IOException { SerialCallbackContext oldContext = curContext; + if (oldContext != null) + oldContext.check(); curContext = null; try { boolean blocked = desc.hasBlockExternalData(); @@ -1853,6 +1855,8 @@ skipCustomData(); } } finally { + if (oldContext != null) + oldContext.check(); curContext = oldContext; } /* @@ -1888,7 +1892,8 @@ handles.lookupException(passHandle) == null) { SerialCallbackContext oldContext = curContext; - + if (oldContext != null) + oldContext.check(); try { curContext = new SerialCallbackContext(obj, slotDesc); @@ -1905,6 +1910,8 @@ handles.markException(passHandle, ex); } finally { curContext.setUsed(); + if (oldContext!= null) + oldContext.check(); curContext = oldContext; } diff -r 0fe54aa739d4 -r e0bf010f895b src/share/classes/java/io/SerialCallbackContext.java --- a/src/share/classes/java/io/SerialCallbackContext.java Wed Apr 15 11:51:09 2015 +0200 +++ 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(