Program: 62247
Project: 62247
Buggy source:
@Override protected void processNodeOperation(AddRelationshipOperation operation,NodeTemplate sourceNode){
  if (operation.getRelationshipName() == null || operation.getRelationshipName().isEmpty()) {
    throw new InvalidNameException("String_Node_Str",operation.getRelationshipName(),"String_Node_Str");
  }
  if (sourceNode.getRequirements() == null || sourceNode.getRequirements().get(operation.getRequirementName()) == null) {
    throw new NotFoundException("String_Node_Str" + operation.getRequirementName() + "String_Node_Str"+ operation.getNodeName());
  }
  Topology topology=EditionContextManager.getTopology();
  Set<CSARDependency> oldDependencies=topology.getDependencies();
  Map<String,NodeTemplate> nodeTemplates=TopologyServiceCore.getNodeTemplates(topology);
  TopologyServiceCore.getNodeTemplate(topology.getId(),operation.getTarget(),nodeTemplates);
  RelationshipType indexedRelationshipType=searchService.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);
  }
  if (relationships.containsKey(operation.getRelationshipName())) {
    throw new AlreadyExistException("String_Node_Str" + operation.getRelationshipName() + "String_Node_Str"+ operation.getNodeName());
  }
  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>();
  NodeTemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),null);
  relationshipTemplate.setProperties(properties);
  relationships.put(operation.getRelationshipName(),relationshipTemplate);
  WorkflowsBuilderService.TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology);
  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");
  if (!Objects.equals(topology.getDependencies(),oldDependencies)) {
    csarService.setDependencies(topology.getId(),topology.getDependencies());
  }
}

Fixed version (ground truth):
@Override protected void processNodeOperation(AddRelationshipOperation operation,NodeTemplate sourceNode){
  if (operation.getRelationshipName() == null || operation.getRelationshipName().isEmpty()) {
    throw new InvalidNameException("String_Node_Str",operation.getRelationshipName(),"String_Node_Str");
  }
  if (sourceNode.getRequirements() == null || sourceNode.getRequirements().get(operation.getRequirementName()) == null) {
    throw new NotFoundException("String_Node_Str" + operation.getRequirementName() + "String_Node_Str"+ operation.getNodeName());
  }
  Topology topology=EditionContextManager.getTopology();
  Map<String,NodeTemplate> nodeTemplates=TopologyServiceCore.getNodeTemplates(topology);
  TopologyServiceCore.getNodeTemplate(topology.getId(),operation.getTarget(),nodeTemplates);
  RelationshipType indexedRelationshipType=searchService.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);
  }
  if (relationships.containsKey(operation.getRelationshipName())) {
    throw new AlreadyExistException("String_Node_Str" + operation.getRelationshipName() + "String_Node_Str"+ operation.getNodeName());
  }
  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>();
  NodeTemplateBuilder.fillProperties(properties,indexedRelationshipType.getProperties(),null);
  relationshipTemplate.setProperties(properties);
  relationships.put(operation.getRelationshipName(),relationshipTemplate);
  WorkflowsBuilderService.TopologyContext topologyContext=workflowBuilderService.buildTopologyContext(topology);
  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");
}