Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 128848 Details for
Bug 266982
IllegalStateException in CDOStore.getRevision
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch v2
patch.txt (text/plain), 16.08 KB, created by
Eike Stepper
on 2009-03-15 14:20:21 EDT
(
hide
)
Description:
Patch v2
Filename:
MIME Type:
Creator:
Eike Stepper
Created:
2009-03-15 14:20:21 EDT
Size:
16.08 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.emf.cdo.tests >Index: src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/tests/org.eclipse.emf.cdo.tests/src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java,v >retrieving revision 1.39 >diff -u -r1.39 AllTestsAllConfigs.java >--- src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 23 Feb 2009 09:14:53 -0000 1.39 >+++ src/org/eclipse/emf/cdo/tests/AllTestsAllConfigs.java 15 Mar 2009 18:17:11 -0000 >@@ -41,6 +41,7 @@ > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_260764_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_261218_Test; > import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_265114_Test; >+import org.eclipse.emf.cdo.tests.bugzilla.Bugzilla_266982_Test; > import org.eclipse.emf.cdo.tests.config.impl.ConfigTest; > import org.eclipse.emf.cdo.tests.config.impl.ConfigTestSuite; > >@@ -128,6 +129,7 @@ > testClasses.add(Bugzilla_260764_Test.class); > testClasses.add(Bugzilla_261218_Test.class); > testClasses.add(Bugzilla_265114_Test.class); >+ testClasses.add(Bugzilla_266982_Test.class); > > // TODO testClasses.add(NonCDOResourceTest.class); > // TODO testClasses.add(GeneratedEcoreTest.class); >Index: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java >=================================================================== >RCS file: src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java >diff -N src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java >--- /dev/null 1 Jan 1970 00:00:00 -0000 >+++ src/org/eclipse/emf/cdo/tests/bugzilla/Bugzilla_266982_Test.java 1 Jan 1970 00:00:00 -0000 >@@ -0,0 +1,86 @@ >+/** >+ * Copyright (c) 2004 - 2009 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: >+ * Simon McDuff - initial API and implementation >+ */ >+package org.eclipse.emf.cdo.tests.bugzilla; >+ >+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.Customer; >+import org.eclipse.emf.cdo.transaction.CDOTransaction; >+import org.eclipse.emf.cdo.util.CDOUtil; >+ >+import junit.framework.Assert; >+ >+/** >+ * IllegalStateException in CDOStore.getRevision >+ * <p> >+ * See https://bugs.eclipse.org/266982 >+ * >+ * @author Simon McDuff >+ */ >+public class Bugzilla_266982_Test extends AbstractCDOTest >+{ >+ public void testBugzilla_266982() throws Exception >+ { >+ final Customer customer = getModel1Factory().createCustomer(); >+ final boolean done[] = new boolean[1]; >+ final Exception exception[] = new Exception[1]; >+ done[0] = false; >+ customer.setName("customer"); >+ >+ CDOSession session = openModel1Session(); >+ CDOTransaction transaction = session.openTransaction(); >+ CDOResource resource = transaction.createResource("/test1"); >+ resource.getContents().add(customer); >+ transaction.commit(); >+ >+ Runnable changeObjects = new Runnable() >+ { >+ public void run() >+ { >+ try >+ { >+ CDOSession session = openModel1Session(); >+ CDOTransaction transaction = session.openTransaction(); >+ Customer customerToLoad = (Customer)transaction.getObject(CDOUtil.getCDOObject(customer).cdoID()); >+ while (!done[0]) >+ { >+ // Could fail if the attach is not thread safe >+ customerToLoad.getName(); >+ } >+ transaction.close(); >+ session.close(); >+ } >+ catch (Exception ex) >+ { >+ exception[0] = ex; >+ } >+ } >+ }; >+ >+ new Thread(changeObjects).start(); >+ >+ for (int i = 0; i < 500 && exception[0] == null; i++) >+ { >+ customer.setName("Ottawa" + i); >+ transaction.commit(); >+ } >+ >+ done[0] = true; >+ if (exception[0] != null) >+ { >+ exception[0].printStackTrace(); >+ Assert.fail(exception[0].getMessage()); >+ } >+ >+ session.close(); >+ } >+} >#P org.eclipse.emf.cdo >Index: src/org/eclipse/emf/internal/cdo/CDOStateMachine.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java,v >retrieving revision 1.108 >diff -u -r1.108 CDOStateMachine.java >--- src/org/eclipse/emf/internal/cdo/CDOStateMachine.java 14 Mar 2009 11:07:29 -0000 1.108 >+++ src/org/eclipse/emf/internal/cdo/CDOStateMachine.java 15 Mar 2009 18:17:13 -0000 >@@ -47,6 +47,7 @@ > import java.util.Iterator; > import java.util.List; > import java.util.Map; >+import java.util.concurrent.locks.ReentrantLock; > > /** > * @author Eike Stepper >@@ -177,13 +178,23 @@ > */ > public void attach(InternalCDOObject object, InternalCDOTransaction transaction) > { >- List<InternalCDOObject> contents = new ArrayList<InternalCDOObject>(); >- attach1(object, new Pair<InternalCDOTransaction, List<InternalCDOObject>>(transaction, contents)); >- attach2(object); >+ ReentrantLock viewLock = transaction.getStateLock(); >+ viewLock.lock(); > >- for (InternalCDOObject content : contents) >+ try > { >- attach2(content); >+ List<InternalCDOObject> contents = new ArrayList<InternalCDOObject>(); >+ attach1(object, new Pair<InternalCDOTransaction, List<InternalCDOObject>>(transaction, contents)); >+ attach2(object); >+ >+ for (InternalCDOObject content : contents) >+ { >+ attach2(content); >+ } >+ } >+ finally >+ { >+ viewLock.unlock(); > } > } > >@@ -219,35 +230,45 @@ > */ > public void detach(InternalCDOObject object) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.DETACH); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.DETACH); >+ } > >- List<InternalCDOObject> objectsToDetach = new ArrayList<InternalCDOObject>(); >- InternalCDOTransaction transaction = (InternalCDOTransaction)object.cdoView(); >+ List<InternalCDOObject> objectsToDetach = new ArrayList<InternalCDOObject>(); >+ InternalCDOTransaction transaction = (InternalCDOTransaction)object.cdoView(); > >- // Accumulate objects that needs to be detached >- // If we have an error, we will keep the graph exactly like it was before. >- process(object, CDOEvent.DETACH, objectsToDetach); >+ // Accumulate objects that needs to be detached >+ // If we have an error, we will keep the graph exactly like it was before. >+ process(object, CDOEvent.DETACH, objectsToDetach); > >- // postDetach requires the object to be TRANSIENT >- for (InternalCDOObject content : objectsToDetach) >- { >- CDOState oldState = content.cdoInternalSetState(CDOState.TRANSIENT); >- content.cdoInternalPostDetach(); >- content.cdoInternalSetState(oldState); >- } >+ // postDetach requires the object to be TRANSIENT >+ for (InternalCDOObject content : objectsToDetach) >+ { >+ CDOState oldState = content.cdoInternalSetState(CDOState.TRANSIENT); >+ content.cdoInternalPostDetach(); >+ content.cdoInternalSetState(oldState); >+ } > >- // detachObject needs to know the state before we change the object to TRANSIENT >- for (InternalCDOObject content : objectsToDetach) >- { >- transaction.detachObject(content); >- content.cdoInternalSetState(CDOState.TRANSIENT); >+ // detachObject needs to know the state before we change the object to TRANSIENT >+ for (InternalCDOObject content : objectsToDetach) >+ { >+ transaction.detachObject(content); >+ content.cdoInternalSetState(CDOState.TRANSIENT); > >- content.cdoInternalSetView(null); >- content.cdoInternalSetID(null); >- content.cdoInternalSetRevision(null); >+ content.cdoInternalSetView(null); >+ content.cdoInternalSetID(null); >+ content.cdoInternalSetRevision(null); >+ } >+ } >+ finally >+ { >+ viewLock.unlock(); > } > } > >@@ -256,12 +277,22 @@ > */ > public void read(InternalCDOObject object) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.READ); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.READ); >+ } > >- process(object, CDOEvent.READ, null); >+ process(object, CDOEvent.READ, null); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > /** >@@ -277,12 +308,22 @@ > */ > public void write(InternalCDOObject object, CDOFeatureDelta featureDelta) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.WRITE); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.WRITE); >+ } > >- process(object, CDOEvent.WRITE, featureDelta); >+ process(object, CDOEvent.WRITE, featureDelta); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > /** >@@ -321,19 +362,29 @@ > > if (view != null) > { >- InternalCDOSession session = (InternalCDOSession)view.getSession(); >- revisions = session.getSessionProtocol().verifyRevision(revisions); >+ ReentrantLock viewLock = ((InternalCDOView)view).getStateLock(); >+ viewLock.lock(); > >- revisions.addAll(revised); >- for (InternalCDORevision revision : revisions) >+ try > { >- InternalCDOObject object = ids.get(revision.getID()); >- if (TRACER.isEnabled()) >+ InternalCDOSession session = (InternalCDOSession)view.getSession(); >+ revisions = session.getSessionProtocol().verifyRevision(revisions); >+ >+ revisions.addAll(revised); >+ for (InternalCDORevision revision : revisions) > { >- trace(object, CDOEvent.RELOAD); >- } >+ InternalCDOObject object = ids.get(revision.getID()); >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.RELOAD); >+ } > >- process(object, CDOEvent.RELOAD, null); >+ process(object, CDOEvent.RELOAD, null); >+ } >+ } >+ finally >+ { >+ viewLock.unlock(); > } > } > } >@@ -343,12 +394,22 @@ > */ > public void invalidate(InternalCDOObject object, int version) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.INVALIDATE); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.INVALIDATE); >+ } > >- process(object, CDOEvent.INVALIDATE, version); >+ process(object, CDOEvent.INVALIDATE, version); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > /** >@@ -356,12 +417,22 @@ > */ > public void detachRemote(InternalCDOObject object) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.DETACH_REMOTE); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.DETACH_REMOTE); >+ } > >- process(object, CDOEvent.DETACH_REMOTE, CDORevision.UNSPECIFIED_VERSION); >+ process(object, CDOEvent.DETACH_REMOTE, CDORevision.UNSPECIFIED_VERSION); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > /** >@@ -369,12 +440,22 @@ > */ > public void commit(InternalCDOObject object, CommitTransactionResult result) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.COMMIT); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.COMMIT); >+ } > >- process(object, CDOEvent.COMMIT, result); >+ process(object, CDOEvent.COMMIT, result); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > /** >@@ -382,12 +463,22 @@ > */ > public void rollback(InternalCDOObject object) > { >- if (TRACER.isEnabled()) >+ ReentrantLock viewLock = object.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try > { >- trace(object, CDOEvent.ROLLBACK); >- } >+ if (TRACER.isEnabled()) >+ { >+ trace(object, CDOEvent.ROLLBACK); >+ } > >- process(object, CDOEvent.ROLLBACK, null); >+ process(object, CDOEvent.ROLLBACK, null); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > @Override >Index: src/org/eclipse/emf/internal/cdo/CDOStore.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStore.java,v >retrieving revision 1.80 >diff -u -r1.80 CDOStore.java >--- src/org/eclipse/emf/internal/cdo/CDOStore.java 15 Mar 2009 10:59:04 -0000 1.80 >+++ src/org/eclipse/emf/internal/cdo/CDOStore.java 15 Mar 2009 18:17:14 -0000 >@@ -52,6 +52,7 @@ > > import java.text.MessageFormat; > import java.util.Collection; >+import java.util.concurrent.locks.ReentrantLock; > > /** > * CDORevision needs to follow these rules:<br> >@@ -566,8 +567,18 @@ > > private static InternalCDORevision getRevisionForReading(InternalCDOObject cdoObject) > { >- CDOStateMachine.INSTANCE.read(cdoObject); >- return getRevision(cdoObject); >+ ReentrantLock viewLock = cdoObject.cdoView().getStateLock(); >+ viewLock.lock(); >+ >+ try >+ { >+ CDOStateMachine.INSTANCE.read(cdoObject); >+ return getRevision(cdoObject); >+ } >+ finally >+ { >+ viewLock.unlock(); >+ } > } > > private static InternalCDORevision getRevisionForWriting(InternalCDOObject cdoObject, CDOFeatureDelta delta) >Index: src/org/eclipse/emf/spi/cdo/InternalCDOView.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/spi/cdo/InternalCDOView.java,v >retrieving revision 1.3 >diff -u -r1.3 InternalCDOView.java >--- src/org/eclipse/emf/spi/cdo/InternalCDOView.java 11 Jan 2009 09:25:07 -0000 1.3 >+++ src/org/eclipse/emf/spi/cdo/InternalCDOView.java 15 Mar 2009 18:17:14 -0000 >@@ -30,6 +30,7 @@ > > import java.util.Collection; > import java.util.Set; >+import java.util.concurrent.locks.ReentrantLock; > > /** > * @author Eike Stepper >@@ -98,4 +99,6 @@ > public void unsubscribe(EObject eObject, Adapter adapter); > > public boolean hasSubscription(CDOID id); >+ >+ public ReentrantLock getStateLock(); > } >Index: src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java >=================================================================== >RCS file: /cvsroot/modeling/org.eclipse.emf/org.eclipse.emf.cdo/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java,v >retrieving revision 1.7 >diff -u -r1.7 CDOViewImpl.java >--- src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java 14 Mar 2009 11:07:28 -0000 1.7 >+++ src/org/eclipse/emf/internal/cdo/view/CDOViewImpl.java 15 Mar 2009 18:17:14 -0000 >@@ -125,6 +125,8 @@ > > private ReentrantLock lock = new ReentrantLock(true); > >+ private ReentrantLock stateLock = new ReentrantLock(true); >+ > private CDOResourceImpl rootResource; > > private ChangeSubscriptionManager changeSubscriptionManager = createChangeSubscriptionManager(); >@@ -260,6 +262,14 @@ > } > > /** >+ * @since 2.0 >+ */ >+ public ReentrantLock getStateLock() >+ { >+ return stateLock; >+ } >+ >+ /** > * @throws InterruptedException > * @since 2.0 > */
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 266982
:
127443
|
128842
|
128848