usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From snoopd...@apache.org
Subject [1/4] git commit: Fix to prevent infinite recursion in IndexRebuild.
Date Thu, 02 Oct 2014 16:18:27 GMT
Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o b644cc0aa -> 878d634ca


Fix to prevent infinite recursion in IndexRebuild.


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e939b05c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e939b05c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e939b05c

Branch: refs/heads/two-dot-o
Commit: e939b05c5e21b25a95905dec84d54a955d00f756
Parents: b2b8886
Author: Dave Johnson <dmjohnson@apigee.com>
Authored: Thu Oct 2 10:14:23 2014 -0400
Committer: Dave Johnson <dmjohnson@apigee.com>
Committed: Thu Oct 2 10:14:23 2014 -0400

----------------------------------------------------------------------
 .../corepersistence/CpEntityManager.java        | 26 ++++++++++++++------
 1 file changed, 19 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e939b05c/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
index 38453e1..f7df6c0 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManager.java
@@ -33,6 +33,7 @@ import java.util.LinkedHashSet;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.Stack;
 import java.util.TreeMap;
 import java.util.TreeSet;
 import java.util.UUID;
@@ -2857,7 +2858,11 @@ public class CpEntityManager implements EntityManager {
      * Completely reindex the application associated with this EntityManager.
      */
     public void reindex( EntityManagerFactory.ProgressObserver po ) throws Exception {
-        indexEntityConnectionsAndCollections( getApplication(), po );
+
+        Stack stack = new Stack();
+        stack.push( getApplication() );
+
+        indexEntityConnectionsAndCollections( getApplication(), po, stack );
     }
 
 
@@ -2865,8 +2870,8 @@ public class CpEntityManager implements EntityManager {
      * Recursively index (or reindex) all of the collections and connections of a 
      * specified entity, and all of the collected and connected entities as well.
      */
-    private void indexEntityConnectionsAndCollections( 
-            final EntityRef entity, final EntityManagerFactory.ProgressObserver po ) {
+    private void indexEntityConnectionsAndCollections( final EntityRef entity, 
+            final EntityManagerFactory.ProgressObserver po, final Stack stack ) {
 
         final GraphManager gm = managerCache.getGraphManager(applicationScope);
 
@@ -2961,8 +2966,12 @@ public class CpEntityManager implements EntityManager {
                             po.onProgress( entity, ref, edge.getType());
 
                             // recursion
-                            indexEntityConnectionsAndCollections( new SimpleEntityRef(
-                                memberEntity.getId().getType(), memberEntity.getId().getUuid()),po);
+                            if ( !stack.contains( ref )) {
+                                stack.push( ref );
+                                indexEntityConnectionsAndCollections( ref, po, stack );
+                                stack.pop(); 
+                            }
+
 
                         } else if ( isConnectionEdgeType( edge.getType() )) {
 
@@ -2998,8 +3007,11 @@ public class CpEntityManager implements EntityManager {
                             po.onProgress( entity, ref, edge.getType());
 
                             // recursion
-                            indexEntityConnectionsAndCollections( new SimpleEntityRef(
-                                targetEntity.getId().getType(), targetEntity.getId().getUuid()),po);
+                            if ( !stack.contains( ref )) {
+                                stack.push( ref );
+                                indexEntityConnectionsAndCollections( ref, po, stack );
+                                stack.pop(); 
+                            }
                         }
                     }
 


Mime
View raw message