Program: 62129
Project: 62129
Buggy source:
@Override protected void processNodeOperation(Csar csar,Topology topology,AddRelationshipOperation operation,NodeTemplate sourceNode){
  if (operation.getRelationshipName() == null || operation.getRelationshipName().isEmpty()) {
    throw new InvalidNameException("String_Node_Str",operation.getRelationshipName(),"String_Node_Str");
  }
  if (AlienUtils.safe(sourceNode.getRelationships()).containsKey(operation.getRelationshipName())) {
    throw new AlreadyExistException("String_Node_Str" + operation.getRelationshipName() + "String_Node_Str"+ operation.getNodeName());
  }
  if (sourceNode.getRequirements() == null || sourceNode.getRequirements().get(operation.getRequirementName()) == null) {
    throw new NotFoundException("String_Node_Str" + operation.getRequirementName() + "String_Node_Str"+ operation.getNodeName());
  }
  Map<String,NodeTemplate> nodeTemplates=TopologyUtils.getNodeTemplates(topology);
  TopologyUtils.getNodeTemplate(topology.getId(),operation.getTarget(),nodeTemplates);
  RelationshipType indexedRelationshipType=toscaTypeSearchService.find(RelationshipType.class,operation.getRelationshipType(),operation.getRelationshipVersion());
  if (indexedRelationshipType == null) {
    throw new NotFoundException(RelationshipType.class.getName(),operation.getRelationshipType() + "String_Node_Str" + operation.getRelationshipVersion(),"String_Node_Str");
  }
  boolean upperBoundReachedSource=topologyRequirementBoundsValidationServices.isRequirementUpperBoundReachedForSource(sourceNode,operation.getRequirementName(),topology.getDependencies());
  if (upperBoundReachedSource) {
    throw new RequirementBoundException(operation.getNodeName(),operation.getRequirementName());
  }
  boolean upperBoundReachedTarget=topologyCapabilityBoundsValidationServices.isCapabilityUpperBoundReachedForTarget(operation.getTarget(),nodeTemplates,operation.getTargetedCapabilityName(),topology.getDependencies());
  if (upperBoundReachedTarget) {
    throw new CapabilityBoundException(operation.getTarget(),operation.getTargetedCapabilityName());
  }
  topologyService.loadType(topology,indexedRelationshipType);
  Map<String,RelationshipTemplate> relationships=sourceNode.getRelationships();
  if (relationships == null) {
    relationships=Maps.newHashMap();
    sourceNode.setRelationships(relationships);
  }
  RelationshipTemplate relationshipTemplate=new RelationshipTemplate();
  relationshipTemplate.setName(operation.getRelationshipName());
  relationshipTemplate.setTarget(operation.getTarget());
  relationshipTemplate.setTargetedCapabilityName(operation.getTargetedCapabilityName());
  relationshipTemplate.setRequirementName(operation.getRequirementName());
  relationshipTemplate.setRequirementType(sourceNode.getRequirements().get(operation.getRequirementName()).getType());
  relationshipTemplate.setType(indexedRelationshipType.getElementId());
  relationshipTemplate.setArtifacts(newLinkedHashMap(indexedRelationshipType.getArtifacts()));
  relationshipTemplate.setAttributes(newLinkedHashMap(indexedRelationshipType.getAttributes()));
  Map<String,AbstractPropertyValue> properties=new LinkedHashMap<String,AbstractPropertyValue>();
  TemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),null);
  relationshipTemplate.setProperties(properties);
  relationships.put(operation.getRelationshipName(),relationshipTemplate);
  TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology,csar);
  workflowBuilderService.addRelationship(topologyContext,operation.getNodeName(),operation.getRelationshipName());
  log.debug("String_Node_Str" + topology.getId() + "String_Node_Str"+ operation.getNodeName()+ "String_Node_Str"+ operation.getRelationshipName()+ "String_Node_Str");
}

Fixed version (ground truth):
@Override protected void processNodeOperation(Csar csar,Topology topology,AddRelationshipOperation operation,NodeTemplate sourceNode){
  if (operation.getRelationshipName() == null || operation.getRelationshipName().isEmpty()) {
    throw new InvalidNameException("String_Node_Str",operation.getRelationshipName(),"String_Node_Str");
  }
  if (AlienUtils.safe(sourceNode.getRelationships()).containsKey(operation.getRelationshipName())) {
    throw new AlreadyExistException("String_Node_Str" + operation.getRelationshipName() + "String_Node_Str"+ operation.getNodeName());
  }
  if (sourceNode.getRequirements() == null || sourceNode.getRequirements().get(operation.getRequirementName()) == null) {
    throw new NotFoundException("String_Node_Str" + operation.getRequirementName() + "String_Node_Str"+ operation.getNodeName());
  }
  Map<String,NodeTemplate> nodeTemplates=TopologyUtils.getNodeTemplates(topology);
  TopologyUtils.getNodeTemplate(topology.getId(),operation.getTarget(),nodeTemplates);
  RelationshipType indexedRelationshipType=toscaTypeSearchService.find(RelationshipType.class,operation.getRelationshipType(),operation.getRelationshipVersion());
  if (indexedRelationshipType == null) {
    throw new NotFoundException(RelationshipType.class.getName(),operation.getRelationshipType() + "String_Node_Str" + operation.getRelationshipVersion(),"String_Node_Str");
  }
  boolean upperBoundReachedSource=topologyRequirementBoundsValidationServices.isRequirementUpperBoundReachedForSource(sourceNode,operation.getRequirementName(),topology.getDependencies());
  if (upperBoundReachedSource) {
    throw new RequirementBoundException(operation.getNodeName(),operation.getRequirementName());
  }
  boolean upperBoundReachedTarget=topologyCapabilityBoundsValidationServices.isCapabilityUpperBoundReachedForTarget(operation.getTarget(),nodeTemplates,operation.getTargetedCapabilityName(),topology.getDependencies());
  if (upperBoundReachedTarget) {
    throw new CapabilityBoundException(operation.getTarget(),operation.getTargetedCapabilityName());
  }
  topologyService.loadType(topology,indexedRelationshipType);
  NodeTemplate newSourceNode=topology.getNodeTemplates().get(sourceNode.getName());
  if (sourceNode != newSourceNode) {
    sourceNode=newSourceNode;
  }
  Map<String,RelationshipTemplate> relationships=sourceNode.getRelationships();
  if (relationships == null) {
    relationships=Maps.newHashMap();
    sourceNode.setRelationships(relationships);
  }
  RelationshipTemplate relationshipTemplate=new RelationshipTemplate();
  relationshipTemplate.setName(operation.getRelationshipName());
  relationshipTemplate.setTarget(operation.getTarget());
  relationshipTemplate.setTargetedCapabilityName(operation.getTargetedCapabilityName());
  relationshipTemplate.setRequirementName(operation.getRequirementName());
  relationshipTemplate.setRequirementType(sourceNode.getRequirements().get(operation.getRequirementName()).getType());
  relationshipTemplate.setType(indexedRelationshipType.getElementId());
  relationshipTemplate.setArtifacts(newLinkedHashMap(indexedRelationshipType.getArtifacts()));
  relationshipTemplate.setAttributes(newLinkedHashMap(indexedRelationshipType.getAttributes()));
  Map<String,AbstractPropertyValue> properties=new LinkedHashMap<String,AbstractPropertyValue>();
  TemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),null);
  relationshipTemplate.setProperties(properties);
  relationships.put(operation.getRelationshipName(),relationshipTemplate);
  TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology,csar);
  workflowBuilderService.addRelationship(topologyContext,operation.getNodeName(),operation.getRelationshipName());
  log.debug("String_Node_Str" + topology.getId() + "String_Node_Str"+ operation.getNodeName()+ "String_Node_Str"+ operation.getRelationshipName()+ "String_Node_Str");
}