commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Steve Pannier" <Steve_Pannier....@jacada.com>
Subject Re: [JXPath] Infinite loop in iterator.hasNext()
Date Wed, 19 Feb 2003 21:08:49 GMT

Dmitri,

I implemented your hack, and I do indeed get the "infinite loop" message.*

I been thinking about this, and the fact that the value objects inside our
map
are wrapped inside a custom class is what I think is causing the problem.
(Our data is organized into a Map-List-Map format, where the value nodes
(i.e. leaf nodes)  are wrapped in a custom object inside a List.)  When the
above "infinite loop" message appears in my logfile, the value of "this"
shows
data from within the wrapper class that I wasn't expecting to see.  I've
done a
little digging, and I suspect the problem I'm seeing is due to JXPath's use
of
reflection.  I've put some debug statements in
ValueUtils.getAccessibleValue()
and ValueUtils.getValue(), and it looks like methods in our custom wrapper
class are being invoked at the time I encounter the infinite loop problem.

Now, at this point it's still entirely possible there is a "loop" condition
within
our map somewhere.  But I wanted to run this by you before I investigate
that
possibility further.  What if the "loop" exists within the bowels of our
wrapper
classes.  Is there a way I can prevent JXPath from using reflection to
interrogate these objects?  Why does JXPath do this?

BTW: I've had no  luck trying to get my test case to recreate this problem.
I've duplicated the same map that causes the problem in our application,
at least from looking at output from map.toString(), but yet it works fine
in
my simple test case.  That's why at his point I'm pretty sure it has to do
with
the way our data is stored inside the map.

Any thoughts/suggestions?


* In the "infinite loop" message in my logfile, the value of "this" is
shown (below),
but there's also the following NPE (the "JIType" and "sampleDataModel"
values
are what I *wasn't* expecting to see here):

We might be in an infinite loop: /.[@name='more_stuff'][1][@name='cat'][1]
[@name='toy'][1][@name='
#CDATA'][1]/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/sampleDataModel/JIType/ID
Exception processing XPath expression: java.lang.NullPointerException
java.lang.NullPointerException
     at
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getPropertyDescriptors(BeanPropertyPointer.java:317)
     at
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getPropertyDescriptor(BeanPropertyPointer.java:302)
     at
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.getPropertyName(BeanPropertyPointer.java:282)
     at
org.apache.commons.jxpath.ri.model.beans.PropertyPointer.getName(PropertyPointer.java:110)
     at
org.apache.commons.jxpath.ri.model.NodePointer.asPath(NodePointer.java:647)
     at
org.apache.commons.jxpath.ri.model.NodePointer.toString(NodePointer.java:671)
     at java.lang.String.valueOf(String.java:1947)
     at java.lang.StringBuffer.append(StringBuffer.java:370)
     at
org.apache.commons.jxpath.ri.model.NodePointer.<init>(NodePointer.java:158)
     at
org.apache.commons.jxpath.ri.model.beans.PropertyPointer.<init>(PropertyPointer.java:90)
     at
org.apache.commons.jxpath.ri.model.beans.BeanPropertyPointer.<init>(BeanPropertyPointer.java:89)
     at
org.apache.commons.jxpath.ri.model.beans.BeanPointer.getPropertyPointer(BeanPointer.java:113)
     at
org.apache.commons.jxpath.ri.model.beans.PropertyIterator.<init>(PropertyIterator.java:94)
     at
org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer.createNodeIterator(PropertyOwnerPointer.java:121)
     at
org.apache.commons.jxpath.ri.model.beans.PropertyOwnerPointer.childIterator(PropertyOwnerPointer.java:105)
     at
org.apache.commons.jxpath.ri.axes.ChildContext.prepare(ChildContext.java:172)
     at
org.apache.commons.jxpath.ri.axes.ChildContext.setPosition(ChildContext.java:147)
     at
org.apache.commons.jxpath.ri.axes.ChildContext.nextNode(ChildContext.java:135)
     at
org.apache.commons.jxpath.ri.EvalContext.nextSet(EvalContext.java:356)
     at
org.apache.commons.jxpath.ri.axes.PredicateContext.nextSet(PredicateContext.java:201)
     at
org.apache.commons.jxpath.ri.EvalContext.performIteratorStep(EvalContext.java:192)
     at
org.apache.commons.jxpath.ri.EvalContext.hasNext(EvalContext.java:151)
     at
org.apache.commons.jxpath.ri.compiler.Expression$ValueIterator.hasNext(Expression.java:171)
     at com.jacada.ji.type.Util.doXPathAssignment(Util.java:862)


Thanks again for your help.


Steve Pannier
Jacada, Inc.
(763) 201-0002 Ext. 219
spannier@jacada.com
http://www.jacada.com



> Steve,
>
> I cannot think of any tool that would do that.  There is quick hack
though.
> Temporarily change the constructor of NodePointer and do something like
> this:
>
> protected NodePointer(NodePointer parent) {
>   this.parent = parent;
>
> // hack begins here
>   int length = 0;
>   NodePointer p = this;
>   while (p != null){
>      length  ++;
>      p = p.getParent();
>   }
>   // Now we have the length of the path.  If it is too long, we
>   // must be in an infinite loop.
>   if (depth > 100){
>       System.err.println("We might be in an infinite loop: " + this);
>   }
> }
>
> This constructor will print a path if it is "too long".
>
> I hope this helps.
>
> - Dmitri
>
> ----- Original Message -----
> From: "Steve Pannier" <Steve_Pannier.CST@jacada.com>
> To: "Jakarta Commons Users List" <commons-user@jakarta.apache.org>
> Sent: Tuesday, February 18, 2003 6:19 PM
> Subject: Re: [JXPath] Infinite loop in iterator.hasNext()
>
>
> >
> > Dmitri,
> >
> > One thing I forgot to ask in my last post:  I have a Map (or a graph
> > as you referred to it), and I want to verify that it contains no loops.
> > Is there an easy way to do this?  Any tool I can use?  Or do I need
> > to do this the old fashioned way?
> >
> > Thanks for your help.
> >
> >
> > Steve Pannier
> > Jacada, Inc.
> > (763) 201-0002 Ext. 219
> > spannier@jacada.com
> > http://www.jacada.com
> >
> >




Mime
View raw message