Mercurial > hg > release > icedtea7-forest-2.5 > jdk
changeset 8202:d97b57cab020
8076405: Improve serial serialization
Reviewed-by: alanb, chegar
author | igerasim |
---|---|
date | Mon, 20 Apr 2015 15:17:22 +0300 |
parents | f35c646e6cc1 |
children | ab54d7eeaa64 |
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 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; }
--- 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(