ModeShape/modeshape — pull request #404 by hchiorean (2012-06-08 08:16:02+00:00)
Title: MODE-1489 - Fixed infinite loop when calling orderBefore multiple times without save

The problem was caused by the fact that there was a "circular" reference when the first orderBefore had been called on the same child, both as source and destination (i.e. orderBefore(child0, child0)). The fix was done on several levels:

- orderBefore on the same source and target should be a no-op (as per spec)
- insertBefore on the child references of a session node should be a no-op if the references are identical
- the child references iterator, when another delegate iterator is provided, should not loop indefinitely if there are circular references