summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2008-04-12 05:55:38 (EDT)
committerEike Stepper2008-04-12 05:55:38 (EDT)
commit124ca4bb25d249d891ac9a5d434e1eef3d3a31b0 (patch)
tree615b8f7764409b7d3aff560265922d02b2165eab
parent23554de707062666397f50517d6e2e36acc5899e (diff)
downloadcdo-124ca4bb25d249d891ac9a5d434e1eef3d3a31b0.zip
cdo-124ca4bb25d249d891ac9a5d434e1eef3d3a31b0.tar.gz
cdo-124ca4bb25d249d891ac9a5d434e1eef3d3a31b0.tar.bz2
[226739] Default value not handle correctly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=226739
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java1
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java10
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java24
4 files changed, 33 insertions, 7 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
index cf8ee60..76551ab 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTests.java
@@ -24,6 +24,7 @@ public class AllTests
// $JUnit-BEGIN$
suite.addTestSuite(InitialTest.class);
+ suite.addTestSuite(AttributeTest.class);
suite.addTestSuite(EnumTest.class);
suite.addTestSuite(StateMachineTest.class);
suite.addTestSuite(ViewTest.class);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
index 3d31535..6bda90a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java
@@ -207,14 +207,10 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec
EClass eClass = eClass();
for (int i = 0; i < eClass.getFeatureCount(); i++)
{
- Object setting = eSettings[i];
- // if (setting != null)
+ EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
+ if (!eFeature.isTransient())
{
- EStructuralFeature eFeature = cdoInternalDynamicFeature(i);
- if (!eFeature.isTransient())
- {
- populateRevisionFeature(view, revision, eFeature, eSettings, i);
- }
+ populateRevisionFeature(view, revision, eFeature, eSettings, i);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
index d0701b9..c55076c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java
@@ -27,6 +27,7 @@ import org.eclipse.emf.cdo.protocol.revision.delta.CDOFeatureDelta;
import org.eclipse.emf.internal.cdo.bundle.OM;
import org.eclipse.emf.internal.cdo.util.FSMUtil;
+import org.eclipse.emf.internal.cdo.util.GenUtil;
import org.eclipse.emf.internal.cdo.util.ModelUtil;
import org.eclipse.net4j.internal.util.om.trace.ContextTracer;
@@ -360,6 +361,10 @@ public final class CDOStore implements EStore
{
value = EcoreUtil.convertToString((EDataType)eFeature.getEType(), value);
}
+ else if (value == null && GenUtil.isPrimitiveType(eFeature.getEType()))
+ {
+ value = eFeature.getDefaultValue();
+ }
CDOFeatureDelta delta = new CDOSetFeatureDeltaImpl(cdoFeature, index, value);
InternalCDORevision revision = getRevisionForWriting(cdoObject, delta);
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java
index dcded5d..523312c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/util/GenUtil.java
@@ -12,6 +12,8 @@ package org.eclipse.emf.internal.cdo.util;
import org.eclipse.net4j.util.StringUtil;
+import org.eclipse.emf.ecore.EClassifier;
+
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@@ -26,6 +28,28 @@ public final class GenUtil
}
/**
+ * @see GenGenBaseImpl#isPrimitiveType
+ */
+ public static boolean isPrimitiveType(EClassifier eType)
+ {
+ try
+ {
+ // J9 2.2 has problems assigning null to a Class variable.
+ Object result = eType.getInstanceClass();
+ if (result == null)
+ {
+ return false;
+ }
+ Class<?> instanceClass = (Class<?>)result;
+ return instanceClass.isPrimitive();
+ }
+ catch (Exception e)
+ {
+ return false;
+ }
+ }
+
+ /**
* @see GenFeatureImpl#getUpperName
*/
public static String getFeatureUpperName(String featureName)