Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2018-04-24 00:54:08 -0400
committerEike Stepper2018-04-24 00:54:08 -0400
commit8d9891fd33bda115e575d274a04cf32746f3debc (patch)
tree39d4180a3e451a1089b50dd4431cf0420d39b4b8
parent5fe0848ec3ae550523f1204e11903f804adab999 (diff)
downloadcdo-8d9891fd33bda115e575d274a04cf32746f3debc.tar.gz
cdo-8d9891fd33bda115e575d274a04cf32746f3debc.tar.xz
cdo-8d9891fd33bda115e575d274a04cf32746f3debc.zip
[409351] CDOServerExporter throws IllegalArgumentException on DynamicValueHolder.NIL
https://bugs.eclipse.org/bugs/show_bug.cgi?id=409351
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerExporter.java10
-rw-r--r--plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/server/CDOServerImporter.java17
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java56
3 files changed, 82 insertions, 1 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 491b8071a2..38f76bfd27 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
@@ -25,6 +25,7 @@ import org.eclipse.emf.cdo.common.model.CDOClassifierRef;
import org.eclipse.emf.cdo.common.model.CDOPackageUnit;
import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.spi.common.branch.InternalCDOBranchManager;
import org.eclipse.emf.cdo.spi.common.commit.InternalCDOCommitInfoManager;
@@ -341,6 +342,11 @@ public abstract class CDOServerExporter<OUT>
*/
public static final String FEATURE_ISSET = "isset";
+ /**
+ * @since 4.7
+ */
+ public static final String FEATURE_ISNULL = "isnull";
+
public static final String FEATURE_ID = "id";
public static final String FEATURE_SIZE = "size";
@@ -611,6 +617,10 @@ public abstract class CDOServerExporter<OUT>
out.attribute(featureType, TYPE_BYTE_ARRAY);
out.attribute(FEATURE_VALUE, HexUtil.bytesToHex(array));
}
+ else if (value == CDORevisionData.NIL)
+ {
+ out.attribute(FEATURE_ISNULL, true);
+ }
else
{
if (!(value instanceof String))
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 832510fda9..f4a3ea52eb 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
@@ -24,6 +24,7 @@ import org.eclipse.emf.cdo.common.model.EMFUtil;
import org.eclipse.emf.cdo.common.model.EMFUtil.ExtResourceSet;
import org.eclipse.emf.cdo.common.revision.CDOList;
import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.common.revision.CDORevisionFactory;
import org.eclipse.emf.cdo.common.revision.CDORevisionHandler;
import org.eclipse.emf.cdo.common.revision.CDORevisionUtil;
@@ -639,6 +640,22 @@ public abstract class CDOServerImporter
{
String type = attributes.getValue(FEATURE_TYPE);
+ if (type == null)
+ {
+ String isNullString = attributes.getValue(FEATURE_ISNULL);
+ if (isNullString != null)
+ {
+ // This must be an explicit single-valued null.
+ boolean isNull = Boolean.parseBoolean(isNullString);
+ if (isNull)
+ {
+ return CDORevisionData.NIL;
+ }
+
+ throw new IllegalArgumentException("Invalid attribute: isnull=false");
+ }
+ }
+
if (TYPE_BLOB.equals(type))
{
byte[] id = HexUtil.hexToBytes(attributes.getValue(FEATURE_ID));
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
index 25bdc07975..b3042e3a15 100644
--- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/BackupTest.java
@@ -12,6 +12,7 @@ package org.eclipse.emf.cdo.tests;
import org.eclipse.emf.cdo.common.lob.CDOBlob;
import org.eclipse.emf.cdo.common.lob.CDOClob;
+import org.eclipse.emf.cdo.common.revision.CDORevisionData;
import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.server.CDOServerExporter;
import org.eclipse.emf.cdo.server.CDOServerImporter;
@@ -21,6 +22,8 @@ import org.eclipse.emf.cdo.tests.bundle.OM;
import org.eclipse.emf.cdo.tests.model1.Customer;
import org.eclipse.emf.cdo.tests.model1.PurchaseOrder;
import org.eclipse.emf.cdo.tests.model1.SalesOrder;
+import org.eclipse.emf.cdo.tests.model2.Model2Package;
+import org.eclipse.emf.cdo.tests.model2.Unsettable1;
import org.eclipse.emf.cdo.tests.model3.File;
import org.eclipse.emf.cdo.tests.model3.Image;
import org.eclipse.emf.cdo.tests.model3.Point;
@@ -29,6 +32,7 @@ import org.eclipse.emf.cdo.tests.model5.Doctor;
import org.eclipse.emf.cdo.tests.model5.TestFeatureMap;
import org.eclipse.emf.cdo.tests.model6.UnsettableAttributes;
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;
@@ -182,6 +186,26 @@ public class BackupTest extends AbstractCDOTest
exporter.exportRepository(baos);
}
+ public void testExportNIL() throws Exception
+ {
+ Unsettable1 object = getModel2Factory().createUnsettable1();
+ object.setUnsettableString(null);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(object);
+ transaction.commit();
+
+ assertEquals(CDORevisionData.NIL, CDOUtil.getCDOObject(object).cdoRevision().data().get(Model2Package.eINSTANCE.getUnsettable1_UnsettableString(), 0));
+
+ InternalRepository repo1 = getRepository();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CDOServerExporter.XML exporter = new CDOServerExporter.XML(repo1);
+ exporter.exportRepository(baos);
+ }
+
public void testExportCustomDataType() throws Exception
{
CDOSession session = openSession();
@@ -248,7 +272,8 @@ public class BackupTest extends AbstractCDOTest
TreeIterator<EObject> iter = transaction2.getRootResource().getAllContents();
while (iter.hasNext())
{
- iter.next();
+ EObject eObject = iter.next();
+ System.out.println(eObject);
}
// Add content from a new package
@@ -425,6 +450,35 @@ public class BackupTest extends AbstractCDOTest
}
@CleanRepositoriesBefore(reason = "Inactive repository required")
+ public void testImportNIL() throws Exception
+ {
+ Unsettable1 object = getModel2Factory().createUnsettable1();
+ object.setUnsettableString(null);
+
+ CDOSession session = openSession();
+ CDOTransaction transaction = session.openTransaction();
+ CDOResource resource = transaction.createResource(getResourcePath("/res1"));
+ resource.getContents().add(object);
+ transaction.commit();
+
+ assertEquals(CDORevisionData.NIL, CDOUtil.getCDOObject(object).cdoRevision().data().get(Model2Package.eINSTANCE.getUnsettable1_UnsettableString(), 0));
+
+ InternalRepository repo1 = getRepository();
+
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ CDOServerExporter.XML exporter = new CDOServerExporter.XML(repo1);
+ exporter.exportRepository(baos);
+
+ InternalRepository repo2 = getRepository("repo2", false);
+
+ ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray());
+ CDOServerImporter.XML importer = new CDOServerImporter.XML(repo2);
+ importer.importRepository(bais);
+
+ useAfterImport("repo2");
+ }
+
+ @CleanRepositoriesBefore(reason = "Inactive repository required")
public void testImportCustomDataType() throws Exception
{
CDOSession session = openSession();

Back to the top