Exception in thread "main" java.lang.CloneNotSupportedException
So an SQLException should be thrown from within the catch block, but since the finally block is always executed a CloneNotSupportedException is thrown as well.
My question is what happens to the SQLException?
Handling just the CloneNotSupportedException when calling m1() compiles fine:
Running this code just results in the output "CloneNotSupportedException".
It seems like an SQLException is thrown in the catch block but never handled or declared.
The exception thrown in the try block is simply ignored and "overruled" by the exception thrown in the finally block.
This is the reason why finally blocks should never terminate abnormally. Whenever you have a checked exception in a finally block, catch it and log it. This way, you will get a notification in your log file why the finally block failed, and the exception in the try block will propagate normally.
posted 7 years ago
Good idea. Thanks Stephan.
All of the world's problems can be solved in a garden - Geoff Lawton. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database