Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsboshev2010-01-25 16:36:38 +0000
committersboshev2010-01-25 16:36:38 +0000
commit44800132e4b57faed5fb4d94095cd4e29b610abd (patch)
tree7752e94085f6e2d56032b87bbdb0dfae60dbcfbb /bundles/org.eclipse.equinox.ds/src
parente98002fc241423d3ed3e0514580b739551e1a4df (diff)
downloadrt.equinox.bundles-44800132e4b57faed5fb4d94095cd4e29b610abd.tar.gz
rt.equinox.bundles-44800132e4b57faed5fb4d94095cd4e29b610abd.tar.xz
rt.equinox.bundles-44800132e4b57faed5fb4d94095cd4e29b610abd.zip
Bug 300690. [ds] FileStorage is not thread safe
Diffstat (limited to 'bundles/org.eclipse.equinox.ds/src')
-rw-r--r--bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/storage/file/FileStorage.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/storage/file/FileStorage.java b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/storage/file/FileStorage.java
index cbc526bde..31d0d645b 100644
--- a/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/storage/file/FileStorage.java
+++ b/bundles/org.eclipse.equinox.ds/src/org/eclipse/equinox/internal/ds/storage/file/FileStorage.java
@@ -38,8 +38,6 @@ public class FileStorage extends ComponentStorage {
//Probably it should be in the supplement bundle?
public static final String PROP_CHECK_CONFIG = "osgi.checkConfiguration"; //$NON-NLS-1$
- private String[] dbBundlePath = new String[1];
- private String[] dbCompPath = new String[] {null, "COMPONENTS"}; //$NON-NLS-1$
private static String CUSTOM_DB_NAME = "SCR"; //$NON-NLS-1$
private File file;
private ExternalizableDictionary data = new ExternalizableDictionary();
@@ -85,6 +83,7 @@ public class FileStorage extends ComponentStorage {
lastModified = getLastModifiedTimestamp(bundle);
}
+ String[] dbBundlePath = new String[1];
dbBundlePath[0] = String.valueOf(bundle.getBundleId());
String lastModifiedValue = (String) data.get(getPath(dbBundlePath));
@@ -117,6 +116,7 @@ public class FileStorage extends ComponentStorage {
private Vector loadComponentsFromDB(Bundle bundle) throws Exception {
try {
+ String[] dbCompPath = new String[] {null, "COMPONENTS"}; //$NON-NLS-1$
ServiceComponent currentComponent = null;
long bundleId = bundle.getBundleId();
dbCompPath[0] = String.valueOf(bundleId);
@@ -141,8 +141,10 @@ public class FileStorage extends ComponentStorage {
}
public void deleteComponentDefinitions(long bundleID) {
+ String[] dbBundlePath = new String[1];
dbBundlePath[0] = String.valueOf(bundleID);
data.remove(getPath(dbBundlePath));
+ String[] dbCompPath = new String[] {null, "COMPONENTS"}; //$NON-NLS-1$
dbCompPath[0] = String.valueOf(bundleID);
data.remove(getPath(dbCompPath));
if (file.exists()) {
@@ -157,6 +159,7 @@ public class FileStorage extends ComponentStorage {
if (components == null || components.size() == 0) {
return;
}
+ String[] dbCompPath = new String[] {null, "COMPONENTS"}; //$NON-NLS-1$
dbCompPath[0] = String.valueOf(bundleID);
DBObject tmpObj = new DBObject(components);
@@ -199,11 +202,13 @@ public class FileStorage extends ComponentStorage {
}
private String getPath(String path[]) {
- pathBuffer.setLength(0);
- for (int i = 0; i < path.length; i++) {
- pathBuffer.append(path[i]).append(separator);
+ synchronized (pathBuffer) {
+ pathBuffer.setLength(0);
+ for (int i = 0; i < path.length; i++) {
+ pathBuffer.append(path[i]).append(separator);
+ }
+ return pathBuffer.toString();
}
- return pathBuffer.toString();
}
/**

Back to the top