Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 313913

Summary: IndexOutOfBoundsException on View Invalidation with multiple Views
Product: [Modeling] EMF Reporter: Pascal Lehmann <pascal.lehmann>
Component: cdo.coreAssignee: Eike Stepper <stepper>
Status: CLOSED FIXED QA Contact: Eike Stepper <stepper>
Severity: normal    
Priority: P3    
Version: 3.0   
Target Milestone: ---   
Hardware: All   
OS: All   
Whiteboard:
Attachments:
Description Flags
TestCase
stepper: iplog+
proposed patch stepper: iplog+

Description Pascal Lehmann CLA 2010-05-21 09:48:14 EDT
Build Identifier: 3.0

When a remote view has to be invalidated, CDONotificationBuilder.buildNotification is called which does patch the indices (bug #306710). If there are more than one remote view present, the method is called multiple times which results in the indices patched more than needed.
This can lead to an IndexOutOfBoundsException in some of the remote views:

[ERROR] Index: 1, Size: 0
java.lang.IndexOutOfBoundsException: Index: 1, Size: 0
	at java.util.ArrayList.add(Unknown Source)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDOAddFeatureDeltaImpl.apply(CDOAddFeatureDeltaImpl.java:50)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDOListFeatureDeltaImpl.apply(CDOListFeatureDeltaImpl.java:248)
	at org.eclipse.emf.cdo.internal.common.revision.delta.CDORevisionDeltaImpl.apply(CDORevisionDeltaImpl.java:191)
	at org.eclipse.emf.internal.cdo.CDOStateMachine$InvalidateTransition.execute(CDOStateMachine.java:866)
	at org.eclipse.emf.internal.cdo.CDOStateMachine$InvalidateTransition.execute(CDOStateMachine.java:1)
	at org.eclipse.net4j.util.fsm.FiniteStateMachine.process(FiniteStateMachine.java:162)
	at org.eclipse.emf.internal.cdo.CDOStateMachine.invalidate(CDOStateMachine.java:418)
	at org.eclipse.emf.internal.cdo.view.CDOViewImpl.invalidate(CDOViewImpl.java:1416)
	at org.eclipse.emf.internal.cdo.view.CDOViewImpl.invalidate(CDOViewImpl.java:1367)
	at org.eclipse.emf.internal.cdo.session.CDOSessionImpl$InvalidationRunnable.run(CDOSessionImpl.java:1205)
	at org.eclipse.net4j.util.concurrent.QueueRunner.work(QueueRunner.java:26)
	at org.eclipse.net4j.util.concurrent.QueueRunner.work(QueueRunner.java:1)
	at org.eclipse.net4j.util.concurrent.QueueWorker.work(QueueWorker.java:75)
	at org.eclipse.net4j.util.concurrent.Worker$WorkerThread.run(Worker.java:188)

Reproducible: Always

Steps to Reproduce:
1. open transaction T and two views A and B
2. add adapters to A and B
3. make some changes on T and commit
Comment 1 Pascal Lehmann CLA 2010-05-21 09:50:36 EDT
Created attachment 169499 [details]
TestCase
Comment 2 Pascal Lehmann CLA 2010-05-21 09:51:38 EDT
Created attachment 169500 [details]
proposed patch

The patch creates a copy of the FeatureDelta proir to patching.
Comment 3 Pascal Lehmann CLA 2010-05-21 11:33:27 EDT
For patch & testcase:

1) The number of lines that you added/changed is smaller than 250.
confirmed
2) You are the only author of these changed lines.
confirmed
3) You apply the EPL to these changed lines.
confirmed
Comment 4 Eike Stepper CLA 2010-05-25 04:03:03 EDT
Thank you Pascal.

Committed to HEAD
Comment 5 Eike Stepper CLA 2010-06-29 04:35:51 EDT
Available in 3.0 GA:
http://download.eclipse.org/modeling/emf/cdo/updates/3.0-releases/