You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by fe...@apache.org on 2007/11/03 21:40:47 UTC

svn commit: r591681 - in /cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon: el/impl/AbstractExpression.java template/expression/JXTExpression.java

Author: felixk
Date: Sat Nov  3 13:40:47 2007
New Revision: 591681

URL: http://svn.apache.org/viewvc?rev=591681&view=rev
Log:
Iterator next() method can't throw NoSuchElement exception

This class implements the java.util.Iterator interface.  However, its next() method is not capable of throwing java.util.NoSuchElementException.  The next() method should be changed so it throws NoSuchElementException if is called when there are no more elements to return.

Modified:
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/AbstractExpression.java
    cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/AbstractExpression.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/AbstractExpression.java?rev=591681&r1=591680&r2=591681&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/AbstractExpression.java (original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/el/impl/AbstractExpression.java Sat Nov  3 13:40:47 2007
@@ -17,6 +17,7 @@
 package org.apache.cocoon.el.impl;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.apache.cocoon.el.Expression;
 
@@ -51,7 +52,7 @@
         }
 
         public Object next() {
-            return null;
+            throw new NoSuchElementException();
         }
 
         public void remove() {

Modified: cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java?rev=591681&r1=591680&r2=591681&view=diff
==============================================================================
--- cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java (original)
+++ cocoon/trunk/core/cocoon-expression-language/cocoon-expression-language-impl/src/main/java/org/apache/cocoon/template/expression/JXTExpression.java Sat Nov  3 13:40:47 2007
@@ -17,6 +17,7 @@
 package org.apache.cocoon.template.expression;
 
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 import org.apache.cocoon.el.Expression;
 import org.apache.cocoon.el.impl.jxpath.JXPathExpression;
@@ -33,11 +34,11 @@
 
     protected static final Iterator NULL_ITER = new Iterator() {
         public boolean hasNext() {
-            return true;
+            return false;
         }
 
         public Object next() {
-            return null;
+            throw new NoSuchElementException();
         }
 
         public void remove() {
@@ -91,8 +92,11 @@
 
                         public Object next() {
                             Object res = val;
-                            val = null;
-                            return res;
+                            if (res != null ) {
+                                val = null;
+                                return res;
+                            }
+                            throw new NoSuchElementException();
                         }
 
                         public void remove() {