Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Finally block is not executed if an exception is thrown in the previous catch block #93

Closed
GoogleCodeExporter opened this issue Apr 22, 2015 · 5 comments

Comments

@GoogleCodeExporter
Copy link

The following code shows the problem:

try {
    System.out.println("try");
    throw new Exception("1");
} catch (Exception e) {
    System.out.println("catch");
    throw new Exception("2");
} finally {
    System.out.println("finally");
}

The expected output is
try
catch
finally
and the exception "2" remains uncaught.

The actual output is
try
catch
and the exception "2" remains uncaught.

The problem is in the file BSHTryStatement.java
I think lines 86 to 176 should be in a try block, and lines 178 to 183 in the 
corresponding finally block.

Original issue reported on code.google.com by lorenzo....@gmail.com on 5 Nov 2013 at 9:41

@GoogleCodeExporter
Copy link
Author

Thank you for reporting, will look at this

Original comment by pejob...@gmail.com on 6 Nov 2013 at 8:13

  • Changed state: Accepted

@GoogleCodeExporter
Copy link
Author

[deleted comment]

1 similar comment
@GoogleCodeExporter
Copy link
Author

[deleted comment]

@GoogleCodeExporter
Copy link
Author

Applied your suggested fix in v2.1 branch

Original comment by pejob...@gmail.com on 6 Nov 2013 at 9:05

  • Added labels: v2.1

@pejobo
Copy link
Owner

pejobo commented Mar 2, 2018

This hase been fixed with 7536b22

@pejobo pejobo closed this as completed Mar 2, 2018
nickl- added a commit to beanshell/beanshell that referenced this issue May 14, 2018
Merge pejobo/beanshell2@7536b22 fix for pejobo/beanshell2#93
* extended tests
* applied suggested fix
nickl- added a commit to beanshell/beanshell that referenced this issue Jan 7, 2019
Merge pejobo/beanshell2@7536b22 fix for pejobo/beanshell2#93
* extended tests
* applied suggested fix
nickl- added a commit to beanshell/beanshell that referenced this issue Jan 7, 2019
Merge pejobo/beanshell2@7536b22 fix for pejobo/beanshell2#93
* extended tests
* applied suggested fix
nickl- added a commit to beanshell/beanshell that referenced this issue Mar 19, 2019
Merge pejobo/beanshell2@7536b22 fix for pejobo/beanshell2#93
* extended tests
* applied suggested fix
patniemeyer pushed a commit to beanshell/beanshell that referenced this issue Dec 6, 2023
Merge pejobo/beanshell2@7536b22 fix for pejobo/beanshell2#93
* extended tests
* applied suggested fix
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants