#vulnerable code 
                                public void redirectBothLegs(String context, String exten, int priority) throws ManagerCommunicationException,
            NoSuchChannelException
    {
        ManagerResponse response;

        if (linkedChannel == null)
        {
            response = server.sendAction(new RedirectAction(name, context, exten, priority));
        }
        else
        {
            response = server.sendAction(new RedirectAction(name, linkedChannel.getName(), context, exten, priority,
                    context, exten, priority));
        }

        if (response instanceof ManagerError)
        {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    } 
                            #location 12 
                            #vulnerability type THREAD_SAFETY_VIOLATION
#fixed code
                                public void redirectBothLegs(String context, String exten, int priority) throws ManagerCommunicationException,
            NoSuchChannelException
    {
        ManagerResponse response;

        if (linkedChannels.isEmpty())
        {
            response = server.sendAction(new RedirectAction(name, context, exten, priority));
        }
        else
        {
            response = server.sendAction(new RedirectAction(name, linkedChannels.get(0).getName(), context, exten, priority,
                    context, exten, priority));
        }

        if (response instanceof ManagerError)
        {
            throw new NoSuchChannelException("Channel '" + name + "' is not available: " + response.getMessage());
        }
    }