mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Fix for ALFCOM-1666 - Null pointer when calling ScriptNode in Java (for workflow)
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@13499 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -43,7 +43,6 @@ import org.mozilla.javascript.IdScriptableObject;
|
|||||||
import org.mozilla.javascript.NativeArray;
|
import org.mozilla.javascript.NativeArray;
|
||||||
import org.mozilla.javascript.ScriptRuntime;
|
import org.mozilla.javascript.ScriptRuntime;
|
||||||
import org.mozilla.javascript.Scriptable;
|
import org.mozilla.javascript.Scriptable;
|
||||||
import org.mozilla.javascript.ScriptableObject;
|
|
||||||
import org.mozilla.javascript.Wrapper;
|
import org.mozilla.javascript.Wrapper;
|
||||||
|
|
||||||
|
|
||||||
@@ -96,9 +95,18 @@ public class ValueConverter
|
|||||||
// call the "Date" constructor on the root scope object - passing in the millisecond
|
// call the "Date" constructor on the root scope object - passing in the millisecond
|
||||||
// value from the Java date - this will construct a JavaScript Date with the same value
|
// value from the Java date - this will construct a JavaScript Date with the same value
|
||||||
Date date = (Date)value;
|
Date date = (Date)value;
|
||||||
Object val = ScriptRuntime.newObject(
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Context.enter();
|
||||||
|
Object val = ScriptRuntime.newObject(
|
||||||
Context.getCurrentContext(), scope, TYPE_DATE, new Object[] {date.getTime()});
|
Context.getCurrentContext(), scope, TYPE_DATE, new Object[] {date.getTime()});
|
||||||
value = (Serializable)val;
|
value = (Serializable)val;
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Context.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (value instanceof Collection)
|
else if (value instanceof Collection)
|
||||||
{
|
{
|
||||||
@@ -110,8 +118,16 @@ public class ValueConverter
|
|||||||
{
|
{
|
||||||
array[index++] = convertValueForScript(services, scope, qname, obj);
|
array[index++] = convertValueForScript(services, scope, qname, obj);
|
||||||
}
|
}
|
||||||
// convert array to a native JavaScript Array
|
try
|
||||||
value = (Serializable)Context.getCurrentContext().newArray(scope, array);
|
{
|
||||||
|
Context.enter();
|
||||||
|
// convert array to a native JavaScript Array
|
||||||
|
value = (Serializable)Context.getCurrentContext().newArray(scope, array);
|
||||||
|
}
|
||||||
|
finally
|
||||||
|
{
|
||||||
|
Context.exit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// simple numbers and strings are wrapped automatically by Rhino
|
// simple numbers and strings are wrapped automatically by Rhino
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user