Actually I agree with recommendation...
For example following method:
public boolean test() {
try {
return true;
} finally {
return false;
}
}
will always return false... Think it's better to avoid such
constructions, as with growing of try-finally block this potential
problem will get less visible and more difficult to fix.
WBR,
Alexey.
charlie hunt wrote:
> I've been running the Jackpot query transformations against the
> grizzly framework source code and have found a couple transformation
> queries kind of interesting.
>
> I wondered what others thought.
>
> There's one that's called "bad finally blocks" that's part of set of
> "Effective Java" transformations. When I run this transformation
> query, it complains about a couple places where we do a return inside
> a finally block. For example:
>
> finally { if (exception
> != null || count == -1){
> ctx.setAttribute(Context.THROWABLE,exception);
> ctx.setKeyRegistrationState(
> Context.KeyRegistrationState.CANCEL);
> return false;
> }
>
> I looked in Joshua's Effective Java book and couldn't find a mention
> of this being a bad practice, (unless I missed it).
>
> Am I missing something obvious as to why this might be a bad practice?
>
> charlie ...
>