leverage null pointer handling,

exception classes can be built using null arguments arrays which
are automatically converted to zero-sized arrays to prevent null pointer exceptions

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@712142 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-11-07 14:48:13 +00:00
parent 234e529e70
commit b1592908df
10 changed files with 14 additions and 14 deletions

View File

@ -31,7 +31,7 @@ public class ConvergenceException extends MathException {
* Default constructor.
*/
public ConvergenceException() {
super("Convergence failed", new Object[0]);
super("Convergence failed", null);
}
/**

View File

@ -35,7 +35,7 @@ public class CardanEulerSingularityException
* if false it is related to EulerAngles
*/
public CardanEulerSingularityException(boolean isCardan) {
super(isCardan ? "Cardan angles singularity" : "Euler angles singularity", new Object[0]);
super(isCardan ? "Cardan angles singularity" : "Euler angles singularity", null);
}
/** Serializable version identifier */

View File

@ -31,7 +31,7 @@ public class RankDeficientMatrixException extends InvalidMatrixException {
* Construct an exception with a default message.
*/
public RankDeficientMatrixException() {
super("matrix is rank-deficient", new Object[0]);
super("matrix is rank-deficient", null);
}
}

View File

@ -31,7 +31,7 @@ public class SingularMatrixException extends InvalidMatrixException {
* Construct an exception with a default message.
*/
public SingularMatrixException() {
super("matrix is singular", new Object[0]);
super("matrix is singular", null);
}
}

View File

@ -36,7 +36,7 @@ public class NotPositiveDefiniteMatrixException extends MathException {
* build an exception with a default message.
*/
public NotPositiveDefiniteMatrixException() {
super("not positive definite matrix", new Object[0]);
super("not positive definite matrix", null);
}
}

View File

@ -30,7 +30,7 @@ public class MathConfigurationExceptionTest extends TestCase {
MathConfigurationException ex = new MathConfigurationException();
assertNull(ex.getCause());
assertNull(ex.getMessage());
assertNull(ex.getMessage(Locale.FRENCH));
assertEquals(0, ex.getMessage(Locale.FRENCH).length());
}
public void testConstructorPatternArguments(){

View File

@ -33,7 +33,7 @@ public class MathExceptionTest extends TestCase {
MathException ex = new MathException();
assertNull(ex.getCause());
assertNull(ex.getMessage());
assertNull(ex.getMessage(Locale.FRENCH));
assertEquals(0, ex.getMessage(Locale.FRENCH).length());
}
public void testConstructorPatternArguments(){
@ -79,8 +79,8 @@ public class MathExceptionTest extends TestCase {
public void testPrintStackTrace() {
String outMsg = "outer message";
String inMsg = "inner message";
MathException cause = new MathConfigurationException(inMsg, new Object[0]);
MathException ex = new MathException(outMsg, new Object[0], cause);
MathException cause = new MathConfigurationException(inMsg, null);
MathException ex = new MathException(outMsg, null, cause);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintStream ps = new PrintStream(baos);
ex.printStackTrace(ps);
@ -104,8 +104,8 @@ public class MathExceptionTest extends TestCase {
public void testSerialization() {
String outMsg = "outer message";
String inMsg = "inner message";
MathException cause = new MathConfigurationException(inMsg, new Object[0]);
MathException ex = new MathException(outMsg, new Object[0], cause);
MathException cause = new MathConfigurationException(inMsg, null);
MathException ex = new MathException(outMsg, null, cause);
MathException image = (MathException) TestUtils.serializeAndRecover(ex);
ByteArrayOutputStream baos = new ByteArrayOutputStream();

View File

@ -29,7 +29,7 @@ public class InvalidMatrixExceptionTest extends TestCase {
*/
public void testConstructorMessage(){
String msg = "message";
InvalidMatrixException ex = new InvalidMatrixException(msg, new Object[0]);
InvalidMatrixException ex = new InvalidMatrixException(msg, null);
assertEquals(msg, ex.getMessage());
}
}

View File

@ -29,7 +29,7 @@ public class MatrixIndexExceptionTest extends TestCase {
*/
public void testConstructorMessage(){
String msg = "message";
MatrixIndexException ex = new MatrixIndexException(msg, new Object[0]);
MatrixIndexException ex = new MatrixIndexException(msg, null);
assertEquals(msg, ex.getMessage());
}
}

View File

@ -659,7 +659,7 @@ public final class RealMatrixImplTest extends TestCase {
if (!lu.isSquare() || lowerData.length != lowerData[0].length || upperData.length != upperData[0].length ||
lowerData.length != upperData.length
|| lowerData.length != lu.getRowDimension()) {
throw new InvalidMatrixException("incorrect dimensions", new Object[0]);
throw new InvalidMatrixException("incorrect dimensions", null);
}
int n = lu.getRowDimension();
for (int i = 0; i < n; i++) {