DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6848>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=6848

Document Synchronization problem

           Summary: Document Synchronization problem
           Product: Xerces2-J
           Version: 2.0.0
          Platform: PC
        OS/Version: Other
            Status: NEW
          Severity: Critical
          Priority: Other
         Component: DOM
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]


hi all;
i have a small piece of code i would like you to see. it acts strange and i am loosing 
it. please take a 
look at it(its small).
i am working with the new xalan package(2.2) and have the xalan.jar, xerces.jar and 
xml-api.jar on my 
class path.


myClass{
        
        public Document dom;

        myClass(){
                DocumentBuilderFactory docBuilderFactory = 
DocumentBuilderFactory.newInstance();
                DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
                dom = docBuilder.parse(new 
File("c:\\temp\\mvm\\MyTestResourceGroup.xml"));
        }
        myMethod(){
                NodeList nl = dom.getElementsByTagName("resourceSet");//the xml file 
contains 3 
resourceSet elements
                int len = nl.getLength();
                 for(int index=0;index<len;index++){
                        Element resourceSet = (Element)nl.item(index);
                         if(!resourceSet.hasAttribute("service")){//each resourceSet 
element 
contains a service attribute(and ohter attrs to)
                                        
System.out.println("ERROR$$$$$$$$$$$$$$$$$$$$$$");
                        }
                }
        }
}

there are many threads that access an instance of this class at the same time calling 
myMethod().
sometimes the code runs ok, some times some thread fail and print the error 
message(even though all 
resourceSet elements do contain the service attribute) 
other times i get null pointers (see below).

am i missing something here? i look at the api and i found nothing about the thread 
safety of NodeList.
please help i cant seem to get whats the matter here.

an example outputs of a test program: 
1. with 20 threads running
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
ERROR$$$$$$$$$$$$$$$$$$$$$$
2. with 20 threads running:
java.lang.NullPointerException
        at org.apache.xerces.dom.DeepNodeListImpl.nextMatchingElementAfter(DeepN
odeListImpl.java:235)
        at org.apache.xerces.dom.DeepNodeListImpl.item(DeepNodeListImpl.java:182
)
        at org.apache.xerces.dom.DeepNodeListImpl.getLength(DeepNodeListImpl.jav
a:153)
        at XmlTest.doTest(XmlTest.java:87)
        at XmlTest$1.run(XmlTest.java:69)
        at java.lang.Thread.run(Thread.java:484)



3. 20 threads
java.lang.NullPointerException
        at org.apache.xerces.dom.DeferredDocumentImpl.clearChunkValue(DeferredDo
cumentImpl.java:1851)
        at org.apache.xerces.dom.DeferredDocumentImpl.getNodeName(DeferredDocume
ntImpl.java:990)
        at org.apache.xerces.dom.DeferredDocumentImpl.getNodeName(DeferredDocume
ntImpl.java:975)
        at org.apache.xerces.dom.DeferredAttrImpl.synchronizeData(DeferredAttrIm
pl.java:161)
        at org.apache.xerces.dom.AttrImpl.getNodeName(AttrImpl.java:267)
        at org.apache.xerces.dom.AttributeMap.setNamedItem(AttributeMap.java:134
)
        at org.apache.xerces.dom.DeferredElementImpl.synchronizeData(DeferredEle
mentImpl.java:161)
        at org.apache.xerces.dom.ElementImpl.getTagName(ElementImpl.java:273)
        at org.apache.xerces.dom.DeepNodeListImpl.nextMatchingElementAfter(DeepN
odeListImpl.java:235)
        at org.apache.xerces.dom.DeepNodeListImpl.item(DeepNodeListImpl.java:182
)
        at org.apache.xerces.dom.DeepNodeListImpl.getLength(DeepNodeListImpl.jav
a:153)
        at XmlTest.doTest(XmlTest.java:87)
        at XmlTest$1.run(XmlTest.java:69)
        at java.lang.Thread.run(Thread.java:484)
__________________
Guy Katz
Comverse
[EMAIL PROTECTED]
+972 3 7663686

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to