From 2f2e67b6aed823ecd9d54b26375ee19cd897df89 Mon Sep 17 00:00:00 2001
From: cramakri <cramakri>
Date: Wed, 10 Oct 2012 09:39:36 +0000
Subject: [PATCH] BIS-201 SP-277 : Improved error message when a circular
 dependency is discovered.

SVN: 27127
---
 .../ch/systemsx/cisd/common/collection/GroupingDAG.java     | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/common/source/java/ch/systemsx/cisd/common/collection/GroupingDAG.java b/common/source/java/ch/systemsx/cisd/common/collection/GroupingDAG.java
index 8b4714f2711..a68d45b5039 100644
--- a/common/source/java/ch/systemsx/cisd/common/collection/GroupingDAG.java
+++ b/common/source/java/ch/systemsx/cisd/common/collection/GroupingDAG.java
@@ -152,7 +152,6 @@ public class GroupingDAG<T>
         }
     }
 
-
     // because the implementation of the priority queue does not allow to change priorities of items
     // in the queue, instead we insert the same items several times.
     // if the dependency count of the item is -1 - it means, that we have already used it
@@ -169,7 +168,10 @@ public class GroupingDAG<T>
 
             if (peekCount() > 0)
             {
-                throw new UserFailureException("Circular dependency found!");
+                T cycleRoot = queue.peek().item;
+                Collection<T> cycle = graph.get(queue.peek().item);
+                throw new UserFailureException("" + cycleRoot
+                        + " depends on itself. Dependency chain : " + cycleRoot + " -> " + cycle);
             }
 
             while (false == queue.isEmpty() && peekCount() <= 0)
-- 
GitLab