Return-Path: X-Original-To: apmail-usergrid-commits-archive@minotaur.apache.org Delivered-To: apmail-usergrid-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 381C31790C for ; Thu, 2 Oct 2014 17:46:20 +0000 (UTC) Received: (qmail 88493 invoked by uid 500); 2 Oct 2014 17:46:19 -0000 Delivered-To: apmail-usergrid-commits-archive@usergrid.apache.org Received: (qmail 88472 invoked by uid 500); 2 Oct 2014 17:46:19 -0000 Mailing-List: contact commits-help@usergrid.incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@usergrid.incubator.apache.org Delivered-To: mailing list commits@usergrid.incubator.apache.org Received: (qmail 88462 invoked by uid 99); 2 Oct 2014 17:46:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 02 Oct 2014 17:46:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 5DAECA12FF6; Thu, 2 Oct 2014 17:46:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: sfeldman@apache.org To: commits@usergrid.apache.org Date: Thu, 02 Oct 2014 17:46:19 -0000 Message-Id: <3e91bad4c68346b3b2fe98d258639caa@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [1/6] git commit: Fix to prevent infinite recursion in IndexRebuild. Repository: incubator-usergrid Updated Branches: refs/heads/map 9a8bed510 -> 587cb5a73 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/map Commit: e939b05c5e21b25a95905dec84d54a955d00f756 Parents: b2b8886 Author: Dave Johnson Authored: Thu Oct 2 10:14:23 2014 -0400 Committer: Dave Johnson 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(); + } } }