Bug 469566 - Provide lock free RepositoryProvider.getProvider() API
Summary: Provide lock free RepositoryProvider.getProvider() API
Status: NEW
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Team (show other bugs)
Version: 4.5   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform Team Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-06-07 09:48 EDT by Andrey Loskutov CLA
Modified: 2015-06-07 09:49 EDT (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrey Loskutov CLA 2015-06-07 09:48:19 EDT
In EGit we had at least 2 bugs with deadlocks where the root cause was that  RepositoryProvider.getProvider() not only "gets" the provider but tries to map one in some cases. So a call to getProvider() can ends up in call to RepositoryProvider.mapExistingProvider() which takes "mappingLock" lock, independently if the calling thread already owns workspace locks.

This way we cannot actually use RepositoryProvider.getProvider() API from IResourceListener.resourceChanged() code, but we want to do so to know if the resource is mapped to EGit or not.

This is pity, since the API of IResourceListener.resourceChanged() explicitly states that:

"IResourceChangeEvent object (and the resource delta within it) is valid only for the duration of the invocation of this method."

So we are forced to do a two-pass event handling (in different threads!) where in the first pass we must somehow try to find interesting resources *without* using RepositoryProvider.getProvider() API, and for the second pass start a new job to find out if the resources are mapped to EGit or not. This is, honestly speaking, an overkill.

So I would like to request here a new 

public static RepositoryProvider getProvider(IProject project, String id, boolean mapIfNeeded) 

API (or something like this) which does NOT involve any locks and simply returns the provider mapped to the project if the flag is set to false.