Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 330976 - Potential for deadlock in JSFAppConfigManager init
Summary: Potential for deadlock in JSFAppConfigManager init
Status: RESOLVED FIXED
Alias: None
Product: Java Server Faces
Classification: WebTools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.3   Edit
Assignee: Carlin Rogers CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-23 16:56 EST by Andrew McCulloch CLA
Modified: 2010-11-30 17:49 EST (History)
6 users (show)

See Also:


Attachments
Proposed lock ordering patch. (10.09 KB, patch)
2010-11-29 16:46 EST, Andrew McCulloch CLA
no flags Details | Diff
Proposed lock ordering patch (10.86 KB, patch)
2010-11-30 13:07 EST, Andrew McCulloch CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew McCulloch CLA 2010-11-23 16:56:06 EST
Build Identifier: 

When calling JSFAppConfigManager.getInstance(IProject) there is a potential for deadlock if the JSFAppConfigManager is not yet initialized.  the first call will cause the JSFAppConfigManagerFactory which is a ResourceSingletonObjectManager instenace to call createInstance while holding the monitor on the factory.  Creating an instance of a JSFAppConfigManager requires a project scheduling rule to be acquired to read the web app model.  If there is a second thread which already holds that project scheduling rule which tries to call JSFAppConfigManager.getInstance it will block on the monitor on JSFAppConfigManagerFactory and a deadlock is created.

Reproducible: Sometimes
Comment 1 Andrew McCulloch CLA 2010-11-23 17:19:19 EST
Build id: M20100909-0800
Comment 2 Andrew McCulloch CLA 2010-11-29 16:46:54 EST
Created attachment 184082 [details]
Proposed lock ordering patch.

This proposed patch adds 2 protected methods to the internal base class of bath JSFAppConfigManagerFactory classes.  There are default implementations to both methods so no other implementor will have to make changes.  The two JSFAppConfigManagerFactory classes now implement these methods to allow checking of thread locking status and taking a project scheduling rule before taking a lock on the ResourceSingletonObjectManager instance monitor.  This insures a consistent lock ordering.

An IAdaptble object is produced as the result of the first new method and is passesd as a parameter to the second new method which allows the implementations to conditionally release a scheduling rule without having to maintain state between calls on their own which would be difficult as they are static instances.
Comment 3 Carlin Rogers CLA 2010-11-29 20:09:57 EST
Looks good, checked in. Thanks for the patch Andrew.
Comment 4 Andrew McCulloch CLA 2010-11-30 13:07:47 EST
Created attachment 184157 [details]
Proposed lock ordering patch

Additional change required to avoid locking on JSFAppConfigManagerFactory.class monitor while acquiring rule.
Comment 5 Carlin Rogers CLA 2010-11-30 17:49:39 EST
Additional modification to avoid locking on JSFAppConfigManagerFactory.class
monitor while acquiring rule has been committed.