[ https://issues.apache.org/jira/browse/OGNL-260?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16967265#comment-16967265 ]
Lukasz Lenart commented on OGNL-260: ------------------------------------ It's better to report such bugs here https://github.com/jkuhnert/ognl > ArrayList Iterator Cursor set to Object Aray in OGNL > ---------------------------------------------------- > > Key: OGNL-260 > URL: https://issues.apache.org/jira/browse/OGNL-260 > Project: Commons OGNL > Issue Type: Bug > Reporter: Julian Ryan > Priority: Major > > When running the following example in the latest (3.2.11): > {code:java} > import ognl.MemberAccess; > import ognl.Ognl; > import java.lang.reflect.Member; > import java.util.Map; > public class OgnlTest { > public static void main(String ... args) { > // Lazy allow everything for this test > Map ognlContext = Ognl.createDefaultContext(null, new MemberAccess() { > @Override > public Object setup(Map context, Object target, Member member, > String propertyName) { > return null; > } > @Override > public void restore(Map context, Object target, Member member, > String propertyName, Object state) { > } > @Override > public boolean isAccessible(Map context, Object target, Member > member, String propertyName) { > return true; > } > }); > try { > Object o = Ognl.getValue("#editsIter = > @java.util.Arrays@asList(\"one,two,three\".split(\",\")), > #editsIter.iterator()", ognlContext, new Object()); > ognlContext.put("iterator", o); > Object o2 = Ognl.getValue("#iterator.next()", ognlContext, new > Object()); > System.err.println(o2); > } catch (Exception e) { > e.printStackTrace(); > } > } > } > {code} > The iterator cursor is set to an Object array with a single value containing > the array values of the ArrayList instead of the values in the ArrayList. > This causes calling iterator.next() to just returns the whole set of > ArrayList values. > The expected behavior would be similar to the following snippet: > {code:java} > import java.util.Arrays; > import java.util.Iterator; > public class IteratorTesting { > public static void main(String ... args) { > Iterator iterator = > Arrays.asList("one,two,three".split(",")).iterator(); > while(iterator.hasNext()) { > Object o = iterator.next(); > System.err.println(o); > } > } > } > {code} > In short, for version 3.2.11 the iterator.next() returns an Object[] of > length 1 and in version 2.6.7 calling iterator.next() works the same as the > second snippet. -- This message was sent by Atlassian Jira (v8.3.4#803005)