Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-04-23 12:15:02 -0400
committerEike Stepper2018-04-23 12:15:02 -0400
commit71558cffe67d4e4d42dd883d5f037d3d28102427 (patch)
treec44cd43189d580a84c9c41eaf038e233f8e45d07
parent70a093e34a380de2a2c24d8fdfb68f6adef8034a (diff)
downloadcdo-71558cffe67d4e4d42dd883d5f037d3d28102427.tar.gz
cdo-71558cffe67d4e4d42dd883d5f037d3d28102427.tar.xz
cdo-71558cffe67d4e4d42dd883d5f037d3d28102427.zip
[533944] CDOServerExporter and Importer don't handle unsettable lists correctly
https://bugs.eclipse.org/bugs/show_bug.cgi?id=533944
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java13
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java32
2 files changed, 37 insertions, 8 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
index db592ee4c1..5ac6a618c3 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java
@@ -336,6 +336,11 @@ public abstract class CDOServerExporter<OUT>
public static final String FEATURE_VALUE = "value";
+ /**
+ * @since 4.7
+ */
+ public static final String FEATURE_ISSET = "isset";
+
public static final String FEATURE_ID = "id";
public static final String FEATURE_SIZE = "size";
@@ -524,13 +529,19 @@ public abstract class CDOServerExporter<OUT>
{
@SuppressWarnings("unchecked")
List<Object> list = (List<Object>)rev.getValue(feature);
- if (list != null)
+ if (list != null && !list.isEmpty())
{
for (Object value : list)
{
exportFeature(out, feature, value);
}
}
+ else if (feature.isUnsettable())
+ {
+ out.element(FEATURE);
+ out.attribute(FEATURE_NAME, feature.getName());
+ out.attribute(FEATURE_ISSET, list != null);
+ }
}
else
{
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
index 257ae86235..c971760930 100644
--- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
+++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java
@@ -451,8 +451,6 @@ public abstract class CDOServerImporter
else if (FEATURE.equals(qName))
{
String name = attributes.getValue(FEATURE_NAME);
- Object value = value(attributes);
-
EClass eClass = revision.getEClass();
EStructuralFeature feature = eClass.getEStructuralFeature(name);
if (feature == null)
@@ -460,16 +458,36 @@ public abstract class CDOServerImporter
throw new IllegalStateException("Feature " + name + " not found in class " + eClass.getName());
}
- if (feature.isMany())
+ String isSetString = attributes.getValue(FEATURE_ISSET);
+ if (isSetString != null)
{
- CDOList list = revision.getOrCreateList(feature);
- list.add(value);
+ // This must be an empty or an unset list.
+ boolean isSet = Boolean.parseBoolean(isSetString);
+ if (isSet)
+ {
+ // Create an empty list.
+ revision.getOrCreateList(feature);
+ }
+ else
+ {
+ // Leave the list unset.
+ }
}
else
{
- if (value != null)
+ Object value = value(attributes);
+
+ if (feature.isMany())
+ {
+ CDOList list = revision.getOrCreateList(feature);
+ list.add(value);
+ }
+ else
{
- revision.setValue(feature, value);
+ if (value != null)
+ {
+ revision.setValue(feature, value);
+ }
}
}
}

Back to the top