public Foo doDangerousStuff() throws Exception {
try {
dangerousMethod();
return new Foo();
} catch (Exception e) {
throw e;
} finally {
mustBeCalledAfterDangerousMethod();
}
}
Does this behave any differently than if we were to omit the catch clause?
public Foo doDangerousStuff() throws Exception {
try {
dangerousMethod();
return new Foo();
} finally {
mustBeCalledAfterDangerousMethod();
}
}
[edit] To clear the confusion, yes, the catch
block does nothing except re-throw the exception. I was wondering if this caused some sort of different ordering in when the finally
block is invoked (assume that the thrown exception is caught by the caller), but from what I infer from the answers thusfar, it does not.