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

[EAGLE-1009] Fix `return` inside `finally` block may result in losing exception #920

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
2 participants
@asdf2014
Member

asdf2014 commented Apr 18, 2017

return inside finally block will result in losing exception:

  • If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and the throw of value V is discarded and forgotten).
  • If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and reason R is discarded).

reference:
http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.20.2
https://issues.apache.org/jira/secure/attachment/12863778/FinallyTest.java

(https://issues.apache.org/jira/browse/EAGLE-1009)

@qingwen220

This comment has been minimized.

Contributor

qingwen220 commented Apr 18, 2017

I don't think there are exceptions lost in the code you modified. All these try statements are followed by catch statement which doesn't throw a new exception anymore.

I agree with your idea that DON'T return in finally block

@asdf2014

This comment has been minimized.

Member

asdf2014 commented Apr 18, 2017

@qingwen220 Hi, qingwen220. You are right. This situation will not lose any exception because all exception from try statement will be catched in catch block and it just print the exception message by slf4j in here.

@asdf2014 asdf2014 changed the title from [EAGLE-1009] Fix losing exception issues to [EAGLE-1009] Fix `return` inside `finally` block may result in losing exception Apr 19, 2017

@asfgit asfgit closed this in e3afe44 Apr 19, 2017

jhsenjaliya pushed a commit to jhsenjaliya/eagle that referenced this pull request Jul 12, 2017

[EAGLE-1009] Fix `return` inside `finally` block may result in losing…
… exception

`return` inside `finally` block will result in losing exception:

* If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and the throw of value V is discarded and forgotten).
* If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and reason R is discarded).

reference:
http://docs.oracle.com/javase/specs/jls/se8/html/jls-14.html#jls-14.20.2
https://issues.apache.org/jira/secure/attachment/12863778/FinallyTest.java

(https://issues.apache.org/jira/browse/EAGLE-1009)

Author: asdf2014 <1571805553@qq.com>

Closes apache#920 from asdf2014/return_inside_finally.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment