Program: 40955
Project: 40955
Buggy source:
/** 
 * {@inheritDoc}
 * @throws UnsupportedEncodingException
 */
@Override public String invokePlan(final CSARID csarID,final QName serviceTemplateId,int serviceTemplateInstanceID,final TPlanDTO givenPlan) throws UnsupportedEncodingException {
  final TPlan storedPlan=ServiceProxy.toscaReferenceMapper.getPlanForCSARIDAndPlanID(csarID,givenPlan.getId());
  if ((null == storedPlan)) {
    this.LOG.error("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getName()+ "String_Node_Str");
    return null;
  }
  if (!storedPlan.getId().equals(givenPlan.getId().getLocalPart())) {
    this.LOG.error("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getName()+ "String_Node_Str"+ storedPlan.getId()+ "String_Node_Str");
    return null;
  }
  givenPlan.setName(storedPlan.getName());
  givenPlan.setPlanLanguage(storedPlan.getPlanLanguage());
  givenPlan.setPlanType(storedPlan.getPlanType());
  givenPlan.setOutputParameters(storedPlan.getOutputParameters());
  final PlanInvocationEvent planEvent=new PlanInvocationEvent();
  this.LOG.info("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getPlanType()+ "String_Node_Str"+ csarID+ "String_Node_Str");
  final Map<QName,TPlan> publicPlanMap=ServiceProxy.toscaReferenceMapper.getCSARIDToPlans(csarID).get(PlanTypes.isPlanTypeURI(givenPlan.getPlanType()));
  if (null == publicPlanMap) {
    this.LOG.error("String_Node_Str" + givenPlan.getPlanType() + "String_Node_Str");
    return null;
  }
  planEvent.setCSARID(csarID.toString());
  planEvent.setInputMessageID(ServiceProxy.toscaReferenceMapper.getPlanInputMessageID(csarID,givenPlan.getId()));
  planEvent.setInterfaceName(ServiceProxy.toscaReferenceMapper.getIntferaceNameOfPlan(csarID,givenPlan.getId()));
  planEvent.setOperationName(ServiceProxy.toscaReferenceMapper.getOperationNameOfPlan(csarID,givenPlan.getId()));
  planEvent.setPlanLanguage(storedPlan.getPlanLanguage());
  planEvent.setPlanType(storedPlan.getPlanType());
  planEvent.setPlanID(givenPlan.getId());
  planEvent.setIsActive(true);
  planEvent.setHasFailed(false);
  for (  final TParameter temp : storedPlan.getInputParameters().getInputParameter()) {
    boolean found=false;
    this.LOG.trace("String_Node_Str",temp.getName());
    final List<TParameterDTO> params=givenPlan.getInputParameters().getInputParameter();
    for (    final TParameterDTO param : params) {
      if (param.getName().equals(temp.getName())) {
        final TParameterDTO dto=param;
        found=true;
        planEvent.getInputParameter().add(dto);
        String value=dto.getValue();
        if (value == null) {
          value="String_Node_Str";
        }
        value=value.replace("String_Node_Str","String_Node_Str");
        value=value.replace("String_Node_Str","String_Node_Str");
        value=value.replace("String_Node_Str","String_Node_Str");
        dto.setValue(value);
        this.LOG.trace("String_Node_Str",param.getName(),param.getValue());
      }
    }
    if (!found) {
      this.LOG.trace("String_Node_Str",temp.getName());
      final TParameterDTO newParam=new TParameterDTO();
      newParam.setName(temp.getName());
      newParam.setType(temp.getType());
      newParam.setRequired(temp.getRequired());
      planEvent.getInputParameter().add(newParam);
    }
  }
  for (  final TParameter temp : storedPlan.getOutputParameters().getOutputParameter()) {
    final TParameterDTO param=new TParameterDTO();
    param.setName(temp.getName());
    param.setRequired(temp.getRequired());
    param.setType(temp.getType());
    planEvent.getOutputParameter().add(param);
  }
  String correlationID;
  if (serviceTemplateInstanceID == -1) {
    serviceTemplateInstanceID=1000 + (int)(Math.random() * (Integer.MAX_VALUE - 1000));
    correlationID=ServiceProxy.correlationHandler.getNewCorrelationID(csarID,serviceTemplateId,serviceTemplateInstanceID,planEvent,true);
  }
 else {
    correlationID=ServiceProxy.correlationHandler.getNewCorrelationID(csarID,serviceTemplateId,serviceTemplateInstanceID,planEvent,false);
  }
  ServiceTemplateInstanceID instanceID;
  if (PlanTypes.isPlanTypeURI(planEvent.getPlanType()).equals(PlanTypes.BUILD)) {
    instanceID=ServiceProxy.csarInstanceManagement.createNewInstance(csarID,serviceTemplateId);
    planEvent.setCSARInstanceID(instanceID.getInstanceID());
  }
 else {
    instanceID=new ServiceTemplateInstanceID(csarID,serviceTemplateId,serviceTemplateInstanceID);
  }
  ServiceProxy.csarInstanceManagement.correlateCSARInstanceWithPlanInstance(instanceID,correlationID);
  ServiceProxy.csarInstanceManagement.setCorrelationAsActive(csarID,correlationID);
  ServiceProxy.csarInstanceManagement.correlateCorrelationIdToPlan(correlationID,planEvent);
  final Map<String,Object> eventValues=new Hashtable<>();
  eventValues.put("String_Node_Str",csarID);
  eventValues.put("String_Node_Str",planEvent.getPlanID());
  eventValues.put("String_Node_Str",planEvent.getPlanLanguage());
  eventValues.put("String_Node_Str",planEvent.getOperationName());
  this.LOG.debug("String_Node_Str",givenPlan.getId());
  final Map<String,String> message=this.createRequest(csarID,serviceTemplateId,ServiceProxy.toscaReferenceMapper.getPlanInputMessageID(csarID,givenPlan.getId()),planEvent.getInputParameter(),correlationID);
  if (null == message) {
    this.LOG.error("String_Node_Str",givenPlan.getId(),givenPlan.getPlanLanguage());
    return null;
  }
  final StringBuilder builder=new StringBuilder("String_Node_Str");
  for (  final String key : message.keySet()) {
    builder.append("String_Node_Str" + key + "String_Node_Str"+ message.get(key)+ "String_Node_Str");
  }
  this.LOG.trace(builder.toString());
  eventValues.put("String_Node_Str",message);
  if (null == ServiceProxy.toscaReferenceMapper.isPlanAsynchronous(csarID,givenPlan.getId())) {
    this.LOG.warn("String_Node_Str");
    eventValues.put("String_Node_Str",true);
  }
 else   if (ServiceProxy.toscaReferenceMapper.isPlanAsynchronous(csarID,givenPlan.getId())) {
    eventValues.put("String_Node_Str",true);
  }
 else {
    eventValues.put("String_Node_Str",false);
  }
  eventValues.put("String_Node_Str",correlationID);
  ServiceProxy.csarInstanceManagement.storePublicPlanToHistory(correlationID,planEvent);
  PlanInstanceRepository repository=new PlanInstanceRepository();
  PlanInstance pi=new PlanInstance();
  pi.setCorrelationId(correlationID);
  LOG.debug("String_Node_Str",storedPlan.getPlanLanguage());
  pi.setLanguage(PlanLanguage.fromString(storedPlan.getPlanLanguage()));
  LOG.debug("String_Node_Str",storedPlan.getPlanType());
  pi.setType(PlanType.fromString(storedPlan.getPlanType()));
  pi.setState(PlanInstanceState.RUNNING);
  pi.setTemplateId(givenPlan.getId());
  stiRepo.find(Long.valueOf(serviceTemplateInstanceID)).ifPresent(serviceTemplateInstance -> pi.setServiceTemplateInstance(serviceTemplateInstance));
  planEvent.getInputParameter().stream().forEach(p -> {
    new PlanInstanceInput(p.getName(),p.getValue(),p.getType()).setPlanInstance(pi);
  }
);
  repository.add(pi);
  final Event event=new Event("String_Node_Str",eventValues);
  this.LOG.debug("String_Node_Str",correlationID);
  ServiceProxy.eventAdmin.sendEvent(event);
  return correlationID;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 * @throws UnsupportedEncodingException
 */
@Override public String invokePlan(final CSARID csarID,final QName serviceTemplateId,long serviceTemplateInstanceID,final TPlanDTO givenPlan) throws UnsupportedEncodingException {
  final TPlan storedPlan=ServiceProxy.toscaReferenceMapper.getPlanForCSARIDAndPlanID(csarID,givenPlan.getId());
  if ((null == storedPlan)) {
    this.LOG.error("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getName()+ "String_Node_Str");
    return null;
  }
  if (!storedPlan.getId().equals(givenPlan.getId().getLocalPart())) {
    this.LOG.error("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getName()+ "String_Node_Str"+ storedPlan.getId()+ "String_Node_Str");
    return null;
  }
  givenPlan.setName(storedPlan.getName());
  givenPlan.setPlanLanguage(storedPlan.getPlanLanguage());
  givenPlan.setPlanType(storedPlan.getPlanType());
  givenPlan.setOutputParameters(storedPlan.getOutputParameters());
  final PlanInvocationEvent planEvent=new PlanInvocationEvent();
  this.LOG.info("String_Node_Str" + givenPlan.getId() + "String_Node_Str"+ givenPlan.getPlanType()+ "String_Node_Str"+ csarID+ "String_Node_Str");
  final Map<QName,TPlan> publicPlanMap=ServiceProxy.toscaReferenceMapper.getCSARIDToPlans(csarID).get(PlanTypes.isPlanTypeURI(givenPlan.getPlanType()));
  if (null == publicPlanMap) {
    this.LOG.error("String_Node_Str" + givenPlan.getPlanType() + "String_Node_Str");
    return null;
  }
  planEvent.setCSARID(csarID.toString());
  planEvent.setInputMessageID(ServiceProxy.toscaReferenceMapper.getPlanInputMessageID(csarID,givenPlan.getId()));
  planEvent.setInterfaceName(ServiceProxy.toscaReferenceMapper.getIntferaceNameOfPlan(csarID,givenPlan.getId()));
  planEvent.setOperationName(ServiceProxy.toscaReferenceMapper.getOperationNameOfPlan(csarID,givenPlan.getId()));
  planEvent.setPlanLanguage(storedPlan.getPlanLanguage());
  planEvent.setPlanType(storedPlan.getPlanType());
  planEvent.setPlanID(givenPlan.getId());
  planEvent.setIsActive(true);
  planEvent.setHasFailed(false);
  for (  final TParameter temp : storedPlan.getInputParameters().getInputParameter()) {
    boolean found=false;
    this.LOG.trace("String_Node_Str",temp.getName());
    final List<TParameterDTO> params=givenPlan.getInputParameters().getInputParameter();
    for (    final TParameterDTO param : params) {
      if (param.getName().equals(temp.getName())) {
        final TParameterDTO dto=param;
        found=true;
        planEvent.getInputParameter().add(dto);
        String value=dto.getValue();
        if (value == null) {
          value="String_Node_Str";
        }
        value=value.replace("String_Node_Str","String_Node_Str");
        value=value.replace("String_Node_Str","String_Node_Str");
        value=value.replace("String_Node_Str","String_Node_Str");
        dto.setValue(value);
        this.LOG.trace("String_Node_Str",param.getName(),param.getValue());
      }
    }
    if (!found) {
      this.LOG.trace("String_Node_Str",temp.getName());
      final TParameterDTO newParam=new TParameterDTO();
      newParam.setName(temp.getName());
      newParam.setType(temp.getType());
      newParam.setRequired(temp.getRequired());
      planEvent.getInputParameter().add(newParam);
    }
  }
  for (  final TParameter temp : storedPlan.getOutputParameters().getOutputParameter()) {
    final TParameterDTO param=new TParameterDTO();
    param.setName(temp.getName());
    param.setRequired(temp.getRequired());
    param.setType(temp.getType());
    planEvent.getOutputParameter().add(param);
  }
  String correlationID;
  if (serviceTemplateInstanceID == -1) {
    serviceTemplateInstanceID=1000 + (int)(Math.random() * (Integer.MAX_VALUE - 1000));
    correlationID=ServiceProxy.correlationHandler.getNewCorrelationID(csarID,serviceTemplateId,(int)serviceTemplateInstanceID,planEvent,true);
  }
 else {
    correlationID=ServiceProxy.correlationHandler.getNewCorrelationID(csarID,serviceTemplateId,(int)serviceTemplateInstanceID,planEvent,false);
  }
  ServiceTemplateInstanceID instanceID;
  if (PlanTypes.isPlanTypeURI(planEvent.getPlanType()).equals(PlanTypes.BUILD)) {
    instanceID=ServiceProxy.csarInstanceManagement.createNewInstance(csarID,serviceTemplateId);
    planEvent.setCSARInstanceID(instanceID.getInstanceID());
  }
 else {
    instanceID=new ServiceTemplateInstanceID(csarID,serviceTemplateId,(int)serviceTemplateInstanceID);
  }
  ServiceProxy.csarInstanceManagement.correlateCSARInstanceWithPlanInstance(instanceID,correlationID);
  ServiceProxy.csarInstanceManagement.setCorrelationAsActive(csarID,correlationID);
  ServiceProxy.csarInstanceManagement.correlateCorrelationIdToPlan(correlationID,planEvent);
  final Map<String,Object> eventValues=new Hashtable<>();
  eventValues.put("String_Node_Str",csarID);
  eventValues.put("String_Node_Str",planEvent.getPlanID());
  eventValues.put("String_Node_Str",planEvent.getPlanLanguage());
  eventValues.put("String_Node_Str",planEvent.getOperationName());
  this.LOG.debug("String_Node_Str",givenPlan.getId());
  final Map<String,String> message=this.createRequest(csarID,serviceTemplateId,ServiceProxy.toscaReferenceMapper.getPlanInputMessageID(csarID,givenPlan.getId()),planEvent.getInputParameter(),correlationID);
  if (null == message) {
    this.LOG.error("String_Node_Str",givenPlan.getId(),givenPlan.getPlanLanguage());
    return null;
  }
  final StringBuilder builder=new StringBuilder("String_Node_Str");
  for (  final String key : message.keySet()) {
    builder.append("String_Node_Str" + key + "String_Node_Str"+ message.get(key)+ "String_Node_Str");
  }
  this.LOG.trace(builder.toString());
  eventValues.put("String_Node_Str",message);
  if (null == ServiceProxy.toscaReferenceMapper.isPlanAsynchronous(csarID,givenPlan.getId())) {
    this.LOG.warn("String_Node_Str");
    eventValues.put("String_Node_Str",true);
  }
 else   if (ServiceProxy.toscaReferenceMapper.isPlanAsynchronous(csarID,givenPlan.getId())) {
    eventValues.put("String_Node_Str",true);
  }
 else {
    eventValues.put("String_Node_Str",false);
  }
  eventValues.put("String_Node_Str",correlationID);
  ServiceProxy.csarInstanceManagement.storePublicPlanToHistory(correlationID,planEvent);
  PlanInstanceRepository repository=new PlanInstanceRepository();
  PlanInstance pi=new PlanInstance();
  pi.setCorrelationId(correlationID);
  LOG.debug("String_Node_Str",storedPlan.getPlanLanguage());
  pi.setLanguage(PlanLanguage.fromString(storedPlan.getPlanLanguage()));
  LOG.debug("String_Node_Str",storedPlan.getPlanType());
  pi.setType(PlanType.fromString(storedPlan.getPlanType()));
  pi.setState(PlanInstanceState.RUNNING);
  pi.setTemplateId(givenPlan.getId());
  stiRepo.find(serviceTemplateInstanceID).ifPresent(serviceTemplateInstance -> pi.setServiceTemplateInstance(serviceTemplateInstance));
  planEvent.getInputParameter().stream().forEach(p -> {
    new PlanInstanceInput(p.getName(),p.getValue(),p.getType()).setPlanInstance(pi);
  }
);
  repository.add(pi);
  final Event event=new Event("String_Node_Str",eventValues);
  this.LOG.debug("String_Node_Str",correlationID);
  ServiceProxy.eventAdmin.sendEvent(event);
  return correlationID;
}