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 197674 - Threads locked during web project open
Summary: Threads locked during web project open
Status: RESOLVED FIXED
Alias: None
Product: javaee
Classification: Unclassified
Component: Web Project (show other bugs)
Version: 7.0.1
Hardware: PC Mac OS X
: P2 normal (vote)
Assignee: David Konecny
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-12 19:07 UTC by Marek Fukala
Modified: 2011-04-14 08:38 UTC (History)
3 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
The threads dump (30.70 KB, text/plain)
2011-04-12 19:08 UTC, Marek Fukala
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Fukala 2011-04-12 19:07:13 UTC
AFAIR I've just started netbeans and opened an ant web project.
Comment 1 Marek Fukala 2011-04-12 19:08:09 UTC
Created attachment 107696 [details]
The threads dump
Comment 2 Marek Fukala 2011-04-12 19:12:27 UTC
Happened on a dev build few days old. I haven't evaluated the issue thoroughly but since there's a lot of web stuff, passing to web project resp. engineer knowledgeable in this area. 

Not reproducible, seems to happen rarely =>  P2
Comment 3 Martin Fousek 2011-04-12 20:16:22 UTC
Suppose, could be related to issue #178165. Thread dump looks different than mine ones earlier but still about the same thing. CCing Petr, he's challenging these troubles and will know more - if it's related/already fixed.
Comment 4 Petr Hejl 2011-04-12 20:34:05 UTC
(In reply to comment #3)
> Suppose, could be related to issue #178165. Thread dump looks different than
> mine ones earlier but still about the same thing. CCing Petr, he's challenging
> these troubles and will know more - if it's related/already fixed.

Not really. Looks like lock ordering problem between project mutex and ProjectWebModule in "Load Open Projects" and "init libs -- Hk2JavaEEPlatformImpl". Perhaps WebProjectJAXWSSupport.getWebservicesMetadataModel should acquire project lock in advance to prevent this. Just guessing.
Comment 5 David Konecny 2011-04-12 22:11:09 UTC
This is not a new deadlock - the opportunity was there for a long time but it just has not happened until now.

I think that synchronization of org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider is wrong or dangerous. It is an abstract class which is extended by several subclasses and most of them synchronize methods which do stuff like "MetadataModelFactory.createMetadataModel" (which in turn call bunch of other stuff from Java to Project infrastructure). Well, it's been like that since at least NB5 so I do not want to touch it. As for workarounds I agree with PetrH that WebProjectJAXWSSupport.getWebservicesMetadataModel should acquire project read lock. That will prevent this instance of the issue.

PetrH, one question: would it be possible to rewrite j2ee.common.Util.getJ2eePlatformClasspathEntries() to not acquire J2eeModuleProvider lock? That seems to me quite dangerous as well. The method name itself is pretty innocent and it is frequently called from under a Project Write lock (eg. when project properties are updated). Fixing that would worakround this issue as well.
Comment 6 Petr Hejl 2011-04-13 09:42:42 UTC
(In reply to comment #5)
> PetrH, one question: would it be possible to rewrite
> j2ee.common.Util.getJ2eePlatformClasspathEntries() to not acquire
> J2eeModuleProvider lock? That seems to me quite dangerous as well. The method
> name itself is pretty innocent and it is frequently called from under a Project
> Write lock (eg. when project properties are updated). Fixing that would
> worakround this issue as well.

Done ;)

Formally this could be considered api change, so I changed module versions. However I checked all usages and nobody use the object monitor of J2eeModuleProvider to synchronize intentionally on J2eeModuleProvider's state. Such usage would be broken anyway.

web-main 1b60db58205b
Comment 7 David Konecny 2011-04-13 19:29:26 UTC
(In reply to comment #6)
> Done ;)

Thanks!
Comment 8 Quality Engineering 2011-04-14 08:38:19 UTC
Integrated into 'main-golden', will be available in build *201104140401* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/1b60db58205b
User: phejl@netbeans.org
Log: #197674 Threads locked during web project open