You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2008/11/24 00:35:06 UTC

svn commit: r720069 - /tomcat/trunk/java/javax/el/CompositeELResolver.java

Author: markt
Date: Sun Nov 23 15:35:05 2008
New Revision: 720069

URL: http://svn.apache.org/viewvc?rev=720069&view=rev
Log:
Fix https://issues.apache.org/bugzilla/show_bug.cgi?id=42077
Don't include nulls in iterator. Based on a patch by Mathias Broekelmann

Modified:
    tomcat/trunk/java/javax/el/CompositeELResolver.java

Modified: tomcat/trunk/java/javax/el/CompositeELResolver.java
URL: http://svn.apache.org/viewvc/tomcat/trunk/java/javax/el/CompositeELResolver.java?rev=720069&r1=720068&r2=720069&view=diff
==============================================================================
--- tomcat/trunk/java/javax/el/CompositeELResolver.java (original)
+++ tomcat/trunk/java/javax/el/CompositeELResolver.java Sun Nov 23 15:35:05 2008
@@ -19,6 +19,7 @@
 
 import java.beans.FeatureDescriptor;
 import java.util.Iterator;
+import java.util.NoSuchElementException;
 
 public class CompositeELResolver extends ELResolver {
 
@@ -127,10 +128,12 @@
 
         private final int size;
 
-        private Iterator itr;
+        private Iterator<FeatureDescriptor> itr;
 
         private int idx;
 
+        private FeatureDescriptor next;
+
         public FeatureIterator(ELContext context, Object base,
                 ELResolver[] resolvers, int size) {
             this.context = context;
@@ -150,22 +153,30 @@
             }
         }
 
-        public boolean hasNext() {
-            return this.itr != null;
+        public boolean hasNext() {          
+            if (this.next != null)
+                return true;
+            if (this.itr != null){
+                while (this.next == null && itr.hasNext()) {
+                    this.next = itr.next();
+                }
+            } else {
+                return false;
+            }
+            if (this.next == null) {
+                this.itr = null;
+                this.guaranteeIterator();
+            }
+            return hasNext();
         }
 
         public FeatureDescriptor next() {
-            Object result = null;
-            if (this.itr != null) {
-                if (this.itr.hasNext()) {
-                    result = this.itr.next();
-                    if (!this.itr.hasNext()) {
-                        this.itr = null;
-                        this.guaranteeIterator();
-                    }
-                }
-            }
-            return (FeatureDescriptor) result;
+            if (!hasNext())
+                throw new NoSuchElementException();
+            FeatureDescriptor next = this.next;
+            this.next = null;
+            return next;
+
         }
 
         public void remove() {



---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org