OpenJDK / jdk8u / jdk8u / jdk
changeset 10924:e0bf010f895b
8076405: Improve serial serialization
Reviewed-by: alanb, chegar
author | igerasim |
---|---|
date | Mon, 20 Apr 2015 15:17:22 +0300 |
parents | 0fe54aa739d4 |
children | 7e8459e7a45c |
files | src/share/classes/java/io/ObjectInputStream.java src/share/classes/java/io/SerialCallbackContext.java |
diffstat | 2 files changed, 15 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- 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; }
--- 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(