usergrid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sfeld...@apache.org
Subject [18/30] incubator-usergrid git commit: Fixes lookup cache bug
Date Mon, 09 Mar 2015 15:14:35 GMT
Fixes lookup cache bug


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

Branch: refs/heads/two-dot-o
Commit: ecc1ddeed2f2e54a66c2b5a56eed689593380820
Parents: 4c8727c
Author: Todd Nine <tnine@apigee.com>
Authored: Fri Mar 6 16:10:33 2015 -0700
Committer: Todd Nine <tnine@apigee.com>
Committed: Fri Mar 6 16:10:33 2015 -0700

----------------------------------------------------------------------
 .../corepersistence/CpEntityManagerFactory.java | 31 ++++++++++----------
 1 file changed, 16 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/ecc1ddee/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
----------------------------------------------------------------------
diff --git a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
index 16de53e..e0029c1 100644
--- a/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
+++ b/stack/core/src/main/java/org/apache/usergrid/corepersistence/CpEntityManagerFactory.java
@@ -241,10 +241,10 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
         getSetup().setupApplicationKeyspace( applicationId, appName );
 
 
-        final Optional<UUID> cachedValue = orgApplicationCache.getOrganizationId( name
);
+        final Optional<UUID> cachedValue = orgApplicationCache.getOrganizationId( organizationName
);
 
 
-        final UUID orgUuid;
+        UUID orgUuid;
 
         if ( !cachedValue.isPresent() ) {
 
@@ -252,22 +252,22 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
             // create new org because the specified one does not exist
             final String orgName = organizationName;
 
-            final Entity orgInfo;
+
 
             try {
-                orgInfo = em.create( "organization", new HashMap<String, Object>()
{{
+                final Entity orgInfo = em.create( "organization", new HashMap<String,
Object>() {{
                     put( PROPERTY_NAME, orgName );
                 }} );
+                orgUuid = orgInfo.getUuid();
+                //evit so it's re-loaded later
+                orgApplicationCache.evictOrgId( name );
             }
             catch ( DuplicateUniquePropertyExistsException e ) {
-                throw new OrganizationAlreadyExistsException( orgName );
+                //swallow, if it exists, just get it
+                orgApplicationCache.evictOrgId( organizationName );
+                orgUuid = orgApplicationCache.getOrganizationId( organizationName ).get();
             }
 
-            em.refreshIndex();
-            orgUuid = orgInfo.getUuid();
-
-            //evit so it's re-loaded later
-            orgApplicationCache.evictOrgId( name );
         } else{
             orgUuid = cachedValue.get();
         }
@@ -281,11 +281,12 @@ public class CpEntityManagerFactory implements EntityManagerFactory,
Application
             put( "organizationUuid", orgId );
         }};
 
-        try{
-             em.create( "appinfo", appInfoMap );
-        }catch(DuplicateUniquePropertyExistsException e){
-                       throw new ApplicationAlreadyExistsException( appName );
-                   }
+        try {
+            em.create( "appinfo", appInfoMap );
+        }
+        catch ( DuplicateUniquePropertyExistsException e ) {
+            throw new ApplicationAlreadyExistsException( appName );
+        }
         em.refreshIndex();
 
         // create application entity


Mime
View raw message