commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bay...@apache.org
Subject svn commit: r956279 - in /commons/proper/collections/trunk/src/java/org/apache/commons/collections: BufferOverflowException.java BufferUnderflowException.java FunctorException.java
Date Sat, 19 Jun 2010 19:47:48 GMT
Author: bayard
Date: Sat Jun 19 19:47:48 2010
New Revision: 956279

URL: http://svn.apache.org/viewvc?rev=956279&view=rev
Log:
Simplifying exceptions now that cause is in the parent. Patch from Sebb in COLLECTIONS-336

Modified:
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
    commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java?rev=956279&r1=956278&r2=956279&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferOverflowException.java
Sat Jun 19 19:47:48 2010
@@ -34,15 +34,11 @@ public class BufferOverflowException ext
     /** Serialization version */
     private static final long serialVersionUID = -3992254982265755876L;
 
-    /** The root cause throwable */
-    private final Throwable throwable;
-
     /**
      * Constructs a new <code>BufferOverflowException</code>.
      */
     public BufferOverflowException() {
         super();
-        throwable = null;
     }
 
     /** 
@@ -61,18 +57,7 @@ public class BufferOverflowException ext
      * @param exception  the root cause of the exception
      */
     public BufferOverflowException(String message, Throwable exception) {
-        super(message);
-        throwable = exception;
+        super(message, exception);
     }
 
-    /**
-     * Gets the root cause of the exception.
-     *
-     * @return the root cause
-     */
-    @Override
-    public final Throwable getCause() {
-        return throwable;
-    }
-    
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java?rev=956279&r1=956278&r2=956279&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/BufferUnderflowException.java
Sat Jun 19 19:47:48 2010
@@ -35,17 +35,13 @@ import java.util.NoSuchElementException;
 public class BufferUnderflowException extends NoSuchElementException {
     
     /** Serialization version */
-    private static final long serialVersionUID = 4054570024234606028L;
-
-    /** The root cause throwable */
-    private final Throwable throwable;
+    private static final long serialVersionUID = 7106567570467436893L;
 
     /**
      * Constructs a new <code>BufferUnderflowException</code>.
      */
     public BufferUnderflowException() {
         super();
-        throwable = null;
     }
 
     /** 
@@ -54,7 +50,7 @@ public class BufferUnderflowException ex
      * @param message  the detail message for this exception
      */
     public BufferUnderflowException(String message) {
-        this(message, null);
+        super(message);
     }
 
     /** 
@@ -65,17 +61,7 @@ public class BufferUnderflowException ex
      */
     public BufferUnderflowException(String message, Throwable exception) {
         super(message);
-        throwable = exception;
+        initCause(exception);
     }
 
-    /**
-     * Gets the root cause of the exception.
-     *
-     * @return the root cause
-     */
-    @Override
-    public final Throwable getCause() {
-        return throwable;
-    }
-    
 }

Modified: commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java
URL: http://svn.apache.org/viewvc/commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java?rev=956279&r1=956278&r2=956279&view=diff
==============================================================================
--- commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java
(original)
+++ commons/proper/collections/trunk/src/java/org/apache/commons/collections/FunctorException.java
Sat Jun 19 19:47:48 2010
@@ -16,9 +16,6 @@
  */
 package org.apache.commons.collections;
 
-import java.io.PrintStream;
-import java.io.PrintWriter;
-
 /**
  * Runtime exception thrown from functors.
  * If required, a root cause error can be wrapped within this one.
@@ -31,28 +28,7 @@ import java.io.PrintWriter;
 public class FunctorException extends RuntimeException {
     
     /** Serialization version */
-    private static final long serialVersionUID = 9139387246344345475L;
-
-    /**
-     * 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;
+    private static final long serialVersionUID = -4704772662059351193L;
 
     /**
      * Constructs a new <code>FunctorException</code> without specified
@@ -60,7 +36,6 @@ public class FunctorException extends Ru
      */
     public FunctorException() {
         super();
-        this.rootCause = null;
     }
 
     /**
@@ -71,7 +46,6 @@ public class FunctorException extends Ru
      */
     public FunctorException(String msg) {
         super(msg);
-        this.rootCause = null;
     }
 
     /**
@@ -82,8 +56,7 @@ public class FunctorException extends Ru
      *                   to be thrown.
      */
     public FunctorException(Throwable rootCause) {
-        super((rootCause == null ? null : rootCause.getMessage()));
-        this.rootCause = rootCause;
+        super(rootCause);
     }
 
     /**
@@ -95,53 +68,7 @@ public class FunctorException extends Ru
      *                   to be thrown.
      */
     public FunctorException(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;
-    }
-
-    /**
-     * Prints the stack trace of this exception to the standard error stream.
-     */
-    public void printStackTrace() {
-        printStackTrace(System.err);
-    }
-
-    /**
-     * Prints the stack trace of this exception to the specified stream.
-     *
-     * @param out  the <code>PrintStream</code> to use for output
-     */
-    public void printStackTrace(PrintStream out) {
-        synchronized (out) {
-            PrintWriter pw = new PrintWriter(out, false);
-            printStackTrace(pw);
-            // Flush the PrintWriter before it's GC'ed.
-            pw.flush();
-        }
-    }
-
-    /**
-     * Prints the stack trace of this exception to the specified writer.
-     *
-     * @param out  the <code>PrintWriter</code> to use for output
-     */
-    public void printStackTrace(PrintWriter out) {
-        synchronized (out) {
-            super.printStackTrace(out);
-            if (rootCause != null && JDK_SUPPORTS_NESTED == false) {
-                out.print("Caused by: ");
-                rootCause.printStackTrace(out);
-            }
-        }
+        super(msg, rootCause);
     }
 
 }



Mime
View raw message