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 186348 - XMLTransformation seeks DataObject without closing OutputStream
Summary: XMLTransformation seeks DataObject without closing OutputStream
Status: VERIFIED FIXED
Alias: None
Product: xml
Classification: Unclassified
Component: XSL (show other bugs)
Version: 6.x
Hardware: PC Windows XP
: P2 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: THREAD
: 158561 179206 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-05-19 07:42 UTC by vieiro
Modified: 2011-11-23 16:32 UTC (History)
2 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Thread dump (25.83 KB, text/plain)
2010-05-19 07:42 UTC, vieiro
Details

Note You need to log in before you can comment on or make changes to this bug.
Description vieiro 2010-05-19 07:42:24 UTC
Created attachment 99181 [details]
Thread dump

Hi,

I was about to XSLT Transform a XML file. I took a lot of time the very first time I did it (didn't took so long the second time).

During this first time I thought it was a threading issue (as the UI was not responsive during this time) so I took a thread dump of the JVM (attached).

The interesting parts I see are the "AWT Event Queue"

"AWT-EventQueue-1" prio=6 tid=0x06263c00 nid=0xf34 in Object.wait() [0x086ee000..0x086efb14]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x126509f0> (a org.openide.loaders.DataObjectPool)
	at java.lang.Object.wait(Object.java:485)
	at org.openide.loaders.DataObjectPool.waitNotified(DataObjectPool.java:537)
	- locked <0x126509f0> (a org.openide.loaders.DataObjectPool)
	at org.openide.loaders.DataObjectExistsException.getDataObject(DataObjectExistsException.java:71)

And this "RequestProcessor"

"Default RequestProcessor" daemon prio=2 tid=0x03f6bc00 nid=0x118 in Object.wait() [0x0533f000..0x0533fb94]
   java.lang.Thread.State: WAITING (on object monitor)
	at java.lang.Object.wait(Native Method)
	- waiting on <0x126509f0> (a org.openide.loaders.DataObjectPool)
	at java.lang.Object.wait(Object.java:485)
	at org.openide.loaders.DataObjectPool.waitNotified(DataObjectPool.java:537)
	- locked <0x126509f0> (a org.openide.loaders.DataObjectPool)

It seems to me that the DataObjectPool.wait() is causing some trouble here, but I'm not sure, so I'm submitting this for your review.
Comment 1 Jaroslav Tulach 2010-05-24 11:52:27 UTC
As far as I can guess from the thread dump:

1. "Folder recognizer" is blocked in XMLDataObject.<init> by MutualExclusionSupport - that means there is an open OutputStream for the fileobject and the system waits for it to be closed.

2. other threads wait in DataObjectExistsException.getDataObject for the XMLDataObject.<init> to finish.

3. Who's writing a file? I guess the XSL transformation in in progress: org.netbeans.modules.xsl.transform.TransformPerformer$AbstractPerformer.fileOutput(TransformPerformer.java:403)

Possible fixes:

1. Close the output stream first and only then call DataObject.find.

2. Don't query the mime type inside of XMLDataObject's constructor.

Anyway assigning to XML module, as that is where the fix has to be done.
Comment 2 Sergey Lunegov 2010-05-25 03:41:57 UTC
Nikita, please take a look.
Comment 3 Svata Dedic 2011-09-23 12:10:52 UTC
Probably I should do both; there's (IMHO) no real need to keep the stream open past DO.find() in the transformation
Comment 4 Svata Dedic 2011-09-23 13:05:46 UTC
Correction - getMIMEType() is called by Loaders themselves, so there's only a little advantage in lazy-recognizing; during XMLDO.<init> the MIME should already resolved & cached. We eliminate only the block when the cached FO is released before loader recognition and XMLDO.<init>

According to the report/stacktrace, the visual defect is that the Folder recognizer thread blocks within DataObject.find() - and that may still happen in DataLoaderPool.allLoaders (calls fo.getMIMEType()) during LONG file operation (not exactly this case). The FolderRecognizer might be still stopped for ~2 sec (10 x 200ms).
Comment 5 Quality Engineering 2011-09-24 14:01:54 UTC
Integrated into 'main-golden'
Changeset: http://hg.netbeans.org/main-golden/rev/e5bcb6e946ae
User: Svata Dedic <sdedic@netbeans.org>
Log: #186348: XMLDO performs lazy resolution of MIMEtype. TransformAction first unlocks, then invalidates DOs - potentially DO will be created once more needlessly
Comment 6 Svata Dedic 2011-09-26 07:19:58 UTC
Fixed: http://hg.netbeans.org/jet-main/rev/e5bcb6e946ae
Comment 7 Svata Dedic 2011-09-26 11:01:29 UTC
*** Bug 158561 has been marked as a duplicate of this bug. ***
Comment 8 Svata Dedic 2011-10-06 11:56:01 UTC
*** Bug 179206 has been marked as a duplicate of this bug. ***