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

Bug 315078

Summary: Logical view is sometime unable to display newly imported project
Product: z_Archived Reporter: Bozier jerome <jerome.bozier>
Component: TPTPAssignee: Bozier jerome <jerome.bozier>
Status: CLOSED FIXED QA Contact: Kathy Chan <kathy>
Severity: normal    
Priority: P2 CC: jptoomey, paulslau
Version: unspecifiedFlags: paulslau: review+
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Whiteboard: adopter
Attachments:
Description Flags
patch none

Description Bozier jerome CLA 2010-05-31 09:38:28 EDT
in logical view, try to import several project at the same time
sometime, the display is not refreshed and this exception is raised :

 java.util.ConcurrentModificationException
	at java.util.HashMap$HashIterator.nextEntry(HashMap.java:1091)
	at java.util.HashMap$KeyIterator.next(HashMap.java:1128)
	at org.eclipse.hyades.test.ui.internal.navigator.LogicalTestNavigatorContentProvider$ProxiesRequests.nodesChanged(LogicalTestNavigatorContentProvider.java:190)
	at org.eclipse.hyades.test.ui.internal.navigator.TestNavigator.nodesChanged(TestNavigator.java:1213)
	at org.eclipse.hyades.test.ui.internal.navigator.TestResourceChangeUpdater.ended(TestResourceChangeUpdater.java:115)
	at org.eclipse.hyades.ui.internal.provider.ResourceChangeUpdaterProvider.doProcessDelta(ResourceChangeUpdaterProvider.java:123)
	at org.eclipse.hyades.ui.internal.provider.ResourceChangeUpdaterProvider.resourceChanged(ResourceChangeUpdaterProvider.java:101)
	at org.eclipse.hyades.test.ui.internal.navigator.proxy.FileProxyNodeCache$ResourceChangeListener.resourceChanged(FileProxyNodeCache.java:717)
	at org.eclipse.core.internal.events.NotificationManager$2.run(NotificationManager.java:291)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:42)
	at org.eclipse.core.internal.events.NotificationManager.notify(NotificationManager.java:285)
	at org.eclipse.core.internal.events.NotificationManager.broadcastChanges(NotificationManager.java:149)
	at org.eclipse.core.internal.resources.Workspace.broadcastPostChange(Workspace.java:327)
	at org.eclipse.core.internal.resources.Workspace.endOperation(Workspace.java:1181)
	at org.eclipse.core.internal.resources.Workspace.run(Workspace.java:1984)
	at org.eclipse.ui.actions.WorkspaceModifyOperation.run(WorkspaceModifyOperation.java:118)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:121)

problem occur because at the same time, the projectMap is updated on one side and on the other, we iterate on it
Comment 1 Bozier jerome CLA 2010-05-31 10:16:34 EDT
to be a bit more precise to reproduce it
. first, go in logical view
. then, import a very big project (as testnavigator.tests)
. expand it
. while the proxy are calculated, import another project

reason :
. all is happening inside LogicalTestNavigator class, inside ProxiesRequests subclass
. when you import a project, it is added to the map "projectToRequestMap"
. the listener on "nodesChanged" iterate on this map keyset. so, if this map is changed during this time, the "concurrentAccess" exception is raised

fix : 
. make a synchronize block on the map time to copy the keySet list.
. make the "nodesChanged" iterate on this copy

updating estimated time, patch will come in a few
Comment 2 Bozier jerome CLA 2010-05-31 10:39:28 EDT
Created attachment 170534 [details]
patch

this patch protect the project map against multithread access :
. map is now a SynchronizedMap (protect it for all adding/removing)
. when we have to iterate on it (for refresh or dispose), we create a local copy in a small synchronized block and iterate on the copy
Comment 3 Bozier jerome CLA 2010-05-31 10:40:20 EDT
Paul, could you review it please ?

many thanks in advance
Comment 4 Bozier jerome CLA 2010-05-31 10:54:35 EDT
test case added under CVS (will update wiki if patch is pushed under CVS)
Comment 5 Kathy Chan CLA 2010-05-31 13:46:18 EDT
Jerome,

Is this a regression from previous releases or just a newly found problem?

As you are aware, Paul is not available to review the patch at this time.  Adding Joe to the CC list to review it.

I'm tentatively targeting this to 4.7.1 unless this turns out to be a regression or a serious problem affecting many consumers.
Comment 6 Joe Toomey CLA 2010-05-31 14:57:01 EDT
This seems to be a very fringe use case (importing a project while a previously imported project is still being expanded in the Logical test navigator.)  

I agree with the 4.7.1 target.
Comment 7 Bozier jerome CLA 2010-05-31 15:19:32 EDT
seeing the source code, this bug exists since really long time (perhaps since logical view exists in test navigator)
so, i agree on the 4.7.1 target 
(i made the patch because it was fast and to not forget it)

updating worked hours
Comment 8 Paul Slauenwhite CLA 2010-06-21 12:26:40 EDT
Requires adding /org.eclipse.hyades.test.ui.navigator.tests/manual/Test.UI.TestNavigator_bugzilla_315078.testsuite to /org.eclipse.hyades.test.ui.navigator.tests/manual/AllTests.testsuite and http://wiki.eclipse.org/TPTP_Test_Tools_Project_Tests#Manual.
Comment 9 Paul Slauenwhite CLA 2010-06-22 13:56:47 EDT
Of interested but not formally requested by a consuming product.  As such, a candidate defect for TPTP 4.7.0.1.
Comment 10 Paul Slauenwhite CLA 2010-06-23 09:30:57 EDT
The attached patch reviewed with comments:

-Update the copyright year to 2010.

-Do we still need to synchronize on projectToRequestMap if we are using a synchronized map?  If it's required, we should use a separate locking object.
Comment 11 Bozier jerome CLA 2010-06-28 08:43:04 EDT
(In reply to comment #10)

> 
> -Do we still need to synchronize on projectToRequestMap if we are using a
> synchronized map?  If it's required, we should use a separate locking object.

ya, synchronized map is automatically protected except for iterating part, that must be in synchronized block (synchronized on list itself, see :
http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html#synchronizedMap%28java.util.Map%29)


Patch fixed (for copyright) and pushed on CVS head
test suite added to "allTest"
wiki updated
closing
Comment 12 Bozier jerome CLA 2010-06-28 08:44:31 EDT
fix : update status to resolved insted of closed
Comment 13 Bozier jerome CLA 2010-08-24 08:48:16 EDT
verified in build TPTP-4.7.1-201008232100, closing