#vulnerable code 
                                public boolean hasRequestListeners(TransportAddress localAddr)
    {
        synchronized(requestListeners)
        {
            if(!requestListeners.isEmpty())
            {
                // there is a generic listener
                return true;
            }
        }

        synchronized(requestListenersChildren)
        {
            if (requestListenersChildren != null)
            {
                EventDispatcher child = requestListenersChildren.get(localAddr);
                if (child != null && child.requestListeners != null)
                {
                    return !child.requestListeners.isEmpty();
                }
            }
        }

        return false;
    } 
                            #location 12 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public boolean hasRequestListeners(TransportAddress localAddr)
    {
        synchronized(requestListeners)
        {
            if(!requestListeners.isEmpty())
            {
                // there is a generic listener
                return true;
            }
        }

        synchronized(requestListenersChildren)
        {
            if (!requestListenersChildren.isEmpty())
            {
                EventDispatcher child = requestListenersChildren.get(localAddr);
                if (child != null && child.requestListeners != null)
                {
                    return !child.requestListeners.isEmpty();
                }
            }
        }

        return false;
    }