Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEsteban Dugueperoux2014-10-29 08:15:02 -0400
committerEsteban Dugueperoux2014-10-30 05:19:21 -0400
commiteafe5fc8385931e5bf203adfaa3b4f64a2c79156 (patch)
tree392e94b82a2ccfac4cd93b2630eb2fdcb1a90373
parentc86a56c32e8aa67e409c6a6f13e1b910e965aa12 (diff)
downloadcdo-eafe5fc8385931e5bf203adfaa3b4f64a2c79156.tar.gz
cdo-eafe5fc8385931e5bf203adfaa3b4f64a2c79156.tar.xz
cdo-eafe5fc8385931e5bf203adfaa3b4f64a2c79156.zip
[449171] Bad encoding of PointerCDORevision version in
CommitNotificationRequest Commit notification send bad CDORevision.version for detached objects. Consequently as PointerCDORevision.version is always at 0, the CommitNotificationIndication doesn't read the CDOBranch then the next read will failed with a EOFException. Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=449171 Change-Id: I387845037f20d9ccbd983c0b7313a0dc3b42c484 Signed-off-by: Esteban Dugueperoux <esteban.dugueperoux@obeo.fr>
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java6
-rw-r--r--plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_449171_Test.java60
4 files changed, 72 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java
index 90de0c6dcf..778a3871d2 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/common/protocol/CDOProtocolConstants.java
@@ -29,9 +29,11 @@ public interface CDOProtocolConstants
/**
* @since 4.2
*/
- public static final int PROTOCOL_VERSION = 20; // Have OMMOnitor optional in
- // RequestWithMonitoring/IndicationWithMonitoring
+ public static final int PROTOCOL_VERSION = 21; // Update how CDOChangeSetData's detachedObject is encoded, see
+ // https://bugs.eclipse.org/bugs/show_bug.cgi?id=449171
+ // public static final int PROTOCOL_VERSION = 20; // Have OMMOnitor optional in
+ // RequestWithMonitoring/IndicationWithMonitoring
// public static final int PROTOCOL_VERSION = 19; // Branch renaming
// public static final int PROTOCOL_VERSION = 18; // Password change protocol
// public static final int PROTOCOL_VERSION = 17; // Last update for make query fail in sequence
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
index ff2cb4d009..d595d233e4 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataInputImpl.java
@@ -228,12 +228,12 @@ public abstract class CDODataInputImpl extends ExtendedDataInput.Delegating impl
{
CDOID id = readCDOID();
int version = readInt();
-
+ boolean isCDORevisionKey = readBoolean();
CDOIDAndVersion data;
- if (version < 0)
+ if (isCDORevisionKey)
{
CDOBranch branch = readCDOBranch();
- data = CDORevisionUtil.createRevisionKey(id, branch, -version);
+ data = CDORevisionUtil.createRevisionKey(id, branch, version);
}
else
{
diff --git a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
index 09523a568a..3a3385d6e7 100644
--- a/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
+++ b/plugins/org.eclipse.emf.cdo.common/src/org/eclipse/emf/cdo/spi/common/protocol/CDODataOutputImpl.java
@@ -193,16 +193,15 @@ public class CDODataOutputImpl extends ExtendedDataOutput.Delegating implements
for (CDOIDAndVersion data : detachedObjects)
{
writeCDOID(data.getID());
- if (data instanceof CDORevisionKey)
+ boolean isCDORevisionKey = data instanceof CDORevisionKey;
+ int version = data.getVersion();
+ writeInt(version);
+ writeBoolean(isCDORevisionKey);
+ if (isCDORevisionKey)
{
CDORevisionKey revisionKey = (CDORevisionKey)data;
- writeInt(-data.getVersion());
writeCDOBranch(revisionKey.getBranch());
}
- else
- {
- writeInt(data.getVersion());
- }
}
}
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_449171_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_449171_Test.java
new file mode 100644
index 0000000000..c4cf3c136f
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_449171_Test.java
@@ -0,0 +1,60 @@
+/*
+ * Copyright (c) 2004-2014 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:
+ * Esteban Dugueperoux - initial API and implementation
+ */
+package org.eclipse.emf.cdo.tests.bugzilla;
+
+import org.eclipse.emf.cdo.common.branch.CDOBranch;
+import org.eclipse.emf.cdo.common.commit.CDOCommitInfo;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.internal.net4j.protocol.CommitNotificationIndication;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.spi.common.revision.PointerCDORevision;
+import org.eclipse.emf.cdo.tests.AbstractCDOTest;
+import org.eclipse.emf.cdo.tests.config.IRepositoryConfig;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.CleanRepositoriesBefore;
+import org.eclipse.emf.cdo.tests.config.impl.ConfigTest.Requires;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+
+/**
+ * Test that {@link CommitNotificationIndication} {@link CDOCommitInfo} decoding with {@link PointerCDORevision} on branch.
+ *
+ * @author Esteban Dugueperoux
+ */
+@Requires(IRepositoryConfig.CAPABILITY_BRANCHING)
+@CleanRepositoriesBefore(reason = "to not be disturb by branches created by others tests")
+public class Bugzilla_449171_Test extends AbstractCDOTest
+{
+
+ private static final String RESOURCE_NAME = "test1.model1";
+
+ public void testCommitNotificationIndicationCDOCommitInfoDecoding() throws Exception
+ {
+ CDOSession session1 = openSession();
+ String subBranchName = "b1";
+ CDOSession session2 = openSession();
+ CDOTransaction txOfSession1 = session1.openTransaction();
+ CDOResource resource = txOfSession1.getOrCreateResource(getResourcePath(RESOURCE_NAME));
+ resource.getContents().add(getModel1Factory().createCompany());
+ txOfSession1.commit();
+ txOfSession1.close();
+ session1.close();
+ session1 = openSession();
+ CDOBranch subBranch = session1.getBranchManager().getMainBranch().createBranch(subBranchName);
+ txOfSession1 = session1.openTransaction(subBranch);
+ resource = txOfSession1.getResource(getResourcePath(RESOURCE_NAME));
+ resource.getContents().remove(0);
+
+ CDOTransaction txOfSession2 = session2.openTransaction(subBranch);
+
+ commitAndSync(txOfSession1, txOfSession2);
+
+ }
+
+}

Back to the top