JDK-5070673 : IOException should support exception chaining
  • Type: Enhancement
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 5.0
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • OS: linux,windows_xp
  • CPU: x86
  • Submitted: 2004-07-01
  • Updated: 2017-05-16
  • Resolved: 2006-04-14
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availabitlity Release.

To download the current JDK release, click here.
JDK 6
6 b81Fixed
Related Reports
Duplicate :  
Relates :  
Description
Name: rmT116609			Date: 07/01/2004


A DESCRIPTION OF THE REQUEST :
Consider adding to IOException a constructor that supports exception chaining
conveniently (IOException( String, Throwable)).

JUSTIFICATION :
IOException seems to be basic or common enough to warrant supporting
exception chaining directly in the constructor.

(In my case, I'm writing an OutputStream subclass that operates on an underlying
stream.  If a method on the underyling stream throws an exception, I wrap it in an
IOException specific to the calling method in my OutputStream subclass.


CUSTOMER SUBMITTED WORKAROUND :
Instead of:
  throw new IOException(  "higher-level message", e );
use
  IOException temp = IOException(  "higher-level message" );
  temp.initCause( e );
  throw temp;
(Incident Review ID: 282209) 
======================================================================

Comments
EVALUATION Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=11977&forumID=1463
2006-03-13

EVALUATION Contribution-Forum:https://jdk-collaboration.dev.java.net/servlets/ProjectForumMessageView?messageID=11970&forumID=1463
2006-03-13

EVALUATION If we decide to modify IOException to easily support exception chaining, we'd need to add two new constructors: public IOException(Throwable); public IOException(String, Throwable); Support of chaining is something that should be added if there is either a common usage case which would benefit from it. A quick grep of the java.{io,lang,reflect,util} source shows that these packages do not call initCause() frequently (and never for IOException), but that doesn't necessarily mean that it wouldn't be useful. If there anybody finds these new constructs useful, please post a comment to the JDC indicating your use case or vote for this RFE.
2005-10-26

EVALUATION Sounds reasonable. Will consider for a future release. ###@###.### 2004-07-01
2004-07-01