--- a/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Fri Apr 17 15:28:44 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/io/ObjectInputStream.java Fri Apr 17 15:36:32 2015 +0100
@@ -1832,6 +1832,8 @@
throws IOException
{
SerialCallbackContext oldContext = curContext;
+ if (oldContext != null)
+ oldContext.check();
curContext = null;
try {
boolean blocked = desc.hasBlockExternalData();
@@ -1856,6 +1858,8 @@
skipCustomData();
}
} finally {
+ if (oldContext != null)
+ oldContext.check();
curContext = oldContext;
}
/*
@@ -1910,7 +1914,8 @@
defaultReadFields(null, slotDesc); // skip field values
} else if (slotDesc.hasReadObjectMethod()) {
SerialCallbackContext oldContext = curContext;
-
+ if (oldContext != null)
+ oldContext.check();
try {
curContext = new SerialCallbackContext(obj, slotDesc);
@@ -1927,6 +1932,8 @@
handles.markException(passHandle, ex);
} finally {
curContext.setUsed();
+ if (oldContext!= null)
+ oldContext.check();
curContext = oldContext;
}
--- a/jdk/src/java.base/share/classes/java/io/SerialCallbackContext.java Fri Apr 17 15:28:44 2015 +0100
+++ b/jdk/src/java.base/share/classes/java/io/SerialCallbackContext.java Fri Apr 17 15:36:32 2015 +0100
@@ -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());
+ }
+ }
+
public void checkAndSetUsed() throws NotActiveException {
if (thread != Thread.currentThread()) {
throw new NotActiveException(