Skip to content

Commit

Permalink
Avoid deadlock by using the same object to synchronise open calls
Browse files Browse the repository at this point in the history
* Possible to have the UI thread taking ownership of the
  ModelWorkspaceManager with another thread owning the openLock. Thus, the
  2 threads can become deadlocked.
  • Loading branch information
Paul Richardson committed Aug 27, 2013
1 parent 70fabd4 commit d28e1cb
Showing 1 changed file with 1 addition and 3 deletions.
Expand Up @@ -24,8 +24,6 @@
*/
public abstract class OpenableImpl extends ModelWorkspaceItemImpl implements Openable, InternalOpenable {

private Object openLock = new Object();

/**
* Construct an instance of OpenableImpl.
*/
Expand Down Expand Up @@ -120,7 +118,7 @@ protected void closing( Object info ) {
*/
@Override
public void openWhenClosed( final IProgressMonitor pm ) throws ModelWorkspaceException {
synchronized(openLock) {
synchronized(ModelWorkspaceManager.getModelWorkspaceManager()) {

// If a thread has had to wait before acquiring the lock then another thread may well
// have already opened this Openable so check again if it is opened.
Expand Down

0 comments on commit d28e1cb

Please sign in to comment.