You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by lu...@apache.org on 2008/11/07 15:35:26 UTC

svn commit: r712136 - /commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java

Author: luc
Date: Fri Nov  7 06:35:16 2008
New Revision: 712136

URL: http://svn.apache.org/viewvc?rev=712136&view=rev
Log:
removed forgotten pre-JDK 1.4 stuff
added protection against null pointer exceptions

Modified:
    commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java

Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java
URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java?rev=712136&r1=712135&r2=712136&view=diff
==============================================================================
--- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java (original)
+++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathException.java Fri Nov  7 06:35:16 2008
@@ -35,24 +35,8 @@
 */
 public class MathException extends Exception {
     
-    /** Serializable version identifier */
-    private static final long serialVersionUID = 1428666635974829194L;
-
-    /**
-     * 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;
-    }
+    /** Serializable version identifier. */
+    private static final long serialVersionUID = 5924076008552401454L;
 
     /** Cache for resources bundle. */
     private static ResourceBundle cachedResources = null;
@@ -105,7 +89,7 @@
      * @return a message string
      */
     private static String buildMessage(String pattern, Object[] arguments, Locale locale) {
-        return new MessageFormat(translate(pattern, locale), locale).format(arguments);        
+        return (pattern == null) ? "" : new MessageFormat(translate(pattern, locale), locale).format(arguments);        
     }
 
     /**
@@ -115,7 +99,7 @@
     public MathException() {
         super();
         this.pattern   = null;
-        this.arguments = new Object[0];
+        this.arguments = null;
     }
     
     /**
@@ -128,7 +112,7 @@
     public MathException(String pattern, Object[] arguments) {
       super(buildMessage(pattern, arguments, Locale.US));
       this.pattern   = pattern;
-      this.arguments = (Object[]) arguments.clone();
+      this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
 
     /**
@@ -157,7 +141,7 @@
     public MathException(String pattern, Object[] arguments, Throwable rootCause) {
       super(buildMessage(pattern, arguments, Locale.US), rootCause);
       this.pattern   = pattern;
-      this.arguments = (Object[]) arguments.clone();
+      this.arguments = (arguments == null) ? new Object[0] : arguments.clone();
     }
 
     /** Gets the pattern used to build the message of this throwable.
@@ -175,7 +159,7 @@
      * @since 1.2
      */
     public Object[] getArguments() {
-        return (Object[]) arguments.clone();
+        return arguments.clone();
     }
 
     /** Gets the message in a specified locale.
@@ -186,7 +170,7 @@
      * @since 1.2
      */
     public String getMessage(Locale locale) {
-        return (pattern == null) ? null : buildMessage(pattern, arguments, locale);
+        return buildMessage(pattern, arguments, locale);
     }
 
     /** {@inheritDoc} */
@@ -214,5 +198,5 @@
             pw.flush();
         }
     }
-    
+
 }