diff options
author | Caspar De Groot | 2011-03-23 02:50:27 +0000 |
---|---|---|
committer | Caspar De Groot | 2011-03-23 02:50:27 +0000 |
commit | fc1a4ccc5e533db089f4e8cb752f196e9c5d7b21 (patch) | |
tree | e859d58db221782ecdd2f493bb34b63d8b512765 | |
parent | 57a633079bb99025ded65b073164fbcf43ed4752 (diff) | |
download | cdo-fc1a4ccc5e533db089f4e8cb752f196e9c5d7b21.tar.gz cdo-fc1a4ccc5e533db089f4e8cb752f196e9c5d7b21.tar.xz cdo-fc1a4ccc5e533db089f4e8cb752f196e9c5d7b21.zip |
[Bug 339313] Revision may contain CDOList with uninitialized values
https://bugs.eclipse.org/bugs/show_bug.cgi?id=339313
3 files changed, 70 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java index 9025188a36..8dc675604b 100644 --- a/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java +++ b/plugins/org.eclipse.emf.cdo.server.net4j/src/org/eclipse/emf/cdo/server/internal/net4j/protocol/LoadRevisionsIndication.java @@ -300,8 +300,14 @@ public class LoadRevisionsIndication extends CDOReadIndication Collection<?> c = (Collection<?>)value; for (Object e : c) { - CDOID id = (CDOID)e; - prefetchRevisionChild(depth, id, additionalRevisions, map); + // If this revision was loaded with referenceChunk != UNCHUNKED, then + // some elements might be uninitialized, i.e. not instanceof CDOID. + // (See bug 339313.) + if (e instanceof CDOID) + { + CDOID id = (CDOID)e; + prefetchRevisionChild(depth, id, additionalRevisions, map); + } } } } 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 7bb53e652f..259539e86d 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 @@ -213,5 +213,6 @@ public abstract class AllConfigs extends ConfigTestSuite testClasses.add(Bugzilla_338884_Test.class); testClasses.add(Bugzilla_338779_Test.class); testClasses.add(Bugzilla_339461_Test.class); + testClasses.add(Bugzilla_339313_Test.class); } } diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java new file mode 100644 index 0000000000..106768d937 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_339313_Test.java @@ -0,0 +1,61 @@ +/** + * Copyright (c) 2004 - 2011 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: + * Caspar De Groot - 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.id.CDOID; +import org.eclipse.emf.cdo.common.revision.CDORevision; +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.tests.model1.Category; +import org.eclipse.emf.cdo.tests.model1.Model1Factory; +import org.eclipse.emf.cdo.transaction.CDOTransaction; +import org.eclipse.emf.cdo.util.CDOUtil; +import org.eclipse.emf.cdo.util.CommitException; + +/** + * @author Caspar De Groot + */ +public class Bugzilla_339313_Test extends AbstractCDOTest +{ + public void test() throws CommitException + { + CDOID topObjectID = null; + + { + CDOSession session = openSession(); + CDOTransaction tx = session.openTransaction(); + CDOResource resource = tx.createResource(getResourcePath("test")); + + Model1Factory factory = getModel1Factory(); + Category c = factory.createCategory(); + c.getCategories().add(factory.createCategory()); + c.getCategories().add(factory.createCategory()); + resource.getContents().add(c); + + tx.commit(); + + topObjectID = CDOUtil.getCDOObject(c).cdoID(); + session.close(); + } + + clearCache(getRepository().getRevisionManager()); + + { + CDOSession session = openSession(); + CDOBranch main = session.getBranchManager().getMainBranch(); + CDORevision rev = session.getRevisionManager().getRevision(topObjectID, main.getHead(), 1, 1, true); + msg(rev); + session.close(); + } + } +} |