mirror of https://github.com/apache/activemq.git
AMQ-2052 Be careful about when to use a file-system-safened id
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@730596 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
e08cc350e0
commit
13d692ebde
|
@ -21,6 +21,8 @@ import java.io.IOException;
|
||||||
import java.io.ObjectInput;
|
import java.io.ObjectInput;
|
||||||
import java.io.ObjectOutput;
|
import java.io.ObjectOutput;
|
||||||
|
|
||||||
|
import org.apache.activemq.util.IOHelper;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by RootContainers
|
* Used by RootContainers
|
||||||
*
|
*
|
||||||
|
@ -46,13 +48,6 @@ public class ContainerId implements Externalizable {
|
||||||
return dataContainerName;
|
return dataContainerName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param dataContainerName The dataContainerPrefix to set.
|
|
||||||
*/
|
|
||||||
public void setDataContainerName(String dataContainerName) {
|
|
||||||
this.dataContainerName = dataContainerName;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Returns the key.
|
* @return Returns the key.
|
||||||
*/
|
*/
|
||||||
|
@ -60,13 +55,6 @@ public class ContainerId implements Externalizable {
|
||||||
return key;
|
return key;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param key The key to set.
|
|
||||||
*/
|
|
||||||
public void setKey(Object key) {
|
|
||||||
this.key = key;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
return key.hashCode() ^ dataContainerName.hashCode();
|
return key.hashCode() ^ dataContainerName.hashCode();
|
||||||
}
|
}
|
||||||
|
@ -92,4 +80,8 @@ public class ContainerId implements Externalizable {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "CID{" + dataContainerName + ":" + key + "}";
|
return "CID{" + dataContainerName + ":" + key + "}";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getFileSystemSafeContainerName() {
|
||||||
|
return IOHelper.toFileSystemSafeName(dataContainerName);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -198,9 +198,7 @@ public class KahaStore implements Store {
|
||||||
|
|
||||||
public synchronized boolean doesMapContainerExist(Object id, String containerName) throws IOException {
|
public synchronized boolean doesMapContainerExist(Object id, String containerName) throws IOException {
|
||||||
initialize();
|
initialize();
|
||||||
ContainerId containerId = new ContainerId();
|
ContainerId containerId = new ContainerId(id, containerName);
|
||||||
containerId.setKey(id);
|
|
||||||
containerId.setDataContainerName(containerName);
|
|
||||||
return maps.containsKey(containerId) || mapsContainer.doesRootExist(containerId);
|
return maps.containsKey(containerId) || mapsContainer.doesRootExist(containerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,17 +210,16 @@ public class KahaStore implements Store {
|
||||||
return getMapContainer(id, containerName, persistentIndex);
|
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 {
|
throws IOException {
|
||||||
initialize();
|
initialize();
|
||||||
String containerName = IOHelper.toFileSystemSafeName(originalContainerName);
|
ContainerId containerId = new ContainerId(id, containerName);
|
||||||
ContainerId containerId = new ContainerId();
|
|
||||||
containerId.setKey(id);
|
|
||||||
containerId.setDataContainerName(containerName);
|
|
||||||
MapContainerImpl result = maps.get(containerId);
|
MapContainerImpl result = maps.get(containerId);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
DataManager dm = getDataManager(containerName);
|
String fileSystemSafeContainerName = containerId.getFileSystemSafeContainerName();
|
||||||
IndexManager im = getIndexManager(dm, containerName);
|
DataManager dm = getDataManager(fileSystemSafeContainerName);
|
||||||
|
IndexManager im = getIndexManager(dm, fileSystemSafeContainerName);
|
||||||
|
|
||||||
IndexItem root = mapsContainer.getRoot(im, containerId);
|
IndexItem root = mapsContainer.getRoot(im, containerId);
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
root = mapsContainer.addRoot(im, containerId);
|
root = mapsContainer.addRoot(im, containerId);
|
||||||
|
@ -268,9 +265,7 @@ public class KahaStore implements Store {
|
||||||
|
|
||||||
public synchronized boolean doesListContainerExist(Object id, String containerName) throws IOException {
|
public synchronized boolean doesListContainerExist(Object id, String containerName) throws IOException {
|
||||||
initialize();
|
initialize();
|
||||||
ContainerId containerId = new ContainerId();
|
ContainerId containerId = new ContainerId(id, containerName);
|
||||||
containerId.setKey(id);
|
|
||||||
containerId.setDataContainerName(containerName);
|
|
||||||
return lists.containsKey(containerId) || listsContainer.doesRootExist(containerId);
|
return lists.containsKey(containerId) || listsContainer.doesRootExist(containerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,17 +277,15 @@ public class KahaStore implements Store {
|
||||||
return getListContainer(id, containerName, persistentIndex);
|
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 {
|
boolean persistentIndex) throws IOException {
|
||||||
initialize();
|
initialize();
|
||||||
String containerName = IOHelper.toFileSystemSafeName(originalContainerName);
|
ContainerId containerId = new ContainerId(id, containerName);
|
||||||
ContainerId containerId = new ContainerId();
|
|
||||||
containerId.setKey(id);
|
|
||||||
containerId.setDataContainerName(containerName);
|
|
||||||
ListContainerImpl result = lists.get(containerId);
|
ListContainerImpl result = lists.get(containerId);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
DataManager dm = getDataManager(containerName);
|
String fileSystemSafeContainerName = containerId.getFileSystemSafeContainerName();
|
||||||
IndexManager im = getIndexManager(dm, containerName);
|
DataManager dm = getDataManager(fileSystemSafeContainerName);
|
||||||
|
IndexManager im = getIndexManager(dm, fileSystemSafeContainerName);
|
||||||
|
|
||||||
IndexItem root = listsContainer.getRoot(im, containerId);
|
IndexItem root = listsContainer.getRoot(im, containerId);
|
||||||
if (root == null) {
|
if (root == null) {
|
||||||
|
|
Loading…
Reference in New Issue