From acc72802a1e5374b9654c865c9843fd70e544d35 Mon Sep 17 00:00:00 2001 From: ogattaz Date: Thu, 28 Aug 2014 10:57:11 +0200 Subject: Put in place a protection in the constructor to set the size of the "clusterPriority" at the right size according the fact that the "clusterStorageProp" property could contains a List of instances of String and/or ClusterStorage --- .../persistency/ClusterStorageManager.java | 35 +++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) (limited to 'src/main/java/com/c2kernel/persistency/ClusterStorageManager.java') diff --git a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java index b1489e0..5227ab8 100644 --- a/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java +++ b/src/main/java/com/c2kernel/persistency/ClusterStorageManager.java @@ -23,9 +23,10 @@ import com.c2kernel.utils.WeakCache; /** * instantiates ClusterStorages listed in properties file All read/write requests to storage pass through this object, which * can query the capabilities of each declared storage, and channel requests accordingly. Transaction based. - * - * * @version $Revision: 1.62 $ $Date: 2006/02/01 13:27:46 $ - * @author $Author: abranson $ + * + * @author abranson + * @author ogattaz + * */ public class ClusterStorageManager { HashMap allStores = new HashMap(); @@ -35,10 +36,20 @@ public class ClusterStorageManager { // we don't need a soft cache for the top level cache - the proxies and entities clear that when reaped HashMap> memoryCache = new HashMap>(); - /** - * Initialises all ClusterStorage handlers listed by class name in the property "ClusterStorages" - * This property is usually process specific, and so should be in the server/client.conf and not the connect file. - */ + /** + * Initialises all ClusterStorage handlers listed by class name in the + * property "ClusterStorages" This property is usually process specific, and + * so should be in the server/client.conf and not the connect file. + * + * 2014/08/28 ogattaz : put in place a protection in the constructor : set + * the clusterPriority at the right size according the fact that the + * "clusterStorageProp" property could contains a List of instance of String + * and/or ClusterStorage + * + * @param auth + * an instance of Authenticator + * @throws ClusterStorageException + */ public ClusterStorageManager(Authenticator auth) throws ClusterStorageException { Object clusterStorageProp = Gateway.getProperties().getObject("ClusterStorage"); if (clusterStorageProp == null || clusterStorageProp.equals("")) { @@ -49,9 +60,13 @@ public class ClusterStorageManager { if (clusterStorageProp instanceof String) rootStores = instantiateStores((String)clusterStorageProp); else if (clusterStorageProp instanceof ArrayList) { - ArrayList propStores = (ArrayList)clusterStorageProp; + ArrayList wTempStorages = (ArrayList)clusterStorageProp; + + // set the clusterPriority at the right size + clusterPriority = new String[wTempStorages.size()]; + rootStores = new ArrayList(); - for (Object thisStore : propStores) { + for (Object thisStore : wTempStorages) { if (thisStore instanceof ClusterStorage) rootStores.add((ClusterStorage)thisStore); else @@ -74,7 +89,7 @@ public class ClusterStorageManager { Logger.msg(5, "ClusterStorageManager.init() - Cluster storage " + newStorage.getClass().getName() + " initialised successfully."); allStores.put(newStorage.getId(), newStorage); - clusterPriority[clusterNo++] = newStorage.getId(); + clusterPriority[clusterNo++] = newStorage.getId(); } clusterReaders.put(ClusterStorage.ROOT, rootStores); // all storages are queried for clusters at the root level -- cgit v1.2.3