commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r646498 - in /commons/sandbox/functor/trunk/src: main/java/org/apache/commons/functor/core/collection/FilteredIterator.java test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
Date Wed, 09 Apr 2008 19:35:25 GMT
Author: mbenson
Date: Wed Apr  9 12:35:23 2008
New Revision: 646498

URL: http://svn.apache.org/viewvc?rev=646498&view=rev
Log:
IllegalArgumentException more to-the-point than NPE

Modified:
    commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
    commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java

Modified: commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java?rev=646498&r1=646497&r2=646498&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
(original)
+++ commons/sandbox/functor/trunk/src/main/java/org/apache/commons/functor/core/collection/FilteredIterator.java
Wed Apr  9 12:35:23 2008
@@ -45,12 +45,14 @@
      * @param predicate to apply
      */
     public FilteredIterator(Iterator iterator, UnaryPredicate predicate) {
-        if (null == iterator || null == predicate) {
-            throw new NullPointerException();
-        } else {
-            this.predicate = predicate;
-            this.iterator = iterator;
+        if (null == iterator) {
+            throw new IllegalArgumentException("iterator argument was null");
         }
+        if (null == predicate) {
+            throw new IllegalArgumentException("filtering predicate argument was null");
+        }
+        this.predicate = predicate;
+        this.iterator = iterator;
     }
 
     // iterator methods

Modified: commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
URL: http://svn.apache.org/viewvc/commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java?rev=646498&r1=646497&r2=646498&view=diff
==============================================================================
--- commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
(original)
+++ commons/sandbox/functor/trunk/src/test/java/org/apache/commons/functor/core/collection/TestFilteredIterator.java
Wed Apr  9 12:35:23 2008
@@ -213,19 +213,19 @@
         try {
             new FilteredIterator(null,null);
             fail("ExpectedNullPointerException");
-        } catch(NullPointerException e) {
+        } catch(IllegalArgumentException e) {
             // expected
         }
         try {
             new FilteredIterator(null,Constant.truePredicate());
             fail("ExpectedNullPointerException");
-        } catch(NullPointerException e) {
+        } catch(IllegalArgumentException e) {
             // expected
         }
         try {
             new FilteredIterator(list.iterator(),null);
             fail("ExpectedNullPointerException");
-        } catch(NullPointerException e) {
+        } catch(IllegalArgumentException e) {
             // expected
         }
     }



Mime
View raw message