Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 331438 - Deadlock initializing Java EE EMF models
Summary: Deadlock initializing Java EE EMF models
Status: RESOLVED FIXED
Alias: None
Product: WTP Java EE Tools
Classification: WebTools
Component: jst.j2ee (show other bugs)
Version: 3.2   Edit
Hardware: PC Windows XP
: P3 major (vote)
Target Milestone: 3.2.3   Edit
Assignee: Carl Anderson CLA
QA Contact: Chuck Bridgham CLA
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-30 09:37 EST by Carl Anderson CLA
Modified: 2010-12-01 19:55 EST (History)
0 users

See Also:
cbridgha: review+


Attachments
Same deadlock fix as j2ee models (556.44 KB, patch)
2010-12-01 11:51 EST, Carl Anderson CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Carl Anderson CLA 2010-11-30 09:37:43 EST
An adopter product is encountering the same type of EMF initialization deadlock as was reported in bug 315286 , except that this is occurring in the Java EE EMF models (whereas the previous one was in the j2ee EMF models).
Comment 1 Carl Anderson CLA 2010-12-01 11:51:49 EST
Created attachment 184275 [details]
Same deadlock fix as j2ee models
Comment 2 Carl Anderson CLA 2010-12-01 14:50:49 EST
The patch here looks huge, but a lot is due to indentation.

Simply put, instead of the initialization of any entry point causing everything
to be initialized (which can deadlock if two initializations are waiting for
each other), I am making the model initialization a directed initialization-
each model element initializes all of the models it requires, and then it calls
to J2EEInit(), which does a "bottom up" initialization of everything on a
separate thread.

Note that during the initialization, which requires being in a constructor, it
is illegal to call wait().  Calling sleep() can cause one thread to wait, but
it will not allow re-entrance into the constructor that is already in progress.
 Therefore, the full initialization should happen on its own thread, and still
following the directed approach.  (I chose the order that is in there because
it will initialize things at the lowest level first, which reduces the risk of
another thread waiting for initialization- if most of the required models of a
particular EMF model are already initialized, its initialization should be
quick and will be less likely to wait.

The separate initialization is guarded to only happen once.

I ran the entire J2EE JUnit bucket against this change.
Comment 3 Chuck Bridgham CLA 2010-12-01 17:05:24 EST
approved
Comment 4 Carl Anderson CLA 2010-12-01 19:55:16 EST
Committed to R3_2_maintenance and HEAD for WTP 3.2.3 and WTP 3.3