This is an automated email from the ASF dual-hosted git repository. ggregory pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/commons-math.git
The following commit(s) were added to refs/heads/master by this push: new 553504b29 Use Java 6 API for exception construction 553504b29 is described below commit 553504b292cbe7d3abd6ff92856785ca1dbeaeda Author: Gary D. Gregory <garydgreg...@gmail.com> AuthorDate: Sat Feb 15 14:27:13 2025 -0500 Use Java 6 API for exception construction Use multi-catch --- .../commons/math4/legacy/linear/MatrixUtils.java | 20 ++++---------------- .../nonstiff/DormandPrince853StepInterpolator.java | 4 +--- .../ode/sampling/AbstractStepInterpolator.java | 4 +--- 3 files changed, 6 insertions(+), 22 deletions(-) diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/MatrixUtils.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/MatrixUtils.java index 7c03e70ea..24615e24e 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/MatrixUtils.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/linear/MatrixUtils.java @@ -692,14 +692,8 @@ public final class MatrixUtils { instance.getClass().getDeclaredField(fieldName); f.setAccessible(true); f.set(instance, vector); - } catch (NoSuchFieldException nsfe) { - IOException ioe = new IOException(); - ioe.initCause(nsfe); - throw ioe; - } catch (IllegalAccessException iae) { - IOException ioe = new IOException(); - ioe.initCause(iae); - throw ioe; + } catch (NoSuchFieldException | IllegalAccessException e) { + throw new IOException(e); } } @@ -798,14 +792,8 @@ public final class MatrixUtils { instance.getClass().getDeclaredField(fieldName); f.setAccessible(true); f.set(instance, matrix); - } catch (NoSuchFieldException nsfe) { - IOException ioe = new IOException(); - ioe.initCause(nsfe); - throw ioe; - } catch (IllegalAccessException iae) { - IOException ioe = new IOException(); - ioe.initCause(iae); - throw ioe; + } catch (NoSuchFieldException | IllegalAccessException nsfe) { + throw new IOException(nsfe); } } diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolator.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolator.java index 1ecded0b7..d4b5af45d 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolator.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/nonstiff/DormandPrince853StepInterpolator.java @@ -449,9 +449,7 @@ class DormandPrince853StepInterpolator // save the local attributes finalizeStep(); } catch (MaxCountExceededException mcee) { - final IOException ioe = new IOException(mcee.getLocalizedMessage()); - ioe.initCause(mcee); - throw ioe; + throw new IOException(mcee.getLocalizedMessage(), mcee); } final int dimension = (currentState == null) ? -1 : currentState.length; diff --git a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/sampling/AbstractStepInterpolator.java b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/sampling/AbstractStepInterpolator.java index b074415af..b0abcb675 100644 --- a/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/sampling/AbstractStepInterpolator.java +++ b/commons-math-legacy/src/main/java/org/apache/commons/math4/legacy/ode/sampling/AbstractStepInterpolator.java @@ -555,9 +555,7 @@ public double getCurrentTime() { // finalize the step (and don't bother saving the now true flag) finalizeStep(); } catch (MaxCountExceededException mcee) { - final IOException ioe = new IOException(mcee.getLocalizedMessage()); - ioe.initCause(mcee); - throw ioe; + throw new IOException(mcee.getLocalizedMessage(), mcee); } }