ClassCastException in Rhino when creating a continuation in a catch block
-------------------------------------------------------------------------

                 Key: COCOON-2006
                 URL: https://issues.apache.org/jira/browse/COCOON-2006
             Project: Cocoon
          Issue Type: Bug
          Components: - Flowscript
    Affects Versions: 2.1.10
            Reporter: Rob Berens


In our example we use a dialog from within a catch block in javascript e.g. to 
ask for confirmation if a file already exists. It looks like this:

try {
    write file
catch (ex if ex.javaexception instanceof MyFileAlreadyExistsException) {
    if (overwriteDialog("Overwrite")) {
        overwrite file
     }
}

function overwriteDialog(message) {
    var form = new Form("path/to/dialog.fd");
    var formWidget = form.form;
    
    formWidget.lookupWidget("message").setValue(message);
    form.showForm("/flow/path/to/dialog.html");
    return "ok".equals(form.submitId);
}

In the overwrite dialog a form is created and shown thereby effectively 
creating a continuation. Formerly when using 2.1.8 this worked fine. In 2.1.10 
we get a ClassCastException with the stack shown below.

When changing the code like this, there is no problem:

var exists = false;
try {
    write file
catch (ex if ex.javaexception instanceof MyFileAlreadyExistsException) {
    exists = true;
}

if (exists && overwriteDialog("Overwrite")) {
    overwrite file
}

I did some investigation in Rhino and found out that the enterFrames as 
referred in org.mozilla.javascript.Interpreter at line 2407 contain a frame 
that has a scope of class NativeWith which in the end leads to the 
ClassCastException.


Thread [PoolThread-3] (Suspended (exception java.lang.ClassCastException))      
        
org.mozilla.javascript.ScriptRuntime.enterActivationFunction(org.mozilla.javascript.Context,
 org.mozilla.javascript.Scriptable) line: 2847      
        
org.mozilla.javascript.Interpreter.enterFrame(org.mozilla.javascript.Context, 
org.mozilla.javascript.Interpreter$CallFrame, java.lang.Object[]) line: 3855    
  
        
org.mozilla.javascript.Interpreter.interpretLoop(org.mozilla.javascript.Context,
 org.mozilla.javascript.Interpreter$CallFrame, java.lang.Object) line: 2408     
        
org.mozilla.javascript.Interpreter.interpret(org.mozilla.javascript.InterpretedFunction,
 org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, 
org.mozilla.javascript.Scriptable, java.lang.Object[]) line: 2251   
        
org.mozilla.javascript.InterpretedFunction.call(org.mozilla.javascript.Context, 
org.mozilla.javascript.Scriptable, org.mozilla.javascript.Scriptable, 
java.lang.Object[]) line: 161     
        
org.mozilla.javascript.ContextFactory.doTopCall(org.mozilla.javascript.Callable,
 org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, 
org.mozilla.javascript.Scriptable, java.lang.Object[]) line: 340    
        
org.mozilla.javascript.ScriptRuntime.doTopCall(org.mozilla.javascript.Callable, 
org.mozilla.javascript.Context, org.mozilla.javascript.Scriptable, 
org.mozilla.javascript.Scriptable, java.lang.Object[]) line: 2758    
        
org.mozilla.javascript.InterpretedFunction.call(org.mozilla.javascript.Context, 
org.mozilla.javascript.Scriptable, org.mozilla.javascript.Scriptable, 
java.lang.Object[]) line: 159     
        
org.mozilla.javascript.Context.call(org.mozilla.javascript.ContextFactory, 
org.mozilla.javascript.Callable, org.mozilla.javascript.Scriptable, 
org.mozilla.javascript.Scriptable, java.lang.Object[]) line: 489 
        
org.mozilla.javascript.ScriptableObject.callMethod(org.mozilla.javascript.Context,
 org.mozilla.javascript.Scriptable, java.lang.String, java.lang.Object[]) line: 
1556  
        
org.mozilla.javascript.ScriptableObject.callMethod(org.mozilla.javascript.Scriptable,
 java.lang.String, java.lang.Object[]) line: 1526  
        
org.apache.cocoon.components.flow.javascript.fom.FOM_JavaScriptInterpreter.handleContinuation(java.lang.String,
 java.util.List, org.apache.cocoon.environment.Redirector) line: 842     
        
org.apache.cocoon.components.treeprocessor.sitemap.CallFunctionNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 124       
        
org.apache.cocoon.components.treeprocessor.sitemap.SelectNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69   
        
org.apache.cocoon.components.treeprocessor.sitemap.SelectNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 103     
        
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext, java.lang.String, 
java.util.Map) line: 47   
        
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 108      
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69 
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 143   
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69        
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 93   
        
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 235 
        
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(org.apache.cocoon.environment.Environment)
 line: 177   
        
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(org.apache.cocoon.environment.Environment)
 line: 253   
        
org.apache.cocoon.components.treeprocessor.sitemap.MountNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 118      
        
org.apache.cocoon.components.treeprocessor.sitemap.SelectNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69   
        
org.apache.cocoon.components.treeprocessor.sitemap.SelectNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 103     
        
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext, java.lang.String, 
java.util.Map) line: 47   
        
