Return-Path: Delivered-To: apmail-jakarta-commons-dev-archive@www.apache.org Received: (qmail 40256 invoked from network); 12 Apr 2004 05:22:15 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 12 Apr 2004 05:22:15 -0000 Received: (qmail 82429 invoked by uid 500); 12 Apr 2004 05:21:51 -0000 Delivered-To: apmail-jakarta-commons-dev-archive@jakarta.apache.org Received: (qmail 82374 invoked by uid 500); 12 Apr 2004 05:21:50 -0000 Mailing-List: contact commons-dev-help@jakarta.apache.org; run by ezmlm Precedence: bulk List-Unsubscribe: List-Subscribe: List-Help: List-Post: List-Id: "Jakarta Commons Developers List" Reply-To: "Jakarta Commons Developers List" Delivered-To: mailing list commons-dev@jakarta.apache.org Received: (qmail 82356 invoked by uid 500); 12 Apr 2004 05:21:50 -0000 Received: (qmail 82349 invoked from network); 12 Apr 2004 05:21:50 -0000 Received: from unknown (HELO minotaur.apache.org) (209.237.227.194) by daedalus.apache.org with SMTP; 12 Apr 2004 05:21:50 -0000 Received: (qmail 40234 invoked by uid 1718); 12 Apr 2004 05:22:11 -0000 Date: 12 Apr 2004 05:22:11 -0000 Message-ID: <20040412052211.40233.qmail@minotaur.apache.org> From: psteitz@apache.org To: jakarta-commons-cvs@apache.org Subject: cvs commit: jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate AbstractUnivariateStatistic.java X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N psteitz 2004/04/11 22:22:11 Modified: math/src/java/org/apache/commons/math/stat/univariate AbstractUnivariateStatistic.java Log: Reordered checks in test() method to avoid NPE. Revision Changes Path 1.15 +10 -6 jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java Index: AbstractUnivariateStatistic.java =================================================================== RCS file: /home/cvs/jakarta-commons/math/src/java/org/apache/commons/math/stat/univariate/AbstractUnivariateStatistic.java,v retrieving revision 1.14 retrieving revision 1.15 diff -u -r1.14 -r1.15 --- AbstractUnivariateStatistic.java 11 Apr 2004 19:39:10 -0000 1.14 +++ AbstractUnivariateStatistic.java 12 Apr 2004 05:22:11 -0000 1.15 @@ -48,7 +48,7 @@ * @param values Is a double[] containing the values * @param begin processing at this point in the array * @param length the number of elements to include - * @return true if the array has postive length + * @return true if the parameters are valid and designate a subarray of positive length * @throws IllegalArgumentException if the indices are invalid or the array is null */ protected boolean test( @@ -59,14 +59,18 @@ if (begin < 0) { throw new IllegalArgumentException("start position cannot be negative"); } + + if (length < 0) { + throw new IllegalArgumentException("length cannot be negative"); + } + + if (values == null) { + throw new IllegalArgumentException("input value array is null"); + } if (begin + length > values.length) { throw new IllegalArgumentException( "begin + length > values.length"); - } - - if (values == null) { - throw new IllegalArgumentException("input value array is null"); } if (length == 0) { --------------------------------------------------------------------- To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org For additional commands, e-mail: commons-dev-help@jakarta.apache.org