vhardy 02/05/13 02:23:11
Modified: sources/org/apache/batik/script/rhino RhinoInterpreter.java
Log:
Fixed Context creation bug. Code would have failed if invoked from different threads
Revision Changes Path
1.16 +11 -6
xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java
Index: RhinoInterpreter.java
===================================================================
RCS file:
/home/cvs/xml-batik/sources/org/apache/batik/script/rhino/RhinoInterpreter.java,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -r1.15 -r1.16
--- RhinoInterpreter.java 30 Apr 2002 15:05:18 -0000 1.15
+++ RhinoInterpreter.java 13 May 2002 09:23:10 -0000 1.16
@@ -42,7 +42,7 @@
* A simple implementation of <code>Interpreter</code> interface to use
* Rhino ECMAScript interpreter.
* @author <a href="mailto:[EMAIL PROTECTED]">Christophe Jolif</a>
- * @version $Id: RhinoInterpreter.java,v 1.15 2002/04/30 15:05:18 vhardy Exp $
+ * @version $Id: RhinoInterpreter.java,v 1.16 2002/05/13 09:23:10 vhardy Exp $
*/
public class RhinoInterpreter implements Interpreter {
private static String[] TO_BE_IMPORTED = {
@@ -89,7 +89,8 @@
protected RhinoClassLoader rhinoClassLoader;
/**
- * Default Context for scripts
+ * Default Context for scripts. This is used only for efficiency
+ * reason.
*/
protected Context defaultContext;
@@ -97,7 +98,7 @@
* Context vector, to make sure we are not
* setting the security context too many times
*/
- protected Vector contexts;
+ protected Vector contexts = new Vector();
/**
* Build a <code>Interpreter</code> for ECMAScript using Rhino.
@@ -113,8 +114,8 @@
Context.setCachingEnabled(false); // reset the cache
Context.setCachingEnabled(true); // enable caching again
// entering a context
- defaultContext = new Context(securitySupport);
- Context ctx = enterContext();
+ defaultContext = enterContext();
+ Context ctx = defaultContext;
try {
@@ -140,13 +141,17 @@
* on the context.
*/
public Context enterContext(){
- Context ctx = Context.enter(defaultContext);
+ Context ctx = Context.enter();
if (ctx != defaultContext){
// Set the SecuritySupport the Context should
// use.
if (!contexts.contains(ctx)) {
ctx.setSecuritySupport(securitySupport);
contexts.add(ctx);
+
+ // Hopefully, we are not switching threads too
+ // often ....
+ defaultContext = ctx;
}
}
return ctx;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]