Author: tn
Date: Sun Dec  2 19:25:13 2012
New Revision: 1416237

URL: http://svn.apache.org/viewvc?rev=1416237&view=rev
Log:
[EMAIL-117] Remove emulation support for nested exceptions.

Modified:
    commons/proper/email/trunk/src/changes/changes.xml
    
commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailException.java

Modified: commons/proper/email/trunk/src/changes/changes.xml
URL: 
http://svn.apache.org/viewvc/commons/proper/email/trunk/src/changes/changes.xml?rev=1416237&r1=1416236&r2=1416237&view=diff
==============================================================================
--- commons/proper/email/trunk/src/changes/changes.xml (original)
+++ commons/proper/email/trunk/src/changes/changes.xml Sun Dec  2 19:25:13 2012
@@ -23,6 +23,9 @@
 
   <body>
     <release version="1.3" date="as in SVN">
+      <action dev="tn" type="fix" issue="EMAIL-117" date="2012-12-02" 
due-to="sebb">
+        Removed emulation support for nested exceptions in EmailException.
+      </action>
       <action dev="tn" type="fix" issue="EMAIL-116" date="2012-11-10" 
due-to="sebb">
         Prevent external modification of internal array in 
DataSourceCompositeResolver.
       </action>

Modified: 
commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailException.java
URL: 
http://svn.apache.org/viewvc/commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailException.java?rev=1416237&r1=1416236&r2=1416237&view=diff
==============================================================================
--- 
commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailException.java 
(original)
+++ 
commons/proper/email/trunk/src/java/org/apache/commons/mail/EmailException.java 
Sun Dec  2 19:25:13 2012
@@ -23,9 +23,10 @@ import java.io.PrintWriter;
 /**
  * Exception thrown when a checked error occurs in commons-email.
  * <p>
- * Supports nesting, emulating JDK 1.4 behavior if necessary.
- * <p>
  * Adapted from FunctorException in Commons Collections.
+ * <p>
+ * Emulation support for nested exceptions has been removed in {@code Email 
1.3},
+ * supported by JDK &ge; 1.4.
  *
  * @author jakarta-commons
  * @since 1.0
@@ -38,40 +39,12 @@ public class EmailException
     private static final long serialVersionUID = 5550674499282474616L;
 
     /**
-     * Does JDK support nested exceptions?
-     */
-    private static final boolean JDK_SUPPORTS_NESTED;
-
-    static
-    {
-        boolean flag = false;
-
-        try
-        {
-            Throwable.class.getDeclaredMethod("getCause", new Class[0]);
-            flag = true;
-        }
-        catch (NoSuchMethodException ex)
-        {
-            flag = false;
-        }
-
-        JDK_SUPPORTS_NESTED = flag;
-    }
-
-    /**
-     * Root cause of the exception
-     */
-    private final Throwable rootCause;
-
-    /**
      * Constructs a new <code>EmailException</code> with no
      * detail message.
      */
     public EmailException()
     {
         super();
-        this.rootCause = null;
     }
 
     /**
@@ -83,7 +56,6 @@ public class EmailException
     public EmailException(String msg)
     {
         super(msg);
-        this.rootCause = null;
     }
 
     /**
@@ -95,8 +67,7 @@ public class EmailException
      */
     public EmailException(Throwable rootCause)
     {
-        super((rootCause == null) ? null : rootCause.getMessage());
-        this.rootCause = rootCause;
+        super(rootCause);
     }
 
     /**
@@ -109,18 +80,7 @@ public class EmailException
      */
     public EmailException(String msg, Throwable rootCause)
     {
-        super(msg);
-        this.rootCause = rootCause;
-    }
-
-    /**
-     * Gets the cause of this throwable.
-     *
-     * @return  the cause of this throwable, or <code>null</code>
-     */
-    public Throwable getCause()
-    {
-        return rootCause;
+        super(msg, rootCause);
     }
 
     /**
@@ -158,12 +118,6 @@ public class EmailException
         synchronized (out)
         {
             super.printStackTrace(out);
-
-            if (!JDK_SUPPORTS_NESTED && (rootCause != null))
-            {
-                out.print("Caused by: ");
-                rootCause.printStackTrace(out);
-            }
         }
     }
 }


Reply via email to