Fixes bug 28519:OrganizationStructureProvider.initialize should be synchronized
authorAugusto Mauch <augusto.mauch@openbravo.com>
Wed, 07 Jan 2015 10:18:24 +0100
changeset 24113 73e444dbdc8f
parent 24112 72a34ed08cd2
child 24114 3d0423546b2d
Fixes bug 28519:OrganizationStructureProvider.initialize should be synchronized

The method OrganizationStructureProvider.initialize should be synchronized, because otherwise it could be executed concurrently. The first thing the method does it to check if it the OrganizationStructureProvider has been already initialized, but this is not enough to prevent the concurrent initializations.

One of the consequences of the concurrent initializations is that the three maps used in that method (naturalTreesByOrgID, parentByOrganizationID and childByOrganizationID) can be left in an inconsistent state, resulting in the a 100% CPU usage when trying to access them.
src/org/openbravo/dal/security/OrganizationStructureProvider.java
--- a/src/org/openbravo/dal/security/OrganizationStructureProvider.java	Thu Sep 25 17:06:26 2014 +0530
+++ b/src/org/openbravo/dal/security/OrganizationStructureProvider.java	Wed Jan 07 10:18:24 2015 +0100
@@ -67,7 +67,7 @@
     initialize();
   }
 
-  private void initialize() {
+  private synchronized void initialize() {
     if (isInitialized) {
       return;
     }