diff options
author | Simon McDuff | 2008-10-28 14:00:35 +0000 |
---|---|---|
committer | Simon McDuff | 2008-10-28 14:00:35 +0000 |
commit | 2a61d4ffabe3f0d04b6c417335a092b9c2d59d2c (patch) | |
tree | 80256ad99821ba94d9377459ad73996bb2a47d99 /plugins | |
parent | e032e6a8f73447b4d9e89f1f0d4a90da19eefb9e (diff) | |
download | cdo-2a61d4ffabe3f0d04b6c417335a092b9c2d59d2c.tar.gz cdo-2a61d4ffabe3f0d04b6c417335a092b9c2d59d2c.tar.xz cdo-2a61d4ffabe3f0d04b6c417335a092b9c2d59d2c.zip |
[252214] NPE when calling audit.setTimeStamp()
https://bugs.eclipse.org/bugs/show_bug.cgi?id=252214
Diffstat (limited to 'plugins')
3 files changed, 97 insertions, 1 deletions
diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java index 1edefe0d50..6112ea3f41 100644 --- a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java @@ -26,6 +26,7 @@ import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251087_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251263_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251544_Test; import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_251752_Test; +import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_252214_Test; import org.eclipse.emf.cdo.tests.config.ConfigTest; import org.eclipse.emf.cdo.tests.config.ConfigTestSuite; @@ -97,6 +98,7 @@ public class AllTestsAllConfigs extends ConfigTestSuite testClasses.add(Bugzilla_251263_Test.class); testClasses.add(Bugzilla_251544_Test.class); testClasses.add(Bugzilla_251752_Test.class); + testClasses.add(Bugzilla_252214_Test.class); // TODO testClasses.add(NonCDOResourceTest.class); // TODO testClasses.add(GeneratedEcoreTest.class); diff --git a/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java new file mode 100644 index 0000000000..30a4a8a5d2 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_252214_Test.java @@ -0,0 +1,89 @@ +/*************************************************************************** + * Copyright (c) 2008 Eike Stepper, Germany. + * 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: + * Simon McDuff - initial API and implementation + **************************************************************************/ + +package org.eclipse.emf.cdo.tests.bugzilla; + +import org.eclipse.emf.cdo.CDOAudit; +import org.eclipse.emf.cdo.CDOObject; +import org.eclipse.emf.cdo.CDOSession; +import org.eclipse.emf.cdo.CDOTransaction; +import org.eclipse.emf.cdo.common.revision.CDORevision; +import org.eclipse.emf.cdo.eresource.CDOResource; +import org.eclipse.emf.cdo.server.IRepository; +import org.eclipse.emf.cdo.tests.AbstractCDOTest; +import org.eclipse.emf.cdo.tests.model1.Company; +import org.eclipse.emf.cdo.util.CDOUtil; + +import org.eclipse.emf.internal.cdo.CDOStateMachine; +import org.eclipse.emf.internal.cdo.InternalCDOObject; + +import java.util.Map; + +/** + * NPE when calling audit.setTimeStamp() + * <p> + * See https://bugs.eclipse.org/252214 + * + * @author Simon McDuff + */ +public class Bugzilla_252214_Test extends AbstractCDOTest +{ + @Override + public Map<String, Object> getTestProperties() + { + Map<String, Object> testProperties = super.getTestProperties(); + testProperties.put(IRepository.Props.SUPPORTING_AUDITS, "true"); + return testProperties; + } + + public void testBugzilla_252214() throws Exception + { + long commitTime1 = 0; + long commitTime2 = 0; + + { + CDOSession session = openModel1Session(); + CDOTransaction transaction = session.openTransaction(); + CDOResource resource = transaction.createResource("/res1"); + + Company company = getModel1Factory().createCompany(); + company.setName("ESC"); + resource.getContents().add(company); + transaction.commit(); + commitTime1 = transaction.getLastCommitTime(); + assertTrue(session.getRepositoryCreationTime() < commitTime1); + assertEquals("ESC", company.getName()); + + company.setName("Sympedia"); + transaction.commit(); + commitTime2 = transaction.getLastCommitTime(); + assertTrue(commitTime1 < commitTime2); + assertTrue(session.getRepositoryCreationTime() < commitTime2); + assertEquals("Sympedia", company.getName()); + } + CDOSession session = openModel1Session(); + + CDOAudit audit = session.openAudit(commitTime1); + { + CDOResource auditResource = audit.getResource("/res1"); + Company auditCompany = (Company)auditResource.getContents().get(0); + CDOObject cdoAuditCompany = CDOUtil.getCDOObject(auditCompany); + CDOStateMachine.INSTANCE.invalidate((InternalCDOObject)cdoAuditCompany, CDORevision.UNSPECIFIED_VERSION); + } + audit.setTimeStamp(commitTime2); + { + CDOResource auditResource = audit.getResource("/res1"); + Company auditCompany = (Company)auditResource.getContents().get(0); + assertEquals("Sympedia", auditCompany.getName()); + } + session.close(); + } +} diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java index 9ec886f528..b9aa30f2df 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java @@ -1177,7 +1177,12 @@ public class CDOViewImpl extends org.eclipse.net4j.util.event.Notifier implement for (InternalCDOObject object : objects.values()) { CDORevision revision = object.cdoRevision(); - if (!revision.isValid(timeStamp)) + if (revision == null) + { + revision = getRevision(object.cdoID(), false); + } + + if (revision == null || !revision.isValid(timeStamp)) { result.add(object); } |