#vulnerable code 
                                void notifyCallEnded(String callResource)
    {
        GatewaySession session;

        synchronized (sessions)
        {
            session = sessions.remove(callResource);

            if (session == null)
            {
                // FIXME: print some gateway ID or provider here
                logger.error(
                    "Call resource not exists for session " + callResource);
                return;
            }
        }

        logger.info("Removed session for call " + callResource);

        if (callsControl != null)
        {
            callsControl.callEnded(this, session.getCallResource());
        }
    } 
                            #location 22 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                void notifyCallEnded(String callResource)
    {
        GatewaySession session;

        synchronized (sessions)
        {
            session = sessions.remove(callResource);

            if (session == null)
            {
                // FIXME: print some gateway ID or provider here
                logger.error(
                    "Call resource not exists for session " + callResource);
                return;
            }
        }

        logger.info("Removed session for call " + callResource);
    }