If the catch block completes abruptly for reason R, then the finally block is executed. Then there is a choice:
If the finally block completes normally, then the try statement completes abruptly for reason R.
If the finally block completes abruptly for reason S, then the try statement completes abruptly for reason S (and reason R is discarded).
(Emphasis mine)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
It is unwise to NOT catch Exceptions or throw Exceptions in a Finally block. An exception that is thrown in the finally block, may cause an exception in the try to be discarded. This can lead to errors that obscure the original error.
I can imagine how easy this can happen, for example, if there is an Exception in the try in such a fashion that the closing of resources in the Finally clause will also throw an Exception.
In fact, that is what happened at work, and threw me for a loop when attempting to debug.
Addendum
Luckily, with Java 72, when using the try-with-resources statement, this problem belongs to the past. Of course this only belongs to the past, if your try-catch-finally can be replaced with a try-with-resources.
To be specific, when using try-with-resources only the exception in the try is thrown. Subsequent exceptions, caused by the closing of the resources, are suppressed. But even these exceptions can still be recovered, by requesting all suppressed exceptions from the exception thrown in the try block3.
(Addendum added: 23 july 2015)
References
[1] JLS - 14.20.2. Execution of try-finally and try-catch-finally
This is just here for me as a fancy bookmark, on how to write proper Markdown formatted files for GitHub1 2.
From the source5:
Markdown is a text-to-HTML conversion tool for web writers. Markdown allows you to write using an easy-to-read, easy-to-write plain text format, then convert it to structurally valid XHTML (or HTML).
At work we have used Trac3, especially it's wiki, as well as PlantUML2, which fitted seamlessly inside Trac.
Recently we have moved over to Confluence3 and a different diagram tool called Gliffy (which company makes an excellent plugin for adding Gliffy to Confluence)1.
After working with both PlantUML as well as Gliffy, I thought I'd write down some points in favour of both.
PlantUML
UML Images are generated by interpreting a simple and intuitive language.
Gliffy
a Web-based drawing tool for diagrams
PlantUML
Pro
Con
Comments
Layout is handled by the tool itself
Influence of user on layout is limited
makes it easy to create diagrams quickly
software with required libraries without UI
possible integration via commandline, for example batch jobs, software buildscripts to generate documentation automatically (javadoc for example)
difficult integration with Confluence
a simple and intuitive language makes it easy to create diagrams quickly
it is a markup language, and therefore more suited to software developers
strong focus on UML
limited number of diagram components, strong focus on UML
very easy to change existing diagrams, even very complex ones
Gliffy
Pro
Con
Comments
Layout can be adapted in every little detail
You get stuck having to draw instead of simply create diagrams
makes it difficult to create or change diagrams quickly
Web tool - no obvious software needs to be installed (only on the server)
Responsiveness is not great in a web browser
excellent integration with Confluence by means of a plugin
even managers might be able to use it
which is a really really bad idea.
lots and lots of diagram components, including UML
very difficult to change existing diagrams, sometimes things need to be redrawn5
Conclusion
If you wish to draw UML diagrams quickly, and integrate them into your build process, PlantUML is the way to go.
If you need all the flexibility you can get and you don't mind having to draw and layout things yourself, Gliffy is the way to go.