Program: 74353
Project: 74353
Buggy source:
/** 
 * If the attributeName is "class" and attributeValue names a class that has had its port names changed between releases, then substitute in the new port names.
 * @param container  The container for this attribute.in this method.
 * @param element The XML element name.
 * @param attributeName The name of the attribute.
 * @param attributeValue The value of the attribute.
 * @return the value of the attributeValue argument.
 */
public String filterAttributeValue(NamedObj container,String element,String attributeName,String attributeValue){
  if (attributeValue == null) {
    return null;
  }
  if (attributeName.equals("String_Node_Str")) {
    _lastNameSeen=attributeValue;
    if (_currentlyProcessingActorWithPortNameChanges && (_portMap != null) && _portMap.containsKey(attributeValue)) {
      String containerName=container.getFullName();
      String newPort=(String)_portMap.get(attributeValue);
      _containerPortMap.put(containerName + "String_Node_Str" + attributeValue,containerName + "String_Node_Str" + newPort);
      MoMLParser.setModified(true);
      return newPort;
    }
  }
  if (attributeName.equals("String_Node_Str")) {
    if (_actorsWithPortNameChanges.containsKey(attributeValue)) {
      _currentlyProcessingActorWithPortNameChanges=true;
      _doneProcessingActorWithPortNameChanges=false;
      _currentActorFullName=container.getFullName() + "String_Node_Str" + _lastNameSeen;
      _portMap=(HashMap)_actorsWithPortNameChanges.get(attributeValue);
    }
 else     if (_currentlyProcessingActorWithPortNameChanges && (container != null) && !container.getFullName().equals(_currentActorFullName)&& !container.getFullName().startsWith(_currentActorFullName)) {
      _currentlyProcessingActorWithPortNameChanges=false;
      _doneProcessingActorWithPortNameChanges=true;
    }
  }
 else   if (_doneProcessingActorWithPortNameChanges && attributeName.equals("String_Node_Str") && _containerPortMap.containsKey(container.getFullName() + "String_Node_Str" + attributeValue)) {
    String newPort=(String)_containerPortMap.get(container.getFullName() + "String_Node_Str" + attributeValue);
    newPort=newPort.substring(container.getFullName().length() + 1);
    MoMLParser.setModified(true);
    return newPort;
  }
 else   if (_doneProcessingActorWithPortNameChanges && attributeName.equals("String_Node_Str")) {
    int lastIndex=attributeValue.lastIndexOf("String_Node_Str");
    NamedObj portContainer=null;
    String portContainerName=null;
    String portName=null;
    if (lastIndex > 0) {
      portContainerName=attributeValue.substring(0,lastIndex);
      portContainer=((CompositeEntity)container).getEntity(portContainerName);
      portName=attributeValue.substring(lastIndex + 1);
    }
 else {
      portContainer=container;
      portName=attributeValue;
    }
    if (portContainer != null) {
      String className=portContainer.getClassName();
      if (_actorsWithPortNameChanges.containsKey(className)) {
        HashMap portMap=(HashMap)_actorsWithPortNameChanges.get(className);
        if (portMap.containsKey(portName)) {
          String newPort=(String)portMap.get(portName);
          if (lastIndex > 0) {
            newPort=portContainerName + "String_Node_Str" + newPort;
          }
          return newPort;
        }
      }
    }
  }
  return attributeValue;
}

Fixed version (ground truth):
/** 
 * If the attributeName is "class" and attributeValue names a class that has had its port names changed between releases, then substitute in the new port names.
 * @param container  The container for this attribute.in this method.
 * @param element The XML element name.
 * @param attributeName The name of the attribute.
 * @param attributeValue The value of the attribute.
 * @return the value of the attributeValue argument.
 */
public String filterAttributeValue(NamedObj container,String element,String attributeName,String attributeValue){
  if (attributeValue == null) {
    return null;
  }
  if (attributeName.equals("String_Node_Str")) {
    _lastNameSeen=attributeValue;
    if (_currentlyProcessingActorWithPortNameChanges && (_portMap != null) && _portMap.containsKey(attributeValue)) {
      String containerName=container.getFullName();
      String newPort=(String)_portMap.get(attributeValue);
      _containerPortMap.put(containerName + "String_Node_Str" + attributeValue,containerName + "String_Node_Str" + newPort);
      MoMLParser.setModified(true);
      return newPort;
    }
  }
  if (attributeName.equals("String_Node_Str")) {
    if (_actorsWithPortNameChanges.containsKey(attributeValue)) {
      _currentlyProcessingActorWithPortNameChanges=true;
      _doneProcessingActorWithPortNameChanges=false;
      _currentActorFullName=container.getFullName() + "String_Node_Str" + _lastNameSeen;
      _portMap=(HashMap)_actorsWithPortNameChanges.get(attributeValue);
    }
 else     if (_currentlyProcessingActorWithPortNameChanges && (container != null) && !container.getFullName().equals(_currentActorFullName)&& !container.getFullName().startsWith(_currentActorFullName)) {
      _currentlyProcessingActorWithPortNameChanges=false;
      _doneProcessingActorWithPortNameChanges=true;
    }
  }
 else   if (_doneProcessingActorWithPortNameChanges && attributeName.equals("String_Node_Str") && _containerPortMap.containsKey(container.getFullName() + "String_Node_Str" + attributeValue)) {
    String newPort=(String)_containerPortMap.get(container.getFullName() + "String_Node_Str" + attributeValue);
    newPort=newPort.substring(container.getFullName().length() + 1);
    MoMLParser.setModified(true);
    return newPort;
  }
 else   if (_doneProcessingActorWithPortNameChanges && attributeName.equals("String_Node_Str") && container instanceof CompositeEntity) {
    int lastIndex=attributeValue.lastIndexOf("String_Node_Str");
    NamedObj portContainer=null;
    String portContainerName=null;
    String portName=null;
    if (lastIndex > 0) {
      portContainerName=attributeValue.substring(0,lastIndex);
      portContainer=((CompositeEntity)container).getEntity(portContainerName);
      portName=attributeValue.substring(lastIndex + 1);
    }
 else {
      portContainer=container;
      portName=attributeValue;
    }
    if (portContainer != null) {
      String className=portContainer.getClassName();
      if (_actorsWithPortNameChanges.containsKey(className)) {
        HashMap portMap=(HashMap)_actorsWithPortNameChanges.get(className);
        if (portMap.containsKey(portName)) {
          String newPort=(String)portMap.get(portName);
          if (lastIndex > 0) {
            newPort=portContainerName + "String_Node_Str" + newPort;
          }
          return newPort;
        }
      }
    }
  }
  return attributeValue;
}