Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2012-10-31 04:29:24 -0400
committerEike Stepper2012-10-31 04:29:24 -0400
commit5ef5733dd9d80f4147b50eff53ba11fc634d535e (patch)
tree477c8ee2e006830aa68d722c3b6d90041365c0dc
parent6953df207533ff1b5165ce9f5269c7ee6be4efc8 (diff)
downloadcdo-5ef5733dd9d80f4147b50eff53ba11fc634d535e.tar.gz
cdo-5ef5733dd9d80f4147b50eff53ba11fc634d535e.tar.xz
cdo-5ef5733dd9d80f4147b50eff53ba11fc634d535e.zip
[393011] [Tests] SessionConfig removes statically registered packages
from global registry https://bugs.eclipse.org/bugs/show_bug.cgi?id=393011
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java35
1 files changed, 28 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
index f15a18196d..0931d8f201 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/config/impl/SessionConfig.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Eike Stepper - initial API and implementation
+ * Christian W. Damus (CEA) - don't remove statically registered packages from registry
*/
package org.eclipse.emf.cdo.tests.config.impl;
@@ -41,6 +42,7 @@ import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EPackage.Registry;
import org.eclipse.emf.ecore.impl.EPackageImpl;
import java.io.File;
@@ -59,12 +61,16 @@ public abstract class SessionConfig extends Config implements ISessionConfig
public static final String PROP_TEST_FETCH_RULE_MANAGER = "test.session.FetchRuleManager";
+ private static final Registry GLOBAL_REGISTRY = EPackage.Registry.INSTANCE;
+
private static final long serialVersionUID = 1L;
private transient Set<CDOSession> sessions;
private transient IListener sessionListener;
+ private transient Set<String> globallyRegisteredPackageURIs;
+
public SessionConfig(String name)
{
super(name);
@@ -131,6 +137,8 @@ public abstract class SessionConfig extends Config implements ISessionConfig
}
}
};
+
+ globallyRegisteredPackageURIs = captureGlobalPackageRegistry();
}
@Override
@@ -165,7 +173,8 @@ public abstract class SessionConfig extends Config implements ISessionConfig
}
finally
{
- removeDynamicPackagesFromGlobalRegistry();
+ removeDynamicPackagesFromGlobalRegistry(globallyRegisteredPackageURIs);
+ globallyRegisteredPackageURIs = null;
}
}
@@ -202,19 +211,31 @@ public abstract class SessionConfig extends Config implements ISessionConfig
CDOUtil.setLegacyModeDefault(true);
}
- private void removeDynamicPackagesFromGlobalRegistry()
+ private Set<String> captureGlobalPackageRegistry()
+ {
+ return new HashSet<String>(GLOBAL_REGISTRY.keySet());
+ }
+
+ private void removeDynamicPackagesFromGlobalRegistry(Set<String> urisToProtect)
{
- EPackage.Registry registry = EPackage.Registry.INSTANCE;
- for (String uri : registry.keySet().toArray(new String[registry.size()]))
+ for (String uri : GLOBAL_REGISTRY.keySet().toArray(new String[GLOBAL_REGISTRY.size()]))
{
- Object object = registry.get(uri);
- if (object != null && object.getClass() == EPackageImpl.class)
+ if (urisToProtect == null || !urisToProtect.contains(uri))
{
- registry.remove(uri);
+ Object object = GLOBAL_REGISTRY.get(uri); // Prevent resolving descriptors
+ if (isDynamicPackage(object))
+ {
+ GLOBAL_REGISTRY.remove(uri);
+ }
}
}
}
+ private boolean isDynamicPackage(Object object)
+ {
+ return object != null && object.getClass() == EPackageImpl.class;
+ }
+
/**
* @author Eike Stepper
* @deprecated Not yet supported.

Back to the top