Program: 172260
Project: 172260
Buggy source:
/** 
 * Get the messages for a locale. <p> Will use cache where available otherwise will load into cache from bundles.
 * @param locale    the locale
 * @return          message map
 */
private Map<String,String> getLocaleProperties(Locale locale){
  Set<String> loadedBundles=null;
  Map<String,String> props=null;
  int loadedBundleCount=0;
  String tenantDomain=getTenantDomain();
  boolean init=false;
  Map<Locale,Set<String>> tenantLoadedResourceBundles=null;
  Map<Locale,Map<String,String>> tenantCachedMessages=null;
  Set<String> tenantResourceBundleBaseNames=null;
  try {
    readLock.lock();
    tenantLoadedResourceBundles=getLoadedResourceBundles(tenantDomain);
    loadedBundles=tenantLoadedResourceBundles.get(locale);
    tenantCachedMessages=getMessages(tenantDomain);
    props=tenantCachedMessages.get(locale);
    tenantResourceBundleBaseNames=getResourceBundleBaseNames(tenantDomain);
    loadedBundleCount=tenantResourceBundleBaseNames.size();
  }
  finally {
    readLock.unlock();
  }
  if (loadedBundles == null) {
    try {
      writeLock.lock();
      loadedBundles=new HashSet<String>();
      tenantLoadedResourceBundles.put(locale,loadedBundles);
      init=true;
    }
  finally {
      writeLock.unlock();
    }
  }
  if (props == null) {
    try {
      writeLock.lock();
      props=new HashMap<String,String>();
      tenantCachedMessages.put(locale,props);
      init=true;
    }
  finally {
      writeLock.unlock();
    }
  }
  if ((loadedBundles.size() != loadedBundleCount) || (init == true)) {
    try {
      writeLock.lock();
      Set<String> resBundleBaseNames=getResourceBundleBaseNames(tenantDomain);
      int count=0;
      for (      String resBundlePath : resBundleBaseNames) {
        if (loadedBundles.contains(resBundlePath) == false) {
          ResourceBundle resourcebundle=null;
          int idx1=resBundlePath.indexOf(StoreRef.URI_FILLER);
          if (idx1 != -1) {
            int idx2=resBundlePath.indexOf("String_Node_Str",idx1 + 3);
            String store=resBundlePath.substring(0,idx2);
            String path=resBundlePath.substring(idx2);
            StoreRef storeRef=tenantService.getName(new StoreRef(store));
            InputStream resBundleStream=getRepoResourceBundle(storeRef,path,locale);
            try {
              if (resBundleStream != null) {
                resourcebundle=new PropertyResourceBundle(resBundleStream);
              }
            }
 catch (            IOException ioe) {
              throw new RuntimeException("String_Node_Str" + resBundlePath + "String_Node_Str"+ ioe);
            }
          }
 else {
            resourcebundle=ResourceBundle.getBundle(resBundlePath,locale);
          }
          if (resourcebundle != null) {
            Enumeration<String> enumKeys=resourcebundle.getKeys();
            while (enumKeys.hasMoreElements() == true) {
              String key=enumKeys.nextElement();
              props.put(key,resourcebundle.getString(key));
            }
            loadedBundles.add(resBundlePath);
            count++;
          }
        }
      }
      logger.info("String_Node_Str" + count + "String_Node_Str"+ locale);
    }
  finally {
      writeLock.unlock();
    }
  }
  return props;
}

Fixed version (ground truth):
/** 
 * Get the messages for a locale. <p> Will use cache where available otherwise will load into cache from bundles.
 * @param locale    the locale
 * @return          message map
 */
private Map<String,String> getLocaleProperties(Locale locale){
  Set<String> loadedBundles=null;
  Map<String,String> props=null;
  int loadedBundleCount=0;
  String tenantDomain=getTenantDomain();
  boolean init=false;
  Map<Locale,Set<String>> tenantLoadedResourceBundles=null;
  Map<Locale,Map<String,String>> tenantCachedMessages=null;
  Set<String> tenantResourceBundleBaseNames=null;
  try {
    readLock.lock();
    tenantLoadedResourceBundles=getLoadedResourceBundles(tenantDomain);
    loadedBundles=tenantLoadedResourceBundles.get(locale);
    tenantCachedMessages=getMessages(tenantDomain);
    props=tenantCachedMessages.get(locale);
    tenantResourceBundleBaseNames=getResourceBundleBaseNames(tenantDomain);
    loadedBundleCount=tenantResourceBundleBaseNames.size();
  }
  finally {
    readLock.unlock();
  }
  if (loadedBundles == null) {
    try {
      writeLock.lock();
      loadedBundles=new HashSet<String>();
      tenantLoadedResourceBundles.put(locale,loadedBundles);
      init=true;
    }
  finally {
      writeLock.unlock();
    }
  }
  if (props == null) {
    try {
      writeLock.lock();
      props=new HashMap<String,String>();
      tenantCachedMessages.put(locale,props);
      init=true;
    }
  finally {
      writeLock.unlock();
    }
  }
  if ((loadedBundles.size() != loadedBundleCount) || (init == true)) {
    try {
      writeLock.lock();
      Set<String> resBundleBaseNames=getResourceBundleBaseNames(tenantDomain);
      int count=0;
      for (      String resBundlePath : resBundleBaseNames) {
        if (loadedBundles.contains(resBundlePath) == false) {
          ResourceBundle resourcebundle=null;
          int idx1=resBundlePath.indexOf(StoreRef.URI_FILLER);
          if (idx1 != -1) {
            int idx2=resBundlePath.indexOf("String_Node_Str",idx1 + 3);
            String store=resBundlePath.substring(0,idx2);
            String path=resBundlePath.substring(idx2);
            StoreRef storeRef=tenantService.getName(new StoreRef(store));
            try {
              resourcebundle=getRepoResourceBundle(storeRef,path,locale);
            }
 catch (            IOException ioe) {
              throw new AlfrescoRuntimeException("String_Node_Str" + resBundlePath + "String_Node_Str"+ ioe);
            }
          }
 else {
            resourcebundle=ResourceBundle.getBundle(resBundlePath,locale);
          }
          if (resourcebundle != null) {
            Enumeration<String> enumKeys=resourcebundle.getKeys();
            while (enumKeys.hasMoreElements() == true) {
              String key=enumKeys.nextElement();
              props.put(key,resourcebundle.getString(key));
            }
            loadedBundles.add(resBundlePath);
            count++;
          }
        }
      }
      logger.info("String_Node_Str" + count + "String_Node_Str"+ locale);
    }
  finally {
      writeLock.unlock();
    }
  }
  return props;
}