summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Winkler2010-10-01 11:16:16 (EDT)
committerStefan Winkler2010-10-01 11:16:16 (EDT)
commita91d414d00d86b12cea002dc06cbb75ea8f0327a (patch)
tree059ff515f24d55b4eeafab0be71f60e08c087d72
parentae56b73aa3ac1d3ab0d74cf60f0cd16dde6214a2 (diff)
downloadcdo-a91d414d00d86b12cea002dc06cbb75ea8f0327a.zip
cdo-a91d414d00d86b12cea002dc06cbb75ea8f0327a.tar.gz
cdo-a91d414d00d86b12cea002dc06cbb75ea8f0327a.tar.bz2
[326743] StackOverflowException in TypeMapping
https://bugs.eclipse.org/bugs/show_bug.cgi?id=326743
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java8
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java2
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java91
4 files changed, 100 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
index ff1ebb1..cadc8ba 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/db/mapping/AbstractTypeMapping.java
@@ -94,7 +94,7 @@ public abstract class AbstractTypeMapping implements ITypeMapping
setValue(stmt, index, getRevisionValue(revision));
}
- public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException
+ public final void setDefaultValue(PreparedStatement stmt, int index) throws SQLException
{
setValue(stmt, index, getDefaultValue());
}
diff --git a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
index 78887af..42ed4b8 100644
--- a/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
+++ b/plugins/org.eclipse.emf.cdo.server.db/src/org/eclipse/emf/cdo/server/internal/db/mapping/CoreTypeMappings.java
@@ -33,8 +33,10 @@ import org.eclipse.net4j.db.DBType;
import org.eclipse.net4j.util.factory.ProductCreationException;
import org.eclipse.emf.common.util.Enumerator;
+import org.eclipse.emf.ecore.EDataType;
import org.eclipse.emf.ecore.EEnum;
import org.eclipse.emf.ecore.EEnumLiteral;
+import org.eclipse.emf.ecore.EFactory;
import org.eclipse.emf.ecore.EcorePackage;
import java.math.BigDecimal;
@@ -763,9 +765,11 @@ public class CoreTypeMappings
}
@Override
- public void setDefaultValue(PreparedStatement stmt, int index) throws SQLException
+ protected Object getDefaultValue()
{
- setValue(stmt, index, getFeature().getDefaultValueLiteral());
+ Object defaultValue = getFeature().getDefaultValue();
+ EFactory factory = getFeature().getEType().getEPackage().getEFactoryInstance();
+ return factory.convertToString((EDataType)getFeature().getEType(), defaultValue);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
index f4284a3..7021421 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllConfigs.java
@@ -100,6 +100,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_324756_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325603_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_325866_Test;
import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_326518_Test;
+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_326743_Test;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTest;
import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite;
@@ -266,6 +267,7 @@ public abstract class AllConfigs extends ConfigTestSuite
testClasses.add(Bugzilla_325603_Test.class);
testClasses.add(Bugzilla_325866_Test.class);
testClasses.add(Bugzilla_326518_Test.class);
+ testClasses.add(Bugzilla_326743_Test.class);
// TODO testClasses.add(NonCDOResourceTest.class);
// TODO testClasses.add(GeneratedEcoreTest.class);
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java
new file mode 100644
index 0000000..e845931
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_326743_Test.java
@@ -0,0 +1,91 @@
+/**
+ * Copyright (c) 2004 - 2010 Eike Stepper (Berlin, 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:
+ * Stefan Winkler - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.model.EMFUtil;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.util.CommitException;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EDataType;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EPackage;
+import org.eclipse.emf.ecore.EcoreFactory;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+/**
+ * @author Stefan Winkler
+ */
+public class Bugzilla_326743_Test extends AbstractCDOTest
+{
+ private EPackage pkg;
+
+ private EClass cls;
+
+ private EAttribute att;
+
+ @Override
+ public void setUp() throws Exception
+ {
+ super.setUp();
+
+ pkg = EMFUtil.createEPackage("customTest", "ct", "http://cdo.emf.eclipse.org/customTest.ecore");
+
+ EDataType customPrimitive = EcoreFactory.eINSTANCE.createEDataType();
+ customPrimitive.setInstanceTypeName("boolean");
+ customPrimitive.setName("CustomPrimitiveType");
+
+ pkg.getEClassifiers().add(customPrimitive);
+
+ cls = EMFUtil.createEClass(pkg, "Foobar", false, false);
+ att = EMFUtil.createEAttribute(cls, "attPrimitive", customPrimitive);
+
+ CDOUtil.prepareDynamicEPackage(pkg);
+ }
+
+ public void testDefaultValue() throws CommitException
+ {
+ EObject obj = EcoreUtil.create(cls);
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOTransaction tx = session.openTransaction();
+ CDOResource res = tx.createResource("/test");
+ res.getContents().add(obj);
+ tx.commit();
+ tx.close();
+ session.close();
+ }
+
+ clearCache(getRepository().getRevisionManager());
+
+ {
+ CDOSession session = openSession();
+ session.getPackageRegistry().putEPackage(pkg);
+ CDOView v = session.openView();
+ CDOResource res = v.getResource("/test");
+ EObject persistent = res.getContents().get(0);
+
+ boolean pCustom = (Boolean)persistent.eGet(att);
+ assertEquals(false, pCustom);
+
+ v.close();
+ session.close();
+ }
+ }
+}