-
Enhancement
-
Resolution: Fixed
-
P5
-
1.4.2
-
rc
-
x86
-
windows_xp
-
Verified
A DESCRIPTION OF THE REQUEST :
Currently, if an exception, A, occurs withing a try block, and then an exception B occurs in a finally block, then exception A is completely lost. Programmers can use manual exception chaining in situations where an exception may be thrown in a finally block. However, this can make the code very messy.
JUSTIFICATION :
From a debugging standpoint it would be useful to see the information from both exceptions without the need to add extra lines of code to do exception chaining.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
I would Java to automatically using exception chaining behind the scenes in a situation where an exception occurs in a try block and a finally block.
ACTUAL -
So in the situation where a try block throws Exception A, and a finally block throws Exception B, if exception A and B occur then exception B is thrown with Exception A as its init cause.
CUSTOMER SUBMITTED WORKAROUND :
Use manual exception chaining.
(Incident Review ID: 237013)
======================================================================
- relates to
-
JDK-6971877 Project Coin: improve semantics of suppressed exceptions in try-with-resources
- Closed
-
JDK-5108147 Extending finally to allow optional Throwable exception parameter
- Closed
-
JDK-6213098 try-catch block lacks follow through semantics
- Closed
-
JDK-7005628 Clarify NPE behavior of Throwable.addSuppressed(null)
- Closed
-
JDK-4447072 RFE: Add an exception block to the try statement
- Closed
-
JDK-6911256 Project Coin: Support Automatic Resource Management (ARM) blocks in the compiler
- Closed
-
JDK-6911258 Project Coin: Add essential API support for Automatic Resource Management (ARM) blocks
- Closed
-
JDK-8073382 use lambdas to provide APIs that do automatic exception chaining, suppression, or wrapping
- Open