Merge branch 'master' of https://gitbox.apache.org/repos/asf/commons-math.git
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 28cd6ba..0876768 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -54,6 +54,9 @@
     </release>
 
     <release version="4.0" date="XXXX-XX-XX" description="">
+      <action dev="erans" type="fix" issue="MATH-1565" due-to="Randy Strauss">
+        Add context to "OutOfRangeException".
+      </action>
       <action dev="erans" type="update" issue="MATH-1562" due-to="Frank Ulbricht">
         Add "Automatic-Module-Name" entry to JAR manifest file.
       </action>
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java
index d010fbd..757e92d 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/MidPointIntegrator.java
@@ -16,12 +16,7 @@
  */
 package org.apache.commons.math4.analysis.integration;
 
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
 import org.apache.commons.math4.util.FastMath;
 
 /**
@@ -47,9 +42,9 @@
      * @param absoluteAccuracy absolute accuracy of the result
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than 39.
@@ -69,9 +64,9 @@
      * Build a midpoint integrator with given iteration counts.
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than 39.
@@ -109,7 +104,7 @@
      * @param diffMaxMin Difference between the lower bound and upper bound
      * of the integration interval.
      * @return the value of n-th stage integral
-     * @throws TooManyEvaluationsException if the maximal number of evaluations
+     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximal number of evaluations
      * is exceeded.
      */
     private double stage(final int n,
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java
index 50179df..5e81c01 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/RombergIntegrator.java
@@ -16,11 +16,7 @@
  */
 package org.apache.commons.math4.analysis.integration;
 
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
 import org.apache.commons.math4.util.FastMath;
 
 /**
@@ -47,9 +43,9 @@
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
      * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT})
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT}
@@ -70,9 +66,9 @@
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
      * (must be less than or equal to {@link #ROMBERG_MAX_ITERATIONS_COUNT})
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than {@link #ROMBERG_MAX_ITERATIONS_COUNT}
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java
index 554be75..0e85f72 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/SimpsonIntegrator.java
@@ -16,9 +16,7 @@
  */
 package org.apache.commons.math4.analysis.integration;
 
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
 import org.apache.commons.math4.util.FastMath;
 
 /**
@@ -44,9 +42,9 @@
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
      * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT})
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT}
@@ -67,9 +65,9 @@
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
      * (must be less than or equal to {@link #SIMPSON_MAX_ITERATIONS_COUNT})
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than {@link #SIMPSON_MAX_ITERATIONS_COUNT}
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java
index 5a7e0e8..87239c7 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/TrapezoidIntegrator.java
@@ -16,12 +16,7 @@
  */
 package org.apache.commons.math4.analysis.integration;
 
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NumberIsTooLargeException;
-import org.apache.commons.math4.exception.NumberIsTooSmallException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
 import org.apache.commons.math4.util.FastMath;
 
 /**
@@ -48,9 +43,9 @@
      * @param absoluteAccuracy absolute accuracy of the result
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than 63.
@@ -70,9 +65,9 @@
      * Build a trapezoid integrator with given iteration counts.
      * @param minimalIterationCount minimum number of iterations
      * @param maximalIterationCount maximum number of iterations
-     * @exception NotStrictlyPositiveException if minimal number of iterations
+     * @exception org.apache.commons.math4.exception.NotStrictlyPositiveException if minimal number of iterations
      * is not strictly positive
-     * @exception NumberIsTooSmallException if maximal number of iterations
+     * @exception org.apache.commons.math4.exception.NumberIsTooSmallException if maximal number of iterations
      * is lesser than or equal to the minimal number of iterations
      * @exception NumberIsTooLargeException if maximal number of iterations
      * is greater than 63.
@@ -106,7 +101,7 @@
      * @param baseIntegrator integrator holding integration parameters
      * @param n the stage of 1/2 refinement, n = 0 is no refinement
      * @return the value of n-th stage integral
-     * @throws TooManyEvaluationsException if the maximal number of evaluations
+     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximal number of evaluations
      * is exceeded.
      */
     double stage(final BaseAbstractUnivariateIntegrator baseIntegrator, final int n) {
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java
index 994985c..97dd416 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/UnivariateIntegrator.java
@@ -17,10 +17,6 @@
 package org.apache.commons.math4.analysis.integration;
 
 import org.apache.commons.math4.analysis.UnivariateFunction;
-import org.apache.commons.math4.exception.MathIllegalArgumentException;
-import org.apache.commons.math4.exception.MaxCountExceededException;
-import org.apache.commons.math4.exception.NullArgumentException;
-import org.apache.commons.math4.exception.TooManyEvaluationsException;
 
 /**
  * Interface for univariate real integration algorithms.
@@ -65,13 +61,13 @@
      * @param min the lower bound for the interval
      * @param max the upper bound for the interval
      * @return the value of integral
-     * @throws TooManyEvaluationsException if the maximum number of function
+     * @throws org.apache.commons.math4.exception.TooManyEvaluationsException if the maximum number of function
      * evaluations is exceeded
-     * @throws MaxCountExceededException if the maximum iteration count is exceeded
+     * @throws org.apache.commons.math4.exception.MaxCountExceededException if the maximum iteration count is exceeded
      * or the integrator detects convergence problems otherwise
-     * @throws MathIllegalArgumentException if {@code min > max} or the endpoints do not
+     * @throws org.apache.commons.math4.exception.MathIllegalArgumentException if {@code min > max} or the endpoints do not
      * satisfy the requirements specified by the integrator
-     * @throws NullArgumentException if {@code f} is {@code null}.
+     * @throws org.apache.commons.math4.exception.NullArgumentException if {@code f} is {@code null}.
      */
     double integrate(int maxEval, UnivariateFunction f, double min, double max);
 
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java
index de86f48..9e0213a 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegrator.java
@@ -18,7 +18,6 @@
 
 import org.apache.commons.math4.analysis.UnivariateFunction;
 import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
 import org.apache.commons.math4.util.MathArrays;
 import org.apache.commons.math4.util.Pair;
 
@@ -42,7 +41,7 @@
      *
      * @param points Integration points.
      * @param weights Weights of the corresponding integration nodes.
-     * @throws NonMonotonicSequenceException if the {@code points} are not
+     * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not
      * sorted in increasing order.
      * @throws DimensionMismatchException if points and weights don't have the same length
      */
@@ -64,7 +63,7 @@
      * the pair) and weights (second element of the pair.
      *
      * @param pointsAndWeights Integration points and corresponding weights.
-     * @throws NonMonotonicSequenceException if the {@code points} are not
+     * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not
      * sorted in increasing order.
      *
      * @see #GaussIntegrator(double[], double[])
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java
index 3b1c2eb..e65124c 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/GaussIntegratorFactory.java
@@ -16,11 +16,8 @@
  */
 package org.apache.commons.math4.analysis.integration.gauss;
 
-import java.math.BigDecimal;
-
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.util.Pair;
+import java.math.BigDecimal;
 
 /**
  * Class that provides different ways to compute the nodes and weights to be
@@ -81,7 +78,7 @@
      * @param lowerBound Lower bound of the integration interval.
      * @param upperBound Upper bound of the integration interval.
      * @return a Gauss-Legendre integrator.
-     * @throws NotStrictlyPositiveException if number of points is not positive
+     * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive
      */
     public GaussIntegrator legendre(int numberOfPoints,
                                     double lowerBound,
@@ -99,7 +96,7 @@
      *
      * @param numberOfPoints Order of the integration rule.
      * @return a Gauss-Legendre integrator.
-     * @throws NotStrictlyPositiveException if number of points is not positive
+     * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive
      */
     public GaussIntegrator legendreHighPrecision(int numberOfPoints) {
         return new GaussIntegrator(getRule(legendreHighPrecision, numberOfPoints));
@@ -114,7 +111,7 @@
      * @param lowerBound Lower bound of the integration interval.
      * @param upperBound Upper bound of the integration interval.
      * @return a Gauss-Legendre integrator.
-     * @throws NotStrictlyPositiveException if number of points is not positive
+     * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive
      */
     public GaussIntegrator legendreHighPrecision(int numberOfPoints,
                                                  double lowerBound,
@@ -145,8 +142,8 @@
      * @param factory Integration rule factory.
      * @param numberOfPoints Order of the integration rule.
      * @return the integration nodes and weights.
-     * @throws NotStrictlyPositiveException if number of points is not positive
-     * @throws DimensionMismatchException if the elements of the rule pair do not
+     * @throws org.apache.commons.math4.exception.NotStrictlyPositiveException if number of points is not positive
+     * @throws org.apache.commons.math4.exception.DimensionMismatchException if the elements of the rule pair do not
      * have the same length.
      */
     private static Pair<double[], double[]> getRule(BaseRuleFactory<? extends Number> factory,
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java
index c680ed9..2d5a3e1 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/HermiteRuleFactory.java
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.math4.analysis.integration.gauss;
 
-import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.util.FastMath;
 import org.apache.commons.math4.util.Pair;
 
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java
index fc9eb3b..23e45df 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LaguerreRuleFactory.java
@@ -20,7 +20,6 @@
 
 import org.apache.commons.math4.analysis.polynomials.PolynomialFunction;
 import org.apache.commons.math4.analysis.polynomials.PolynomialsUtils;
-import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.linear.EigenDecomposition;
 import org.apache.commons.math4.linear.MatrixUtils;
 import org.apache.commons.math4.linear.RealMatrix;
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
index 811f6d1..e5ce3c6 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreHighPrecisionRuleFactory.java
@@ -19,7 +19,6 @@
 import java.math.BigDecimal;
 import java.math.MathContext;
 
-import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.util.Pair;
 
 /**
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java
index 657f594..cbc1e7d 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/LegendreRuleFactory.java
@@ -16,7 +16,6 @@
  */
 package org.apache.commons.math4.analysis.integration.gauss;
 
-import org.apache.commons.math4.exception.DimensionMismatchException;
 import org.apache.commons.math4.util.Pair;
 
 /**
diff --git a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java
index 083b848..1230a1d 100644
--- a/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java
+++ b/src/main/java/org/apache/commons/math4/analysis/integration/gauss/SymmetricGaussIntegrator.java
@@ -17,8 +17,6 @@
 package org.apache.commons.math4.analysis.integration.gauss;
 
 import org.apache.commons.math4.analysis.UnivariateFunction;
-import org.apache.commons.math4.exception.DimensionMismatchException;
-import org.apache.commons.math4.exception.NonMonotonicSequenceException;
 import org.apache.commons.math4.util.Pair;
 
 /**
@@ -36,9 +34,9 @@
      *
      * @param points Integration points.
      * @param weights Weights of the corresponding integration nodes.
-     * @throws NonMonotonicSequenceException if the {@code points} are not
+     * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not
      * sorted in increasing order.
-     * @throws DimensionMismatchException if points and weights don't have the same length
+     * @throws org.apache.commons.math4.exception.DimensionMismatchException if points and weights don't have the same length
      */
     public SymmetricGaussIntegrator(double[] points,
                                     double[] weights) {
@@ -50,7 +48,7 @@
      * the pair) and weights (second element of the pair.
      *
      * @param pointsAndWeights Integration points and corresponding weights.
-     * @throws NonMonotonicSequenceException if the {@code points} are not
+     * @throws org.apache.commons.math4.exception.NonMonotonicSequenceException if the {@code points} are not
      * sorted in increasing order.
      *
      * @see #SymmetricGaussIntegrator(double[], double[])
diff --git a/src/main/java/org/apache/commons/math4/exception/OutOfRangeException.java b/src/main/java/org/apache/commons/math4/exception/OutOfRangeException.java
index 4e8dd62..0d6730e 100644
--- a/src/main/java/org/apache/commons/math4/exception/OutOfRangeException.java
+++ b/src/main/java/org/apache/commons/math4/exception/OutOfRangeException.java
@@ -42,7 +42,9 @@
     public OutOfRangeException(Number wrong,
                                Number lo,
                                Number hi) {
-        this(LocalizedFormats.OUT_OF_RANGE_SIMPLE, wrong, lo, hi);
+        super(LocalizedFormats.OUT_OF_RANGE_SIMPLE, wrong, lo, hi);
+        this.lo = lo;
+        this.hi = hi;
     }
 
     /**
@@ -58,9 +60,8 @@
                                Number wrong,
                                Number lo,
                                Number hi) {
-        super(specific, wrong, lo, hi);
-        this.lo = lo;
-        this.hi = hi;
+        this(wrong, lo, hi);
+        getContext().addMessage(specific, wrong, lo, hi);
     }
 
     /**
diff --git a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java
index 651339c..867a841 100644
--- a/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java
+++ b/src/test/java/org/apache/commons/math4/analysis/integration/gauss/BaseRuleFactoryTest.java
@@ -59,6 +59,7 @@
         for (Future<Pair<double[], double[]>> f : results) {
             f.get();
         }
+        exec.shutdown();
 
         // Assertion would fail if "getRuleInternal" were not "synchronized".
         final int n = RuleBuilder.getNumberOfCalls();
diff --git a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java
index 9940c1c..e7486f2 100644
--- a/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java
+++ b/src/test/java/org/apache/commons/math4/linear/MatrixUtilsTest.java
@@ -22,6 +22,7 @@
 import org.apache.commons.math4.exception.MathIllegalArgumentException;
 import org.apache.commons.math4.exception.NotStrictlyPositiveException;
 import org.apache.commons.math4.exception.NullArgumentException;
+import org.apache.commons.math4.exception.OutOfRangeException;
 import org.apache.commons.math4.dfp.Dfp;
 import org.junit.Assert;
 import org.junit.Test;
@@ -445,4 +446,43 @@
                 MatrixUtils.createRealIdentityMatrix(testData.length), result, 1e-12);
     }
 
+    @Test
+    public void testCheckMatrixRowIndexError() {
+        try {
+            AnyMatrix m = MatrixUtils.createRealMatrix(new double[][] {{9,9}, {9,9}, {9,9}});
+            MatrixUtils.checkRowIndex(m, 4);
+            Assert.fail("expected an OutOfRangeException");
+        } catch (OutOfRangeException e) {
+            String s = e.getMessage();
+            int topIx = s.indexOf('2');
+            int botIx = s.indexOf('0');
+            int rowIx = s.indexOf('4');
+            if (topIx < 0 || botIx < 0 || rowIx < 0) {
+                Assert.fail("expected a message like index 4 is not in 0..3, not: " + s);
+            }
+        } catch (Exception e) {
+            Assert.fail("expected an OutOfRange exception, not: " +
+                        e.getClass().getName() + ": " + e.getMessage());
+        }
+    }
+
+    @Test
+    public void testCheckMatrixColIndexError() {
+        try {
+            AnyMatrix m = MatrixUtils.createRealMatrix(new double[][] {{9,9}, {9,9}, {9,9}});
+            MatrixUtils.checkColumnIndex(m, 4);
+            Assert.fail("expected an OutOfRangeException");
+        } catch (OutOfRangeException e) {
+            String s = e.getMessage();
+            int topIx = s.indexOf('1');
+            int botIx = s.indexOf('0');
+            int rowIx = s.indexOf('4');
+            if (topIx < 0 || botIx < 0 || rowIx < 0) {
+                Assert.fail("expected a message like index 4 is not in 0..3, not: " + s);
+            }
+        } catch (Exception e) {
+            Assert.fail("expected an OutOfRange exception, not: " +
+                        e.getClass().getName() + ": " + e.getMessage());
+        }
+    }
 }
diff --git a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java
index bc58b13..b953871 100644
--- a/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java
+++ b/src/test/java/org/apache/commons/math4/random/SynchronizedRandomGeneratorTest.java
@@ -114,6 +114,7 @@
         for (int i = 0; i < numGenerators; i++) {
             values[i] = results.get(i).get();
         }
+        exec.shutdown();
         return values;
     }
 }