diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java b/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java index c6251988c9..86006d5e91 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java @@ -21,6 +21,8 @@ import java.io.IOException; import java.io.ObjectInput; import java.io.ObjectOutput; +import org.apache.activemq.util.IOHelper; + /** * Used by RootContainers * @@ -46,13 +48,6 @@ public class ContainerId implements Externalizable { return dataContainerName; } - /** - * @param dataContainerName The dataContainerPrefix to set. - */ - public void setDataContainerName(String dataContainerName) { - this.dataContainerName = dataContainerName; - } - /** * @return Returns the key. */ @@ -60,13 +55,6 @@ public class ContainerId implements Externalizable { return key; } - /** - * @param key The key to set. - */ - public void setKey(Object key) { - this.key = key; - } - public int hashCode() { return key.hashCode() ^ dataContainerName.hashCode(); } @@ -92,4 +80,8 @@ public class ContainerId implements Externalizable { public String toString() { return "CID{" + dataContainerName + ":" + key + "}"; } + + public String getFileSystemSafeContainerName() { + return IOHelper.toFileSystemSafeName(dataContainerName); + } } diff --git a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java index 54d60c7ad8..97f2398bda 100644 --- a/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java +++ b/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java @@ -198,9 +198,7 @@ public class KahaStore implements Store { public synchronized boolean doesMapContainerExist(Object id, String containerName) throws IOException { initialize(); - ContainerId containerId = new ContainerId(); - containerId.setKey(id); - containerId.setDataContainerName(containerName); + ContainerId containerId = new ContainerId(id, containerName); return maps.containsKey(containerId) || mapsContainer.doesRootExist(containerId); } @@ -212,17 +210,16 @@ public class KahaStore implements Store { return getMapContainer(id, containerName, persistentIndex); } - public synchronized MapContainer getMapContainer(Object id, String originalContainerName, boolean persistentIndex) + public synchronized MapContainer getMapContainer(Object id, String containerName, boolean persistentIndex) throws IOException { initialize(); - String containerName = IOHelper.toFileSystemSafeName(originalContainerName); - ContainerId containerId = new ContainerId(); - containerId.setKey(id); - containerId.setDataContainerName(containerName); + ContainerId containerId = new ContainerId(id, containerName); MapContainerImpl result = maps.get(containerId); if (result == null) { - DataManager dm = getDataManager(containerName); - IndexManager im = getIndexManager(dm, containerName); + String fileSystemSafeContainerName = containerId.getFileSystemSafeContainerName(); + DataManager dm = getDataManager(fileSystemSafeContainerName); + IndexManager im = getIndexManager(dm, fileSystemSafeContainerName); + IndexItem root = mapsContainer.getRoot(im, containerId); if (root == null) { root = mapsContainer.addRoot(im, containerId); @@ -268,9 +265,7 @@ public class KahaStore implements Store { public synchronized boolean doesListContainerExist(Object id, String containerName) throws IOException { initialize(); - ContainerId containerId = new ContainerId(); - containerId.setKey(id); - containerId.setDataContainerName(containerName); + ContainerId containerId = new ContainerId(id, containerName); return lists.containsKey(containerId) || listsContainer.doesRootExist(containerId); } @@ -282,17 +277,15 @@ public class KahaStore implements Store { return getListContainer(id, containerName, persistentIndex); } - public synchronized ListContainer getListContainer(Object id, String originalContainerName, + public synchronized ListContainer getListContainer(Object id, String containerName, boolean persistentIndex) throws IOException { initialize(); - String containerName = IOHelper.toFileSystemSafeName(originalContainerName); - ContainerId containerId = new ContainerId(); - containerId.setKey(id); - containerId.setDataContainerName(containerName); + ContainerId containerId = new ContainerId(id, containerName); ListContainerImpl result = lists.get(containerId); if (result == null) { - DataManager dm = getDataManager(containerName); - IndexManager im = getIndexManager(dm, containerName); + String fileSystemSafeContainerName = containerId.getFileSystemSafeContainerName(); + DataManager dm = getDataManager(fileSystemSafeContainerName); + IndexManager im = getIndexManager(dm, fileSystemSafeContainerName); IndexItem root = listsContainer.getRoot(im, containerId); if (root == null) {