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" <[EMAIL PROTECTED]>
To: "Jakarta Commons Users List" <[EMAIL PROTECTED]>
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
> [EMAIL PROTECTED]
> http://www.jacada.com
>
>
>
> > I will wait for you test case before start seriously looking into this.
> >
> > Here's something that might help.  If you have a graph with a loop (A
> points
> > to B and B points to A, directly or otherwise), and you launch a search
> like
> > this: "//foo", the whole thing has a good chance of falling into an
> infinite
> > loop, creating pointers of ever growing length.  I have a plan to
> introduce
> > some automated detection of this situation, but at this point it will
> simply
> > lead to an OutOfMemoryError.  Could this be it?
> >
> > - Dmitri
> >
> > ----- Original Message -----
> > From: "Steve Pannier" <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Monday, February 17, 2003 2:58 PM
> > Subject: [JXPath] Infinite loop in iterator.hasNext()
> >
> >
> > > I've run into a problem with iterating through the result set after
> > > calling context.iterate().  As I'm iterating, the hasNext() method
> > > in my while loop conditional seems to get into an infinite loop.
> > > (I get several java.lang.OutOfMemoryError's - no stack trace
> > > available.)  I did get a stack dump by sending the Unix QUIT
> > > signal to my running process, and the result of that is shown
> > > here:
> > >
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to