file locking error in tree editor

Rich Unger <[email protected]> Mon, 17 Nov 2003 17:31:01 -0800
Newsgroups gmane.comp.java.netbeans.modules.xml.devel
Message-ID <[email protected]>
I'm trying to debug a file locking problem in the tree editor (it's
probably my fault to begin with).  The problem can be reproduced as
follows:

1. Create an XML file with a DTD DOCTYPE reference.
Here's an example:

<?xml version="1.0" encoding="utf-8"?>

<!DOCTYPE struts-config
  PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.1//EN" 
  "http://jakarta.apache.org/struts/dtds/struts-config_1_1.dtd">
<struts-config>
   <action-mappings/>
</struts-config>

2. Expand it's node in the Explorer window.
3. Delete the node in the Explorer window.

You won't be allowed to delete the file.

The error does not occur if there's no DOCTYPE line, nor is there a
problem if I open up the file in the text editor.  It seems limited to
tree-editor/Explorer code.

My first thought was to look at xml/tree/completion/GrammarManager.java. 
It has a static Map which holds onto references to the XMLDataObject (both
in the key and, indirectly, in the value.  I tried replacing the key with
Integer.toHexString(dObj.hashCode()), and making the dObj member variable
a WeakReference.  None of that helped.

Then, just to make sure, I short-circuited all the calls to
GrammarManager.getGrammar().  Still no luck.  So, perhaps it's not the
completion code.

Perhaps something in the TAX representation is holding a reference to the
FileInputStream?

Anyone got any other ideas?

Rich