8076405: Improve serial serialization
Reviewed-by: alanb, igerasim
This commit is contained in:
parent
4799f0adcd
commit
6716f24c45
@ -1832,6 +1832,8 @@ public class ObjectInputStream
|
||||
throws IOException
|
||||
{
|
||||
SerialCallbackContext oldContext = curContext;
|
||||
if (oldContext != null)
|
||||
oldContext.check();
|
||||
curContext = null;
|
||||
try {
|
||||
boolean blocked = desc.hasBlockExternalData();
|
||||
@ -1856,6 +1858,8 @@ public class ObjectInputStream
|
||||
skipCustomData();
|
||||
}
|
||||
} finally {
|
||||
if (oldContext != null)
|
||||
oldContext.check();
|
||||
curContext = oldContext;
|
||||
}
|
||||
/*
|
||||
@ -1910,7 +1914,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);
|
||||
|
||||
@ -1927,6 +1932,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());
|
||||
}
|
||||
}
|
||||
|
||||
public void checkAndSetUsed() throws NotActiveException {
|
||||
if (thread != Thread.currentThread()) {
|
||||
throw new NotActiveException(
|
||||
|
Loading…
x
Reference in New Issue
Block a user