You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ofbiz.apache.org by do...@apache.org on 2012/05/05 01:36:32 UTC

svn commit: r1334252 - /ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java

Author: doogie
Date: Fri May  4 23:36:31 2012
New Revision: 1334252

URL: http://svn.apache.org/viewvc?rev=1334252&view=rev
Log:
OPTIMIZE: Now that safe locking/threading is supported, there is no
longer a need to pre-populate the EntityKeyStore table with 20 random
keys; in reality, these 20 keys were enought to expand the keyMap
HashMap's internal structure, to a size that wouldn't normally be
auto-expanded during production.  And it was this lack of auto-expanding
that was keeping the map from becoming corrupted in very rare
circumstances.

Modified:
    ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java

Modified: ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java?rev=1334252&r1=1334251&r2=1334252&view=diff
==============================================================================
--- ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java (original)
+++ ofbiz/trunk/framework/entity/src/org/ofbiz/entity/util/EntityCrypto.java Fri May  4 23:36:31 2012
@@ -52,22 +52,6 @@ public final class EntityCrypto {
 
     public EntityCrypto(Delegator delegator) {
         this.delegator = delegator;
-
-        // check the key table and make sure there
-        // make sure there are some dummy keys
-        synchronized(EntityCrypto.class) {
-            try {
-                long size = delegator.findCountByCondition("EntityKeyStore", null, null, null);
-                if (size == 0) {
-                    for (int i = 0; i < 20; i++) {
-                        String randomName = this.getRandomString();
-                        this.createKey(randomName);
-                    }
-                }
-            } catch (GenericEntityException e) {
-                Debug.logError(e, module);
-            }
-        }
     }
 
     /** Encrypts an Object into an encrypted hex encoded String */
@@ -200,11 +184,4 @@ public final class EntityCrypto {
             throw new EntityCryptoException(e);
         }
     }
-
-    protected String getRandomString() {
-        Random rand = new Random();
-        byte[] randomBytes = new byte[24];
-        rand.nextBytes(randomBytes);
-        return StringUtil.toHexString(randomBytes);
-    }
 }