You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by dj...@apache.org on 2009/01/01 21:15:30 UTC
svn commit: r730596 - in
/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha:
ContainerId.java impl/KahaStore.java
Author: djencks
Date: Thu Jan 1 12:15:30 2009
New Revision: 730596
URL: http://svn.apache.org/viewvc?rev=730596&view=rev
Log:
AMQ-2052 Be careful about when to use a file-system-safened id
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java?rev=730596&r1=730595&r2=730596&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/ContainerId.java Thu Jan 1 12:15:30 2009
@@ -21,6 +21,8 @@
import java.io.ObjectInput;
import java.io.ObjectOutput;
+import org.apache.activemq.util.IOHelper;
+
/**
* Used by RootContainers
*
@@ -47,26 +49,12 @@
}
/**
- * @param dataContainerName The dataContainerPrefix to set.
- */
- public void setDataContainerName(String dataContainerName) {
- this.dataContainerName = dataContainerName;
- }
-
- /**
* @return Returns the key.
*/
public Object getKey() {
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 String toString() {
return "CID{" + dataContainerName + ":" + key + "}";
}
+
+ public String getFileSystemSafeContainerName() {
+ return IOHelper.toFileSystemSafeName(dataContainerName);
+ }
}
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java?rev=730596&r1=730595&r2=730596&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/kaha/impl/KahaStore.java Thu Jan 1 12:15:30 2009
@@ -198,9 +198,7 @@
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 @@
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 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 @@
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) {