Make sure we enter and exit a Context in serialize()/deserialize().
Do not wrap return object in deserialize().
This commit is contained in:
parent
0dd4dba0f7
commit
892fe4b6e1
1 changed files with 22 additions and 13 deletions
|
@ -461,6 +461,8 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
* @throws java.io.IOException
|
||||
*/
|
||||
public void serialize(Object obj, OutputStream out) throws IOException {
|
||||
Context.enter();
|
||||
try {
|
||||
// use a special ScriptableOutputStream that unwraps Wrappers
|
||||
ScriptableOutputStream sout = new ScriptableOutputStream(out, core.global) {
|
||||
protected Object replaceObject(Object obj) throws IOException {
|
||||
|
@ -471,6 +473,9 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
};
|
||||
sout.writeObject(obj);
|
||||
sout.flush();
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -483,9 +488,13 @@ public class RhinoEngine implements ScriptingEngine {
|
|||
* @throws java.io.IOException
|
||||
*/
|
||||
public Object deserialize(InputStream in) throws IOException, ClassNotFoundException {
|
||||
Context.enter();
|
||||
try {
|
||||
ObjectInputStream sin = new ScriptableInputStream(in, core.global);
|
||||
Object deserialized = sin.readObject();
|
||||
return Context.toObject(deserialized, core.global);
|
||||
return sin.readObject();
|
||||
} finally {
|
||||
Context.exit();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue