Skip to content
This repository has been archived by the owner. It is now read-only.

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

Closed
wants to merge 1 commit into from
Closed

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

wants to merge 1 commit into from

Conversation

@asdf2014
Copy link
Member

@asdf2014 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
Copy link
Contributor

@qingwen220 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
Copy link
Member Author

@asdf2014 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 [EAGLE-1009] Fix losing exception issues [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
… 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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
2 participants