Return-Path: Delivered-To: apmail-commons-commits-archive@minotaur.apache.org Received: (qmail 40082 invoked from network); 28 Jun 2010 12:03:08 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 28 Jun 2010 12:03:08 -0000 Received: (qmail 43834 invoked by uid 500); 28 Jun 2010 12:03:07 -0000 Delivered-To: apmail-commons-commits-archive@commons.apache.org Received: (qmail 42709 invoked by uid 500); 28 Jun 2010 12:03:03 -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 42165 invoked by uid 99); 28 Jun 2010 12:03:02 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Jun 2010 12:03:02 +0000 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; Mon, 28 Jun 2010 12:02:59 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 4DCA62388A02; Mon, 28 Jun 2010 12:01:36 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r958551 - in /commons/proper/math/trunk/src: main/java/org/apache/commons/math/exception/ test/java/org/apache/commons/math/exception/ Date: Mon, 28 Jun 2010 12:01:36 -0000 To: commits@commons.apache.org From: erans@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20100628120136.4DCA62388A02@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: erans Date: Mon Jun 28 12:01:35 2010 New Revision: 958551 URL: http://svn.apache.org/viewvc?rev=958551&view=rev Log: MATH-361. Added a check to avoid triggering a "NullPointerException" if the argument list is "null". Added unit tests. Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java (with props) commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java (with props) commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java (with props) commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java (with props) Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java Modified: commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java?rev=958551&r1=958550&r2=958551&view=diff ============================================================================== --- commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java (original) +++ commons/proper/math/trunk/src/main/java/org/apache/commons/math/exception/MathIllegalArgumentException.java Mon Jun 28 12:01:35 2010 @@ -72,11 +72,13 @@ public class MathIllegalArgumentExceptio */ private List flatten(Object[] array) { final List list = new ArrayList(); - for (Object o : array) { - if (o instanceof Object[]) { - list.addAll(flatten((Object[]) o)); - } else { - list.add(o); + if (array != null) { + for (Object o : array) { + if (o instanceof Object[]) { + list.addAll(flatten((Object[]) o)); + } else { + list.add(o); + } } } return list; Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java?rev=958551&view=auto ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java (added) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java Mon Jun 28 12:01:35 2010 @@ -0,0 +1,34 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math.exception; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link DimensionMismatchException}. + * + * @version $Revision$ $Date$ + */ +public class DimensionMismatchExceptionTest { + @Test + public void testAccessors() { + final DimensionMismatchException e = new DimensionMismatchException(1, 2); + Assert.assertEquals(1, e.getArgument()); + Assert.assertEquals(2, e.getDimension()); + } +} Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/DimensionMismatchExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java?rev=958551&view=auto ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java (added) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java Mon Jun 28 12:01:35 2010 @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math.exception; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link NotPositiveException}. + * + * @version $Revision$ $Date$ + */ +public class NotPositiveExceptionTest { + @Test + public void testAccessors() { + final NotPositiveException e = new NotPositiveException(-1); + Assert.assertEquals(-1, e.getArgument()); + } +} Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotPositiveExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java?rev=958551&view=auto ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java (added) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java Mon Jun 28 12:01:35 2010 @@ -0,0 +1,33 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math.exception; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link NotStrictlyPositiveException}. + * + * @version $Revision$ $Date$ + */ +public class NotStrictlyPositiveExceptionTest { + @Test + public void testAccessors() { + final NotStrictlyPositiveException e = new NotStrictlyPositiveException(0); + Assert.assertEquals(0, e.getArgument()); + } +} Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/NotStrictlyPositiveExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native Added: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java URL: http://svn.apache.org/viewvc/commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java?rev=958551&view=auto ============================================================================== --- commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java (added) +++ commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java Mon Jun 28 12:01:35 2010 @@ -0,0 +1,35 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.commons.math.exception; + +import org.junit.Assert; +import org.junit.Test; + +/** + * Test for {@link OutOfRangeException}. + * + * @version $Revision$ $Date$ + */ +public class OutOfRangeExceptionTest { + @Test + public void testAccessors() { + final OutOfRangeException e = new OutOfRangeException(-1, 0, 2); + Assert.assertEquals(-1, e.getArgument()); + Assert.assertEquals(0, e.getLo()); + Assert.assertEquals(2, e.getHi()); + } +} Propchange: commons/proper/math/trunk/src/test/java/org/apache/commons/math/exception/OutOfRangeExceptionTest.java ------------------------------------------------------------------------------ svn:eol-style = native