提交 38a3cf16 编写于 作者: I igerasim

8076405: Improve serial serialization

Reviewed-by: alanb, chegar
上级 cf29b742
......@@ -1829,6 +1829,8 @@ public class ObjectInputStream
throws IOException
{
SerialCallbackContext oldContext = curContext;
if (oldContext != null)
oldContext.check();
curContext = null;
try {
boolean blocked = desc.hasBlockExternalData();
......@@ -1853,6 +1855,8 @@ public class ObjectInputStream
skipCustomData();
}
} finally {
if (oldContext != null)
oldContext.check();
curContext = oldContext;
}
/*
......@@ -1887,7 +1891,8 @@ public class ObjectInputStream
defaultReadFields(null, slotDesc); // skip field values
} else if (slotDesc.hasReadObjectMethod()) {
SerialCallbackContext oldContext = curContext;
if (oldContext != null)
oldContext.check();
try {
curContext = new SerialCallbackContext(obj, slotDesc);
......@@ -1904,6 +1909,8 @@ public class ObjectInputStream
handles.markException(passHandle, ex);
} finally {
curContext.setUsed();
if (oldContext!= null)
oldContext.check();
curContext = oldContext;
}
......
......@@ -60,6 +60,13 @@ final class SerialCallbackContext {
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(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册