This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 217111

Summary: Deadlocks updating dependencies while POM is open in editor
Product: projects Reporter: Jesse Glick <jglick>
Component: MavenAssignee: Milos Kleint <mkleint>
Status: RESOLVED FIXED    
Severity: normal CC: sdedic
Priority: P3 Keywords: THREAD
Version: 7.3   
Hardware: PC   
OS: Linux   
Issue Type: DEFECT Exception Reporter:
Attachments: Tried to remove a dep
A couple minutes before, when adding a dep

Description Jesse Glick 2012-08-20 15:23:20 UTC
Created attachment 123316 [details]
Tried to remove a dep

47bac66aa192. Seems if I have a POM open in the editor, making additions or removals in the Dependencies node is more likely than not to result in a deadlock.
Comment 1 Jesse Glick 2012-08-20 15:24:19 UTC
Created attachment 123317 [details]
A couple minutes before, when adding a dep
Comment 2 Milos Kleint 2012-08-22 12:08:08 UTC
I believe the fix http://hg.netbeans.org/main/rev/3dfb067533e2 it completely flawed.
At least according to the xam/xdm documentation isInTransaction() means that some other thread holds the lock and is in transaction. But that has no relationship to the current thread whatsoever. The lock only applies to the thread that started the transaction. The transaction could be ended right after this check. or in the middle of it.. but we still query the model from the other thread.


I suggest we remove these checks and just acquire the transaction, or not even bother since transactions are supposedly to be started only for mutations, which we don't do in the StatusProvider. 

also please note that model.synch() which is called by StatusProvider.checkModelValid() will in it's body start a blocking transaction.

to solve this problem I suggest 2 solutions (should be aplied together, not mutually exclusive):
1. Utilities.performPOMModelOperations() will wrap the xam transaction in ((BaseDocument)model.getBaseDocument()).runAtomicAsUser(Runnable) to have the document locked first.
2. in status provider, remove all the transaction related code and just read the models.
Comment 3 Milos Kleint 2012-08-22 13:56:21 UTC
http://hg.netbeans.org/core-main/rev/03bf71617ea5

but I also filed issue 217234 to finally create order in the way threading is done with the xam pom models.
Comment 4 Milos Kleint 2012-08-22 13:56:43 UTC
*** Bug 216978 has been marked as a duplicate of this bug. ***
Comment 5 Quality Engineering 2012-08-23 16:06:10 UTC
Integrated into 'main-golden', will be available in build *201208231248* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/03bf71617ea5
User: Milos Kleint <mkleint@netbeans.org>
Log: #217111 post code to RP thread to avoid document lock in awt