#fixed code
                              @Override
  public int send(final Criteria recipientCriteria, final Message message,
      AsyncCallback callbackOnReply)
  {

    Map<InstanceType, List<Message>> generateMessage = generateMessage(
        recipientCriteria, message);
    int totalMessageCount = 0;
    String correlationId = null;
    if (callbackOnReply != null)
    {
      correlationId = UUID.randomUUID().toString();
      for (List<Message> messages : generateMessage.values())
      {
        totalMessageCount += messages.size();
        callbackOnReply.setMessagesSent(messages);
      }
      _asyncCallbackService.registerAsyncCallback(correlationId, callbackOnReply);
    }

    for (InstanceType receiverType : generateMessage.keySet())
    {
      List<Message> list = generateMessage.get(receiverType);
      for (Message tempMessage : list)
      {
        if(correlationId != null)
        {
          tempMessage.setCorrelationId(correlationId);
        }
        if (receiverType == InstanceType.CONTROLLER)
        {
          _manager.getDataAccessor().setControllerProperty(ControllerPropertyType.MESSAGES,
              tempMessage.getRecord(), CreateMode.PERSISTENT);
        }
        if (receiverType == InstanceType.PARTICIPANT)
        {
          _manager.getDataAccessor().setInstanceProperty(message.getTgtName(),
              InstancePropertyType.MESSAGES, tempMessage.getId(),
              tempMessage.getRecord());
        }
      }
    }
    return totalMessageCount;
  }
#vulnerable code 
                              @Override
  public int send(final Criteria recipientCriteria, final Message message,
      AsyncCallback callbackOnReply)
  {

    Map<InstanceType, List<Message>> generateMessage = generateMessage(
        recipientCriteria, message);
    int totalMessageCount = 0;
    String correlationId = null;
    if (callbackOnReply != null)
    {
      correlationId = UUID.randomUUID().toString();
      for (List<Message> messages : generateMessage.values())
      {
        totalMessageCount += messages.size();
        callbackOnReply.setMessagesSent(messages);
      }
      _asyncCallbackService.registerAsyncCallback(correlationId, callbackOnReply);
    }

    for (InstanceType receiverType : generateMessage.keySet())
    {
      List<Message> list = generateMessage.get(receiverType);
      for (Message tempMessage : list)
      {
        tempMessage.setId(UUID.randomUUID().toString());
        if(correlationId != null)
        {
          tempMessage.setCorrelationId(correlationId);
        }
        if (receiverType == InstanceType.CONTROLLER)
        {
          _dataAccessor.setControllerProperty(ControllerPropertyType.MESSAGES,
              tempMessage.getRecord(), CreateMode.PERSISTENT);
        }
        if (receiverType == InstanceType.PARTICIPANT)
        {
          _dataAccessor.setInstanceProperty(message.getTgtName(),
              InstancePropertyType.MESSAGES, tempMessage.getId(),
              tempMessage.getRecord());
        }
      }
    }
    return totalMessageCount;
  } 
                            #location 26 
                            #vulnerability type THREAD_SAFETY_VIOLATION