Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-11-22 07:07:28 -0500
committerEike Stepper2018-11-22 07:07:28 -0500
commite4227f94a4ccad14d8276f3fd3c6bc3aa5d7362c (patch)
tree3875aa62b52af64a49b42aaf9171bd9b3bad7ed3
parent7f34fd73180b8b4e0463172a1acdd97b2b17bb10 (diff)
downloadcdo-e4227f94a4ccad14d8276f3fd3c6bc3aa5d7362c.tar.gz
cdo-e4227f94a4ccad14d8276f3fd3c6bc3aa5d7362c.tar.xz
cdo-e4227f94a4ccad14d8276f3fd3c6bc3aa5d7362c.zip
[541437] Repository UUID management seems broken
https://bugs.eclipse.org/bugs/show_bug.cgi?id=541437
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java45
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_541437_Test.java50
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java7
3 files changed, 87 insertions, 15 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
index 70cb7ba82a..1b25c76446 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/Repository.java
@@ -154,6 +154,8 @@ public class Repository extends Container<Object> implements InternalRepository,
private static final int NONE = CDORevision.DEPTH_NONE;
+ private static final String PROP_UUID = "org.eclipse.emf.cdo.server.repositoryUUID"; //$NON-NLS-1$
+
private String name;
private String uuid;
@@ -248,19 +250,6 @@ public class Repository extends Container<Object> implements InternalRepository,
public String getUUID()
{
- if (uuid == null)
- {
- uuid = getProperties().get(Props.OVERRIDE_UUID);
- if (uuid == null)
- {
- uuid = UUID.randomUUID().toString();
- }
- else if (uuid.length() == 0)
- {
- uuid = getName();
- }
- }
-
return uuid;
}
@@ -2049,6 +2038,13 @@ public class Repository extends Container<Object> implements InternalRepository,
protected void initProperties()
{
+ // OVERRIDE_UUID
+ uuid = properties.get(Props.OVERRIDE_UUID);
+ if (uuid != null && uuid.length() == 0)
+ {
+ uuid = getName();
+ }
+
// SUPPORTING_AUDITS
String valueAudits = properties.get(Props.SUPPORTING_AUDITS);
if (valueAudits != null)
@@ -2428,6 +2424,28 @@ public class Repository extends Container<Object> implements InternalRepository,
revisionManager.setSupportingBranches(supportingBranches);
LifecycleUtil.activate(store);
+
+ Map<String, String> persistentProperties = store.getPersistentProperties(Collections.singleton(PROP_UUID));
+ String persistentUUID = persistentProperties.get(PROP_UUID);
+
+ if (uuid == null)
+ {
+ if (persistentUUID == null)
+ {
+ uuid = UUID.randomUUID().toString();
+ }
+ else
+ {
+ uuid = persistentUUID;
+ }
+ }
+
+ if (persistentUUID == null || !persistentUUID.equals(uuid))
+ {
+ persistentProperties.put(PROP_UUID, uuid);
+ store.setPersistentProperties(persistentProperties);
+ }
+
LifecycleUtil.activate(packageRegistry);
LifecycleUtil.activate(sessionManager);
LifecycleUtil.activate(revisionManager);
@@ -2460,7 +2478,6 @@ public class Repository extends Container<Object> implements InternalRepository,
{
initSystemPackages(false);
readPackageUnits();
-
readRootResource();
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_541437_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_541437_Test.java
new file mode 100644
index 0000000000..17c198202d
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_541437_Test.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 2018 Eike Stepper (Loehne, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.server.IRepository;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+
+import java.util.Map;
+
+/**
+ * Bug 541437 - Repository UUID management seems broken.
+ *
+ * @author Eike Stepper
+ */
+public class Bugzilla_541437_Test extends AbstractCDOTest
+{
+ @Override
+ public synchronized Map<String, Object> getTestProperties()
+ {
+ Map<String, Object> properties = super.getTestProperties();
+ properties.put(IRepository.Props.OVERRIDE_UUID, null);
+ return properties;
+ }
+
+ public void testUUIDWithoutOverride() throws Exception
+ {
+ String oldUUID = getRepository().getUUID();
+ assertNotSame(null, oldUUID);
+ assertNotSame(getRepository().getName(), oldUUID);
+ }
+
+ @Requires(IRepositoryConfig.CAPABILITY_RESTARTABLE)
+ public void testUUIDAfterRestart() throws Exception
+ {
+ String oldUUID = getRepository().getUUID();
+ restartRepository();
+
+ String newUUID = getRepository().getUUID();
+ assertEquals(oldUUID, newUUID);
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
index a9eba2e875..4d4c3460f8 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/RepositoryConfig.java
@@ -365,7 +365,12 @@ public abstract class RepositoryConfig extends Config implements IRepositoryConf
{
for (Entry<String, Object> entry : testProperties.entrySet())
{
- if (entry.getValue() instanceof String)
+ Object value = entry.getValue();
+ if (value == null)
+ {
+ repositoryProperties.remove(entry.getKey());
+ }
+ else if (value instanceof String)
{
repositoryProperties.put(entry.getKey(), (String)entry.getValue());
}

Back to the top