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 192421 - Deadlock between NbMavenProjectImpl and MavenProjectPropsImpl
Summary: Deadlock between NbMavenProjectImpl and MavenProjectPropsImpl
Status: RESOLVED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Maven (show other bugs)
Version: 7.0
Hardware: PC Linux
: P1 normal (vote)
Assignee: Antonin Nebuzelsky
URL:
Keywords: THREAD
Depends on:
Blocks:
 
Reported: 2010-11-24 17:08 UTC by Jesse Glick
Modified: 2010-12-11 06:32 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (20.67 KB, text/plain)
2010-11-24 17:08 UTC, Jesse Glick
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2010-11-24 17:08:48 UTC
Created attachment 103299 [details]
Thread dump

Occurred to me today in 101124-3c968d669482. Tried to open a project which was unloadable (missing parent POMs I think); IDE stuck in Opening Project dialog and had to be killed.
Comment 1 Antonin Nebuzelsky 2010-12-10 13:25:04 UTC
The problem here is that two threads are synchronizing on NbMavenProjectImpl, one thread at the end of opening the project in LazyLookup.beforeLookup() and the other thread (after reloading the project) in call to getOriginalMavenProject() through the MavenProjectPropsImpl getter method. They both are also synchronizing on MavenProjectPropsImpl.

The methods of MavenProjectPropsImpl probably need to stay synchronized.

What could help would be a modification of getOriginalMavenProject() method which would wait on synchronization only if project == null, i.e. change like this:

-    public @NonNull synchronized MavenProject getOriginalMavenProject() {
+    public @NonNull MavenProject getOriginalMavenProject() {
         if (project == null) {
+            synchronized (this) {
+                if (project == null) {
                     project = loadOriginalMavenProject(true);
                 }
+            }
+        }
         return project;
     }

Jesse, can you review and comment?
Comment 2 alexismp 2010-12-10 13:52:40 UTC
cc
Comment 3 Jesse Glick 2010-12-10 14:20:39 UTC
The suggested patch is double-checked locking, which is generally frowned upon.

Better would probably be to have MavenProjectPropsImpl synchronize on the associated NbMavenProjectImpl rather than itself.
Comment 4 Antonin Nebuzelsky 2010-12-10 15:50:00 UTC
Good idea. Thanks, Jesse.

Fixed in core-main #ca1f94af7f4d
Comment 5 Quality Engineering 2010-12-11 06:32:37 UTC
Integrated into 'main-golden', will be available in build *201012110001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/ca1f94af7f4d
User: Antonin Nebuzelsky <anebuzelsky@netbeans.org>
Log: #192421 - Deadlock between NbMavenProjectImpl and MavenProjectPropsImpl