commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Darren Scott" <>
Subject RE: [betwixt] info on .betwixt files, "add" methods, and CyclicReferenceExceptions
Date Sat, 14 Dec 2002 00:23:49 GMT
> as i said, i had planned to take a look at creating a fix in 
> any case. if 
> you do make progress before then let me know so that i can 
> look at adding 
> some other features instead :)
> - robert

I think I've got a fix for unexpected CyclicReferenceExceptions. Robert
asked me to provide a cvs diff -u for the fix - I've never used -u on
diff before and it seemed to produce a LOT of output, so here's output
from a regular diff between my working copy and the top of the source
tree (1.6):

RCS file:
retrieving revision 1.6
diff -w -r1.6
> import java.util.Stack;
>     /** Stack containing ID attribute values for beans seen so far in
this graph */
>     protected Stack idStack = new Stack();
<             log.trace( "Writing bean graph (qualified name '" +
qualifiedName + "'" );
>             log.trace( "Writing bean graph (qualified name '" +
qualifiedName + "')" );
<                     if ( ref == null ) {
>                     if ( bean ) == -1 ) {
>                             idStack.push( bean );
>                             idStack.push( bean );
>                         // about to finish writing this bean - no need
to remember it any more
>                         idStack.pop();

Basically, as well as recording bean IDs in a Hashmap, we now also
maintain a stack of beans currently being written. Each time we see a
new bean we add the bean to the stack before recursing further down the
graph by calling write(). When we leave the write() method, we pop the
bean off the stack as we are no longer interested in it (at least for
the purposes of checking for cycles). The decision as to whether a cycle
exists is then based on whether the bean is already in the stack - if it
is, we have already seen it as part of this graph and hence there is a
cycle. This means that multiple occurences that are not part of a cycle
no longer produce a CyclicReferenceException.

Give it a go and let me know if you think it works.



View raw message