Return-Path: Delivered-To: apmail-commons-commits-archive@locus.apache.org Received: (qmail 1045 invoked from network); 7 Nov 2008 16:32:40 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Nov 2008 16:32:40 -0000 Received: (qmail 55724 invoked by uid 500); 7 Nov 2008 16:32:45 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 55672 invoked by uid 500); 7 Nov 2008 16:32:45 -0000 Mailing-List: contact commits-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@commons.apache.org Delivered-To: mailing list commits@commons.apache.org Received: (qmail 55662 invoked by uid 99); 7 Nov 2008 16:32:45 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Nov 2008 08:32:45 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 07 Nov 2008 16:31:35 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id A247923889E9; Fri, 7 Nov 2008 08:32:17 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r712187 - in /commons/proper/math/branches/MATH_2_0/src: java/org/apache/commons/math/ java/org/apache/commons/math/ode/nonstiff/ java/org/apache/commons/math/ode/sampling/ java/org/apache/commons/math/random/ test/org/apache/commons/math/o... Date: Fri, 07 Nov 2008 16:32:09 -0000 To: commits@commons.apache.org From: luc@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081107163217.A247923889E9@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: luc Date: Fri Nov 7 08:31:58 2008 New Revision: 712187 URL: http://svn.apache.org/viewvc?rev=712187&view=rev Log: allow chained IOExceptions even before Java 6 Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathRuntimeException.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MultistepStepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathRuntimeException.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathRuntimeException.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathRuntimeException.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/MathRuntimeException.java Fri Nov 7 08:31:58 2008 @@ -17,6 +17,7 @@ package org.apache.commons.math; import java.io.EOFException; +import java.io.IOException; import java.io.PrintStream; import java.io.PrintWriter; import java.text.MessageFormat; @@ -249,6 +250,22 @@ } /** + * Constructs a new IOException with specified nested + * Throwable root cause. + *

This factory method allows chaining of other exceptions within an + * IOException even for Java 5. The constructor for + * IOException with a cause parameter was introduced only + * with Java 6.

+ * @param rootCause the exception or error that caused this exception + * to be thrown. + */ + public static IOException createIOException(final Throwable rootCause) { + IOException ioe = new IOException(rootCause.getLocalizedMessage()); + ioe.initCause(rootCause); + return ioe; + } + + /** * Constructs a new IllegalArgumentException with specified formatted detail message. * Message formatting is delegated to {@link java.text.MessageFormat}. * @param pattern format specifier Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/DormandPrince853StepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.FirstOrderDifferentialEquations; import org.apache.commons.math.ode.sampling.StepInterpolator; @@ -250,7 +251,7 @@ // save the local attributes finalizeStep(); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } out.writeInt(currentState.length); for (int i = 0; i < currentState.length; ++i) { Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/GraggBulirschStoerStepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import java.io.IOException; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.sampling.AbstractStepInterpolator; import org.apache.commons.math.ode.sampling.StepInterpolator; @@ -392,7 +393,7 @@ // we can now set the interpolated time and state setInterpolatedTime(t); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } } Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MultistepStepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MultistepStepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MultistepStepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/MultistepStepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectInput; import java.io.ObjectOutput; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.sampling.AbstractStepInterpolator; @@ -157,7 +158,7 @@ // we can now set the interpolated time and state setInterpolatedTime(t); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } } Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/nonstiff/RungeKuttaStepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import java.io.IOException; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.FirstOrderDifferentialEquations; import org.apache.commons.math.ode.sampling.AbstractStepInterpolator; @@ -165,7 +166,7 @@ // we can now set the interpolated time and state setInterpolatedTime(t); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } } Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/AbstractStepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import java.io.IOException; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.FirstOrderIntegrator; import org.apache.commons.math.ode.SecondOrderIntegrator; @@ -369,7 +370,7 @@ try { finalizeStep(); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } } Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/ode/sampling/DummyStepInterpolator.java Fri Nov 7 08:31:58 2008 @@ -21,6 +21,7 @@ import java.io.ObjectOutput; import java.io.IOException; +import org.apache.commons.math.MathRuntimeException; import org.apache.commons.math.ode.DerivativeException; import org.apache.commons.math.ode.nonstiff.EmbeddedRungeKuttaIntegrator; @@ -119,7 +120,7 @@ // we can now set the interpolated time and state setInterpolatedTime(t); } catch (DerivativeException e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } } Modified: commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java (original) +++ commons/proper/math/branches/MATH_2_0/src/java/org/apache/commons/math/random/EmpiricalDistributionImpl.java Fri Nov 7 08:31:58 2008 @@ -136,7 +136,7 @@ // don't wrap RuntimeExceptions throw rte; } catch (Exception e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } if (sampleStats.getN() == 0) { throw MathRuntimeException.createEOFException("URL {0} contains no data", @@ -175,7 +175,7 @@ // don't wrap RuntimeExceptions throw rte; } catch (Exception e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } in = new BufferedReader(new FileReader(file)); fillBinStats(in); @@ -376,7 +376,7 @@ // don't wrap RuntimeExceptions throw rte; } catch (Exception e) { - throw new IOException(e.getMessage()); + throw MathRuntimeException.createIOException(e); } // Assign upperBounds based on bin counts Modified: commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java?rev=712187&r1=712186&r2=712187&view=diff ============================================================================== --- commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java (original) +++ commons/proper/math/branches/MATH_2_0/src/test/org/apache/commons/math/ode/sampling/DummyStepInterpolatorTest.java Fri Nov 7 08:31:58 2008 @@ -120,7 +120,7 @@ fail("an exception should have been thrown"); } catch (IOException ioe) { // expected behavior - assertNull(ioe.getMessage()); + assertEquals(0, ioe.getMessage().length()); } catch (Exception e) { fail("wrong exception caught"); } @@ -166,7 +166,7 @@ fail("an exception should have been thrown"); } catch (IOException ioe) { // expected behavior - assertNull(ioe.getMessage()); + assertEquals(0, ioe.getMessage().length()); } catch (Exception e) { fail("wrong exception caught"); }