Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] Invalid "Duplicate ID" exception?
[CDO] Invalid "Duplicate ID" exception? [message #507175] Tue, 12 January 2010 11:24
Eclipse UserFriend
Originally posted by: Thomas.Kowatsch.ruag.com

Hi.

I have the following scenario:
- CDO Transaction opened with a transaction handler.
- The Transaction handler implements in modifyingObjects():
if object is an Editable (that has last edit name and date) then set
the last edit name and user. possible recursion is checked with checking
the feature to be modified in modifyingObjects().
- now I add an object A (is an Editable) to a containment list in object
B (is also an Editable).
- modifyingObject() is entered correctly for B with containement list as
featureChange. inside modifyingObject(), last edit name and time is
updated ok.
- so far no problems...
- when looking at the call stack when modifyingObject() is called for
object B, it looks like:
CDOTransactionImpl.registerFeatureDelta(InternalCDOObject,
CDOFeatureDelta) line: 1175
CDOTransactionImpl.registerDirty(InternalCDOObject, CDOFeatureDelta)
line: 1197
CDOStateMachine$WriteTransition.execute(InternalCDOObject, CDOState,
CDOEvent, Object) line: 909
CDOStateMachine$WriteTransition.execute(Object, Enum, Enum, Object) line: 1
CDOStateMachine(FiniteStateMachine<STATE,EVENT,SUBJECT>).process(SUBJECT,
EVENT, DATA) line: 162
CDOStateMachine.writeWithoutViewLock(InternalCDOObject, CDOFeatureDelta)
line: 392
CDOStateMachine.write(InternalCDOObject, CDOFeatureDelta) line: 377
CDOStore.getRevisionForWriting(InternalCDOObject, CDOFeatureDelta)
line: 610
CDOStore.add(InternalEObject, EStructuralFeature, int, Object) line: 391
EStoreEObjectImpl$BasicEStoreEList<E>.delegateAdd(int, Object) line: 172

Now the problems come up in
CDOTransactionImpl.registerDirty(InternalCDOObject, CDOFeatureDelta).
There is a call to CDOTransactionImpl.registerNew(Map map,
InternalCDOObject object) at the end of the method. Inside registerNew,
the object should be added to the dirty objects map:

...
Object old = map.put(object.cdoID(), object);
if (old != null)
{
throw new
IllegalStateException(MessageFormat.format(Messages.getStrin g( "CDOTransactionImpl.10"),
object)); //$NON-NLS-1$
}
...

No the IllegalStateException is thrown because there is already a CDO
object with the same ID in the map. Chekcing what object is already in
the map showed that it is in fact the same object (instance) that wants
to get added right now, i.e. the object already is added.

in my unterstandings, the "if" expression above should be:

if (old != null && old != object)

Is that actually a bug or am I getting something wrong?
If it is a bug, please tell me, I will open one.

Cheers.
--Thomas
Re: [CDO] Invalid "Duplicate ID" exception? [message #507180 is a reply to message #507175] Tue, 12 January 2010 06:50 Go to previous message
Eike Stepper is currently offline Eike StepperFriend
Messages: 6457
Registered: July 2009
Senior Member
Hi Thomas,

Comments below...


Thomas Kowatsch schrieb:
> Hi.
>
> I have the following scenario:
> - CDO Transaction opened with a transaction handler.
> - The Transaction handler implements in modifyingObjects():
> if object is an Editable (that has last edit name and date) then set
> the last edit name and user.
I fear it's not advisable to modify objects while they're being
modified. You should move your logic into an Adapter.

Cheers
/Eike

----
http://thegordian.blogspot.com
http://twitter.com/eikestepper



> possible recursion is checked with checking the feature to be modified
> in modifyingObjects().
> - now I add an object A (is an Editable) to a containment list in
> object B (is also an Editable).
> - modifyingObject() is entered correctly for B with containement list
> as featureChange. inside modifyingObject(), last edit name and time is
> updated ok.
> - so far no problems...
> - when looking at the call stack when modifyingObject() is called for
> object B, it looks like:
> CDOTransactionImpl.registerFeatureDelta(InternalCDOObject,
> CDOFeatureDelta) line: 1175
> CDOTransactionImpl.registerDirty(InternalCDOObject, CDOFeatureDelta)
> line: 1197
> CDOStateMachine$WriteTransition.execute(InternalCDOObject, CDOState,
> CDOEvent, Object) line: 909
> CDOStateMachine$WriteTransition.execute(Object, Enum, Enum, Object)
> line: 1
> CDOStateMachine(FiniteStateMachine<STATE,EVENT,SUBJECT>).process(SUBJECT,
> EVENT, DATA) line: 162
> CDOStateMachine.writeWithoutViewLock(InternalCDOObject,
> CDOFeatureDelta) line: 392
> CDOStateMachine.write(InternalCDOObject, CDOFeatureDelta) line: 377
> CDOStore.getRevisionForWriting(InternalCDOObject, CDOFeatureDelta)
> line: 610
> CDOStore.add(InternalEObject, EStructuralFeature, int, Object) line:
> 391
> EStoreEObjectImpl$BasicEStoreEList<E>.delegateAdd(int, Object) line:
> 172
>
> Now the problems come up in
> CDOTransactionImpl.registerDirty(InternalCDOObject, CDOFeatureDelta).
> There is a call to CDOTransactionImpl.registerNew(Map map,
> InternalCDOObject object) at the end of the method. Inside
> registerNew, the object should be added to the dirty objects map:
>
> ...
> Object old = map.put(object.cdoID(), object);
> if (old != null)
> {
> throw new
> IllegalStateException(MessageFormat.format(Messages.getStrin g( "CDOTransactionImpl.10"),
> object)); //$NON-NLS-1$
> }
> ...
>
> No the IllegalStateException is thrown because there is already a CDO
> object with the same ID in the map. Chekcing what object is already in
> the map showed that it is in fact the same object (instance) that
> wants to get added right now, i.e. the object already is added.
>
> in my unterstandings, the "if" expression above should be:
>
> if (old != null && old != object)
>
> Is that actually a bug or am I getting something wrong?
> If it is a bug, please tell me, I will open one.
>
> Cheers.
> --Thomas


Previous Topic:Re: GMF & TENEO
Next Topic:EMF test code
Goto Forum:
  


Current Time: Fri Dec 13 23:09:26 GMT 2019

Powered by FUDForum. Page generated in 0.02012 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top