You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cocoon.apache.org by Jason von Nieda <ja...@displayware.com> on 2009/04/01 20:25:39 UTC

Throw inside catch skips finally in Flowscript?

Hi all, I ran into an issue that seems to be pretty serious and I'm having a
hard time finding any information about it.
In JavaScript Flowscript using Cocoon 2.1.11 and
Rhino rhino1.5r4-continuations-R26.jar it seems that throwing an exception
from within a catch block causes an associated finally block to fail to
execute. Example:

function test()
{
try {
// this line runs
Packages.java.lang.System.out.println("test1");
throw "moof";
}
catch (e) {
// this line runs
Packages.java.lang.System.out.println("test2");
throw e;
}
finally {
// this line does not
Packages.java.lang.System.out.println("test3");
}
}

In the example above, if I remove the throw e; from the catch block the
finally block runs fine. Additionally, if instead of using throw inside the
catch I just run some code that causes an exception to be thrown, the
finally also does not run.

This seems fairly glaring to me, as it makes it impossible to use a catch
and a finally at the same time.

Can someone tell me if this is a known bug in Cocoon, or Rhino, or something
else and if there is some information about it? I'm trying to decide how to
proceed in fixing thousands of lines of Flow.

Thanks,
Jason von Nieda

Re: Throw inside catch skips finally in Flowscript?

Posted by Sylvain Wallez <sy...@apache.org>.
Jason von Nieda wrote:
> Reposting this as I never got any kind of response. Are we the first 
> to run into this bug?

The version of Rhino used in the 2.1 branch is the initial 
implementation of continutations, that was later included and refactored 
into the main project at Mozilla.

So you should try to upgrade to the latest official release, this may 
have been fixed. I don't remember though if a simple replacement of 
rhino.jar works or if changes are required in the flowscript code. In 
the latter case, have a look a the flowscript classes in 2.2, since it 
uses the official Rhino.

Sylvain

> On Wed, Apr 1, 2009 at 11:25 AM, Jason von Nieda 
> <jason@displayware.com <ma...@displayware.com>> wrote:
>
>     Hi all, I ran into an issue that seems to be pretty serious and
>     I'm having a hard time finding any information about it.
>
>     In JavaScript Flowscript using Cocoon 2.1.11 and
>     Rhino rhino1.5r4-continuations-R26.jar it seems that throwing an
>     exception from within a catch block causes an associated finally
>     block to fail to execute. Example:
>
>     function test()
>     {
>     try {
>     // this line runs
>     Packages.java.lang.System.out.println("test1");
>     throw "moof";
>     }
>     catch (e) {
>     // this line runs
>     Packages.java.lang.System.out.println("test2");
>     throw e;
>     }
>     finally {
>     // this line does not
>     Packages.java.lang.System.out.println("test3");
>     }
>     }
>
>     In the example above, if I remove the throw e; from the catch
>     block the finally block runs fine. Additionally, if instead of
>     using throw inside the catch I just run some code that causes an
>     exception to be thrown, the finally also does not run. 
>
>     This seems fairly glaring to me, as it makes it impossible to use
>     a catch and a finally at the same time. 
>
>     Can someone tell me if this is a known bug in Cocoon, or Rhino, or
>     something else and if there is some information about it? I'm
>     trying to decide how to proceed in fixing thousands of lines of Flow.
>
>     Thanks,
>     Jason von Nieda
>
>


-- 
Sylvain Wallez - http://bluxte.net


Re: Throw inside catch skips finally in Flowscript?

Posted by Jason von Nieda <ja...@displayware.com>.
Reposting this as I never got any kind of response. Are we the first to run
into this bug?

On Wed, Apr 1, 2009 at 11:25 AM, Jason von Nieda <ja...@displayware.com>wrote:

> Hi all, I ran into an issue that seems to be pretty serious and I'm having
> a hard time finding any information about it.
> In JavaScript Flowscript using Cocoon 2.1.11 and
> Rhino rhino1.5r4-continuations-R26.jar it seems that throwing an exception
> from within a catch block causes an associated finally block to fail to
> execute. Example:
>
> function test()
> {
> try {
> // this line runs
> Packages.java.lang.System.out.println("test1");
>  throw "moof";
> }
> catch (e) {
> // this line runs
>  Packages.java.lang.System.out.println("test2");
> throw e;
> }
>  finally {
> // this line does not
> Packages.java.lang.System.out.println("test3");
>  }
> }
>
> In the example above, if I remove the throw e; from the catch block the
> finally block runs fine. Additionally, if instead of using throw inside the
> catch I just run some code that causes an exception to be thrown, the
> finally also does not run.
>
> This seems fairly glaring to me, as it makes it impossible to use a catch
> and a finally at the same time.
>
> Can someone tell me if this is a known bug in Cocoon, or Rhino, or
> something else and if there is some information about it? I'm trying to
> decide how to proceed in fixing thousands of lines of Flow.
>
> Thanks,
> Jason von Nieda
>