United StatesChange Country, Oracle Worldwide Web Sites Communities I am a... I want to...
JDK-5070673 : IOException should support exception chaining

Details
Type:
Enhancement
Submit Date:
2004-07-01
Status:
Resolved
Updated Date:
2017-05-16
Project Name:
JDK
Resolved Date:
2006-04-14
Component:
core-libs
OS:
linux,windows_xp
Sub-Component:
java.io
CPU:
x86
Priority:
P3
Resolution:
Fixed
Affected Versions:
5.0
Fixed Versions:

Related Reports
Duplicate:
Relates:

Sub Tasks

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



Hardware and Software, Engineered to Work Together