Program: 40968
Project: 40968
Buggy source:
/** 
 * Executes the connectTo operation on the given connectToNode NodeTemplate, the parameters for the operation will be searched starting from the given parametersRootNode Node Template E.g.: For a MQTT Client to connect to a MQTT topic it uses the properties from the topology stack given by the topic itself. These properties are then mapped to the parameters of the MQTT client connectTo operation.
 * @param templateContext the context of this operation call
 * @param connectToNode a Node Template with a connectTo operation
 * @param parametersRootNode a Node Template, which should be used as thestarting node for parameter search
 */
private boolean executeConnectsTo(final TemplatePlanContext templateContext,final AbstractNodeTemplate connectToNode,final AbstractNodeTemplate parametersRootNode){
  AbstractInterface connectsToIface=null;
  AbstractOperation connectsToOp=null;
  for (  final AbstractInterface iface : connectToNode.getType().getInterfaces()) {
    for (    final AbstractOperation op : iface.getOperations()) {
      if (op.getName().equals("String_Node_Str")) {
        connectsToIface=iface;
        connectsToOp=op;
        break;
      }
    }
    if (connectsToOp != null) {
      break;
    }
  }
  final Map<AbstractParameter,Variable> param2propertyMapping=new HashMap<>();
  for (  final AbstractParameter param : connectsToOp.getInputParameters()) {
    boolean ambiParam=false;
    Variable var=templateContext.getPropertyVariable(templateContext.getRelationshipTemplate(),param.getName());
    if (var != null) {
      param2propertyMapping.put(param,var);
    }
    if (org.opentosca.container.core.tosca.convention.Utils.isSupportedVirtualMachineIPProperty(param.getName())) {
      ambiParam=true;
    }
    if (!ambiParam) {
      AbstractNodeTemplate currentNode=parametersRootNode;
      while (currentNode != null) {
        final Variable property=templateContext.getPropertyVariable(currentNode,param.getName());
        if (property != null) {
          param2propertyMapping.put(param,property);
          break;
        }
 else {
          currentNode=this.fetchNodeConnectedWithHostedOn(currentNode);
        }
      }
    }
 else {
      for (      final String paramName : org.opentosca.container.core.tosca.convention.Utils.getSupportedVirtualMachineIPPropertyNames()) {
        boolean found=false;
        AbstractNodeTemplate currentNode=parametersRootNode;
        while (currentNode != null) {
          final Variable property=templateContext.getPropertyVariable(currentNode,paramName);
          if (property != null) {
            param2propertyMapping.put(param,property);
            found=true;
            break;
          }
 else {
            currentNode=this.fetchNodeConnectedWithHostedOn(currentNode);
          }
        }
        if (found) {
          break;
        }
      }
    }
  }
  if (param2propertyMapping.size() != connectsToOp.getInputParameters().size()) {
    Handler.LOG.error("String_Node_Str");
    return false;
  }
  for (  final AbstractNodeTypeImplementation nodeImpl : connectToNode.getImplementations()) {
    for (    final AbstractImplementationArtifact ia : nodeImpl.getImplementationArtifacts()) {
      if (ia.getInterfaceName().equals(connectsToIface.getName()) && (ia.getOperationName() != null) && ia.getOperationName().equals(connectsToOp.getName())) {
        templateContext.executeOperation(connectToNode,connectsToIface.getName(),connectsToOp.getName(),param2propertyMapping);
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * Executes the connectTo operation on the given connectToNode NodeTemplate, the parameters for the operation will be searched starting from the given parametersRootNode Node Template E.g.: For a MQTT Client to connect to a MQTT topic it uses the properties from the topology stack given by the topic itself. These properties are then mapped to the parameters of the MQTT client connectTo operation.
 * @param templateContext the context of this operation call
 * @param connectToNode a Node Template with a connectTo operation
 * @param parametersRootNode a Node Template, which should be used as thestarting node for parameter search
 */
private boolean executeConnectsTo(final TemplatePlanContext templateContext,final AbstractNodeTemplate connectToNode,final AbstractNodeTemplate parametersRootNode){
  AbstractInterface connectsToIface=null;
  AbstractOperation connectsToOp=null;
  for (  final AbstractInterface iface : connectToNode.getType().getInterfaces()) {
    for (    final AbstractOperation op : iface.getOperations()) {
      if (op.getName().equals("String_Node_Str")) {
        connectsToIface=iface;
        connectsToOp=op;
        break;
      }
    }
    if (connectsToOp != null) {
      break;
    }
  }
  final Map<AbstractParameter,Variable> param2propertyMapping=new HashMap<>();
  for (  final AbstractParameter param : connectsToOp.getInputParameters()) {
    boolean ambiParam=false;
    Variable var=templateContext.getPropertyVariable(templateContext.getRelationshipTemplate(),param.getName());
    if (var != null) {
      param2propertyMapping.put(param,var);
    }
    if (org.opentosca.container.core.tosca.convention.Utils.isSupportedVirtualMachineIPProperty(param.getName())) {
      ambiParam=true;
    }
    if (!ambiParam) {
      AbstractNodeTemplate currentNode=parametersRootNode;
      while (currentNode != null) {
        final Variable property=templateContext.getPropertyVariable(currentNode,param.getName());
        if (property != null) {
          param2propertyMapping.put(param,property);
          break;
        }
 else {
          currentNode=this.fetchNodeConnectedWithHostedOn(currentNode);
        }
      }
    }
 else {
      for (      final String paramName : org.opentosca.container.core.tosca.convention.Utils.getSupportedVirtualMachineIPPropertyNames()) {
        boolean found=false;
        AbstractNodeTemplate currentNode=parametersRootNode;
        while (currentNode != null) {
          final Variable property=templateContext.getPropertyVariable(currentNode,paramName);
          if (property != null) {
            param2propertyMapping.put(param,property);
            found=true;
            break;
          }
 else {
            currentNode=this.fetchNodeConnectedWithHostedOn(currentNode);
          }
        }
        if (found) {
          break;
        }
      }
    }
  }
  if (param2propertyMapping.size() != connectsToOp.getInputParameters().size()) {
    Handler.LOG.error("String_Node_Str");
    return false;
  }
  templateContext.executeOperation(connectToNode,connectsToIface.getName(),connectsToOp.getName(),param2propertyMapping);
  return true;
}