Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-10-30 12:09:56 -0400
committerEike Stepper2008-10-30 12:09:56 -0400
commit3b3d6365b80dcc1ad6aad352ddad82be48dd5397 (patch)
tree58cc0d25eeabd9150a9b381c964c05f4bcac5f8d
parent5aedf281cca3845d98e4fec88d5e125918698b7d (diff)
downloadcdo-3b3d6365b80dcc1ad6aad352ddad82be48dd5397.tar.gz
cdo-3b3d6365b80dcc1ad6aad352ddad82be48dd5397.tar.xz
cdo-3b3d6365b80dcc1ad6aad352ddad82be48dd5397.zip
[252161] StackOverflow in CDOEditor.populateNewRoot() when sessino.packageRegistry contains a package not registered in the client machine
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252161
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java8
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java35
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java15
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java4
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java7
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java8
9 files changed, 77 insertions, 19 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
index 699050f5ca..ed56f53b9e 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/DBStoreAccessor.java
@@ -154,11 +154,9 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
public void readPackage(CDOPackage cdoPackage)
{
String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
- Object[] values = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME,
- CDODBSchema.PACKAGES_ECORE);
+ Object[] values = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_ID, CDODBSchema.PACKAGES_NAME);
PackageServerInfo.setDBID(cdoPackage, (Integer)values[0]);
((InternalCDOPackage)cdoPackage).setName((String)values[1]);
- ((InternalCDOPackage)cdoPackage).setEcore((String)values[2]);
readClasses(cdoPackage);
mapPackages(cdoPackage);
}
@@ -243,6 +241,13 @@ public class DBStoreAccessor extends StoreAccessor implements IDBStoreAccessor
CDODBSchema.FEATURES_REFERENCE_CLASSIFIER, CDODBSchema.FEATURES_MANY, CDODBSchema.FEATURES_CONTAINMENT);
}
+ public void readPackageEcore(CDOPackage cdoPackage)
+ {
+ String where = CDODBSchema.PACKAGES_URI.getName() + " = '" + cdoPackage.getPackageURI() + "'";
+ Object[] values = DBUtil.select(getConnection(), where, CDODBSchema.PACKAGES_ECORE);
+ ((InternalCDOPackage)cdoPackage).setEcore((String)values[0]);
+ }
+
public String readPackageURI(int packageID)
{
String where = CDODBSchema.PACKAGES_ID.getName() + "=" + packageID;
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
index cd6989e269..b29c8048d6 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/MEMStoreAccessor.java
@@ -82,6 +82,14 @@ public class MEMStoreAccessor extends StoreAccessor
/**
* @since 2.0
*/
+ public void readPackageEcore(CDOPackage cdoPackage)
+ {
+ throw new UnsupportedOperationException();
+ }
+
+ /**
+ * @since 2.0
+ */
public CloseableIterator<CDOID> readObjectIDs()
{
throw new UnsupportedOperationException();
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java
index 374f2cf2de..16f9435350 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOSessionPackageManager.java
@@ -15,6 +15,8 @@ import org.eclipse.emf.cdo.common.model.CDOFeature;
import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageManager;
+import org.eclipse.emf.internal.cdo.CDOSessionImpl;
+
import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -25,6 +27,11 @@ import org.eclipse.emf.ecore.EStructuralFeature;
*/
public interface CDOSessionPackageManager extends CDOPackageManager
{
+ /**
+ * @since 2.0
+ */
+ public CDOSessionImpl getSession();
+
public CDOPackage convert(EPackage ePackage);
public CDOClass convert(EClass eClass);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
index 044f692425..c7827440df 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOSessionPackageManagerImpl.java
@@ -21,7 +21,7 @@ import org.eclipse.emf.cdo.common.model.CDOPackage;
import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.common.util.TransportException;
import org.eclipse.emf.cdo.internal.common.model.CDOPackageManagerImpl;
-import org.eclipse.emf.cdo.util.EMFUtil;
+import org.eclipse.emf.cdo.spi.common.InternalCDOPackage;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.protocol.CDOClientProtocol;
@@ -137,8 +137,10 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
}
}
- @Override
- protected void resolve(CDOPackage cdoPackage)
+ /**
+ * @since 2.0
+ */
+ public void loadPackage(CDOPackage cdoPackage)
{
if (!cdoPackage.isDynamic())
{
@@ -154,7 +156,7 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
try
{
CDOClientProtocol protocol = session.getProtocol();
- LoadPackageRequest request = new LoadPackageRequest(protocol, cdoPackage);
+ LoadPackageRequest request = new LoadPackageRequest(protocol, cdoPackage, false);
IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
failOverStrategy.send(request);
@@ -174,10 +176,27 @@ public class CDOSessionPackageManagerImpl extends CDOPackageManagerImpl implemen
}
}
- @Override
- protected String provideEcore(CDOPackage cdoPackage)
+ /**
+ * @since 2.0
+ */
+ public void loadPackageEcore(CDOPackage cdoPackage)
{
- EPackage ePackage = ModelUtil.getEPackage(cdoPackage, session.getPackageRegistry());
- return EMFUtil.ePackageToString(ePackage, session.getPackageRegistry());
+ try
+ {
+ CDOClientProtocol protocol = session.getProtocol();
+ LoadPackageRequest request = new LoadPackageRequest(protocol, cdoPackage, true);
+
+ IFailOverStrategy failOverStrategy = session.getFailOverStrategy();
+ String ecore = failOverStrategy.send(request);
+ ((InternalCDOPackage)cdoPackage).setEcore(ecore);
+ }
+ catch (RuntimeException ex)
+ {
+ throw ex;
+ }
+ catch (Exception ex)
+ {
+ throw new TransportException(ex);
+ }
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
index 3e5107bf7a..eb8ca17ce8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/CommitTransactionRequest.java
@@ -124,6 +124,7 @@ public class CommitTransactionRequest extends CDOClientRequest<CommitTransaction
}
out.writeCDOPackage(newPackage);
+ out.writeString(((InternalCDOPackage)newPackage).basicGetEcore());
}
if (PROTOCOL_TRACER.isEnabled())
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java
index 5de5b0ae86..12a520ea38 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadPackageRequest.java
@@ -20,14 +20,17 @@ import java.io.IOException;
/**
* @author Eike Stepper
*/
-public class LoadPackageRequest extends CDOClientRequest<Object>
+public class LoadPackageRequest extends CDOClientRequest<String>
{
private CDOPackage cdoPackage;
- public LoadPackageRequest(CDOClientProtocol protocol, CDOPackage cdoPackage)
+ private boolean onlyEcore;
+
+ public LoadPackageRequest(CDOClientProtocol protocol, CDOPackage cdoPackage, boolean onlyEcore)
{
super(protocol);
this.cdoPackage = cdoPackage;
+ this.onlyEcore = onlyEcore;
}
@Override
@@ -40,11 +43,17 @@ public class LoadPackageRequest extends CDOClientRequest<Object>
protected void requesting(CDODataOutput out) throws IOException
{
out.writeCDOPackageURI(cdoPackage.getPackageURI());
+ out.writeBoolean(onlyEcore);
}
@Override
- protected Object confirming(CDODataInput in) throws IOException
+ protected String confirming(CDODataInput in) throws IOException
{
+ if (onlyEcore)
+ {
+ return in.readString();
+ }
+
in.readCDOPackage(cdoPackage);
return null;
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
index 029dd9573c..d2ee08ab74 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageRegistryImpl.java
@@ -166,7 +166,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
public EFactory getEFactory()
{
- // TODO Implement method LocalPackageDescriptor.getEFactory()
+ // TODO Implement method RemotePackageDescriptor.getEFactory()
throw new UnsupportedOperationException("Not yet implemented");
}
@@ -185,7 +185,7 @@ public class CDOPackageRegistryImpl extends EPackageRegistryImpl implements CDOP
@Override
public String toString()
{
- return MessageFormat.format("LocalPackageDescriptor[{0}]", cdoPackage.getPackageURI());
+ return MessageFormat.format("RemotePackageDescriptor[{0}]", cdoPackage.getPackageURI());
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
index 6dc36b65fc..42d85c9f24 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/CDOPackageTypeRegistryImpl.java
@@ -77,6 +77,12 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
put(packageURI, CDOPackageType.NATIVE);
}
+ public void reset()
+ {
+ deactivate();
+ activate();
+ }
+
@Override
protected void doActivate() throws Exception
{
@@ -110,6 +116,7 @@ public final class CDOPackageTypeRegistryImpl extends HashMapRegistry<String, CD
}
}
+ clear();
super.doDeactivate();
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
index 5c7d5bc4cc..32976ed8f8 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/ModelUtil.java
@@ -322,7 +322,7 @@ public final class ModelUtil
{
if (!cdoPackage.isDynamic())
{
- EPackage ePackage = createGeneratedEPackage(cdoPackage.getPackageURI());
+ EPackage ePackage = getGeneratedEPackage(cdoPackage);
if (ePackage != null)
{
return ePackage;
@@ -332,14 +332,16 @@ public final class ModelUtil
return createDynamicEPackage(cdoPackage);
}
- public static EPackage createGeneratedEPackage(String packageURI)
+ private static EPackage getGeneratedEPackage(CDOPackage cdoPackage)
{
+ String packageURI = cdoPackage.getPackageURI();
if (packageURI.equals(EcorePackage.eINSTANCE.getNsURI()))
{
return EcorePackage.eINSTANCE;
}
- return EPackage.Registry.INSTANCE.getEPackage(packageURI);
+ EPackage.Registry registry = EPackage.Registry.INSTANCE;
+ return registry.getEPackage(packageURI);
}
public static EPackageImpl createDynamicEPackage(CDOPackage cdoPackage)

Back to the top