org.apache.cocoon.components.treeprocessor.sitemap.MatchNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 108      
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69 
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelineNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 143   
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode(org.apache.cocoon.components.treeprocessor.AbstractParentProcessingNode).invokeNodes(org.apache.cocoon.components.treeprocessor.ProcessingNode[],
 org.apache.cocoon.environment.Environment, 
org.apache.cocoon.components.treeprocessor.InvokeContext) line: 69        
        
org.apache.cocoon.components.treeprocessor.sitemap.PipelinesNode.invoke(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 93   
        
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(org.apache.cocoon.environment.Environment,
 org.apache.cocoon.components.treeprocessor.InvokeContext) line: 235 
        
org.apache.cocoon.components.treeprocessor.ConcreteTreeProcessor.process(org.apache.cocoon.environment.Environment)
 line: 177   
        
org.apache.cocoon.components.treeprocessor.TreeProcessor.process(org.apache.cocoon.environment.Environment)
 line: 253   
        
org.apache.cocoon.Cocoon.process(org.apache.cocoon.environment.Environment) 
line: 699   
        
org.apache.cocoon.servlet.CocoonServlet.service(javax.servlet.http.HttpServletRequest,
 javax.servlet.http.HttpServletResponse) line: 1154       
        
org.apache.cocoon.servlet.CocoonServlet(javax.servlet.http.HttpServlet).service(javax.servlet.ServletRequest,
 javax.servlet.ServletResponse) line: 853  
        
org.mortbay.jetty.servlet.ServletHolder.handle(javax.servlet.ServletRequest, 
javax.servlet.ServletResponse) line: 358   
        
org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(java.lang.String, 
javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse, 
org.mortbay.jetty.servlet.ServletHolder) line: 294    
        
org.mortbay.jetty.servlet.WebApplicationHandler(org.mortbay.jetty.servlet.ServletHandler).handle(java.lang.String,
 java.lang.String, org.mortbay.http.HttpRequest, org.mortbay.http.HttpResponse) 
line: 567     
        
org.mortbay.jetty.servlet.WebApplicationContext(org.mortbay.http.HttpContext).handle(java.lang.String,
 java.lang.String, org.mortbay.http.HttpRequest, org.mortbay.http.HttpResponse) 
line: 1807        
        
org.mortbay.jetty.servlet.WebApplicationContext.handle(java.lang.String, 
java.lang.String, org.mortbay.http.HttpRequest, org.mortbay.http.HttpResponse) 
line: 525       
        
org.mortbay.jetty.servlet.WebApplicationContext(org.mortbay.http.HttpContext).handle(org.mortbay.http.HttpRequest,
 org.mortbay.http.HttpResponse) line: 1757    
        
org.mortbay.jetty.Server(org.mortbay.http.HttpServer).service(org.mortbay.http.HttpRequest,
 org.mortbay.http.HttpResponse) line: 879    
        org.mortbay.http.HttpConnection.service(org.mortbay.http.HttpRequest, 
org.mortbay.http.HttpResponse) line: 789  
        org.mortbay.http.HttpConnection.handleNext() line: 960  
        org.mortbay.http.HttpConnection.handle() line: 806      
        org.mortbay.http.SocketListener.handleConnection(java.net.Socket) line: 
218     
        
org.mortbay.http.SocketListener(org.mortbay.util.ThreadedServer).handle(java.lang.Object)
 line: 300     
        org.mortbay.util.ThreadPool$PoolThread.run() line: 511  


-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to