https://issues.apache.org/bugzilla/show_bug.cgi?id=49742

           Summary: NPE in EventListenerList (Concurrency)
           Product: Batik
           Version: 1.7
          Platform: PC
        OS/Version: Windows XP
            Status: NEW
          Severity: minor
          Priority: P2
         Component: SVG DOM
        AssignedTo: [email protected]
        ReportedBy: [email protected]


not repeatable, not clearly reproducable. bug occurs frequently in our Jemmy
application GUI tests.

java.lang.NullPointerException
    at
org.apache.batik.dom.events.EventListenerList.removeListener(EventListenerList.java:88)
    at
org.apache.batik.dom.events.EventSupport.removeEventListenerNS(EventSupport.java:180)
    at
org.apache.batik.dom.AbstractNode.removeEventListenerNS(AbstractNode.java:991)
    at
org.apache.batik.dom.svg.SVGOMDocument.removeCSSNavigableDocumentListener(SVGOMDocument.java:473)
    at
org.apache.batik.css.engine.CSSEngine.removeEventListeners(CSSEngine.java:487)
    at org.apache.batik.css.engine.CSSEngine.dispose(CSSEngine.java:516)
    at
org.apache.batik.bridge.BridgeContext.removeDOMListeners(BridgeContext.java:1291)
    at org.apache.batik.bridge.BridgeContext.dispose(BridgeContext.java:1444)
    at
org.apache.batik.swing.svg.AbstractJSVGComponent.installSVGDocument(AbstractJSVGComponent.java:721)
    at
org.apache.batik.swing.JSVGCanvas.installSVGDocument(JSVGCanvas.java:591)
    at
org.apache.batik.swing.svg.AbstractJSVGComponent$2.run(AbstractJSVGComponent.java:679)


I guess it's because we do call AbstractJSVGComponent's setSVGDocument
frequently. I assume while one call of setSVGDocument still processes its
installSVGDocument, another thread also tries to remove listeners. 

Code in EventListenerList, which causes NPE, is eht "else if" condition:

    else if (head != null
                && (namespaceURI != null &&
namespaceURI.equals(head.namespaceURI)
                    || namespaceURI == null && head.namespaceURI == null)
                && listener == head.listener) {
            head = head.next;
        }

The only reason for NPE that I can figure out is, that the member "head" in
thread A passes the "head != null" condition, then thread B already processes
head=head.next (what may set head = NULL), and then thread A resumes with
accessing head.namecpaceURI or head.listener -> NPE.

What about assigning head to a local variable before entering the IF condition;
and using the local variable for the conditions (and as source for assignment)?

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to