Program: 74379
Project: 74379
Buggy source:
private boolean _matchPort(Port patternPort,Port hostPort){
  if (patternPort instanceof GTEntity && !((GTEntity)patternPort).match(hostPort)) {
    return false;
  }
  int matchSize=_match.size();
  boolean success=true;
  NamedObj patternContainer=null;
  NamedObj hostContainer=null;
  _match.put(patternPort,hostPort);
  if (!_shallowMatchPort(patternPort,hostPort)) {
    success=false;
  }
  if (success) {
    patternContainer=patternPort.getContainer();
    hostContainer=hostPort.getContainer();
    Object patternObject=_match.get(patternContainer);
    if (patternObject != null && patternObject != hostContainer) {
      success=false;
    }
 else {
      Object hostMatch=_match.getKey(hostContainer);
      if (hostMatch != null && hostMatch != patternContainer) {
        success=false;
      }
    }
  }
  if (success) {
    ObjectList patternList=new ObjectList();
    patternList.add(patternContainer);
    ObjectList hostList=new ObjectList();
    hostList.add(hostContainer);
    Token collapsingToken=_getAttribute(patternContainer.getContainer(),"String_Node_Str",RelationCollapsingAttribute.class);
    boolean collapsing=collapsingToken == null ? RelationCollapsingAttribute.DEFAULT : ((BooleanToken)collapsingToken).booleanValue();
    if (collapsing) {
      _temporaryMatch.put(patternContainer,hostContainer);
      Path patternPath=new Path(patternPort);
      Set<Relation> visitedRelations=new HashSet<Relation>();
      Set<Port> visitedPorts=new HashSet<Port>();
      boolean foundPath=findFirstPath(patternPort,patternPath,visitedRelations,visitedPorts);
      while (foundPath) {
        patternList.add(patternPath.clone());
        foundPath=findNextPath(patternPath,visitedRelations,visitedPorts);
      }
      Path hostPath=new Path(hostPort);
      visitedRelations=new HashSet<Relation>();
      visitedPorts=new HashSet<Port>();
      foundPath=findFirstPath(hostPort,hostPath,visitedRelations,visitedPorts);
      while (foundPath) {
        hostList.add(hostPath.clone());
        foundPath=findNextPath(hostPath,visitedRelations,visitedPorts);
      }
      _temporaryMatch.remove(patternContainer);
    }
 else {
      for (      Object relationObject : patternPort.linkedRelationList()) {
        Relation relation=(Relation)relationObject;
        if (!_ignoreRelation(relation)) {
          patternList.add(relation);
        }
      }
      for (      Object relationObject : hostPort.linkedRelationList()) {
        Relation relation=(Relation)relationObject;
        if (!_ignoreRelation(relation)) {
          hostList.add(relation);
        }
      }
    }
    success=_matchObject(patternList,hostList);
  }
  if (!success) {
    _match.retain(matchSize);
  }
  return success;
}

Fixed version (ground truth):
private boolean _matchPort(Port patternPort,Port hostPort){
  if (patternPort instanceof GTEntity && !((GTEntity)patternPort).match(hostPort)) {
    return false;
  }
  int matchSize=_match.size();
  boolean success=true;
  NamedObj patternContainer=null;
  NamedObj hostContainer=null;
  _match.put(patternPort,hostPort);
  if (!_shallowMatchPort(patternPort,hostPort)) {
    success=false;
  }
  if (success) {
    patternContainer=patternPort.getContainer();
    hostContainer=hostPort.getContainer();
    Object patternObject=_match.get(patternContainer);
    if (patternObject != null && patternObject != hostContainer) {
      success=false;
    }
 else {
      Object hostMatch=_match.getKey(hostContainer);
      if (hostMatch != null && hostMatch != patternContainer) {
        success=false;
      }
    }
  }
  if (success) {
    ObjectList patternList=new ObjectList();
    if (!_ignoreObject(patternContainer)) {
      patternList.add(patternContainer);
    }
    ObjectList hostList=new ObjectList();
    if (!_ignoreObject(hostContainer)) {
      hostList.add(hostContainer);
    }
    Token collapsingToken=_getAttribute(patternContainer.getContainer(),"String_Node_Str",RelationCollapsingAttribute.class);
    boolean collapsing=collapsingToken == null ? RelationCollapsingAttribute.DEFAULT : ((BooleanToken)collapsingToken).booleanValue();
    if (collapsing) {
      _temporaryMatch.put(patternContainer,hostContainer);
      Path patternPath=new Path(patternPort);
      Set<Relation> visitedRelations=new HashSet<Relation>();
      Set<Port> visitedPorts=new HashSet<Port>();
      boolean foundPath=findFirstPath(patternPort,patternPath,visitedRelations,visitedPorts);
      while (foundPath) {
        patternList.add(patternPath.clone());
        foundPath=findNextPath(patternPath,visitedRelations,visitedPorts);
      }
      Path hostPath=new Path(hostPort);
      visitedRelations=new HashSet<Relation>();
      visitedPorts=new HashSet<Port>();
      foundPath=findFirstPath(hostPort,hostPath,visitedRelations,visitedPorts);
      while (foundPath) {
        hostList.add(hostPath.clone());
        foundPath=findNextPath(hostPath,visitedRelations,visitedPorts);
      }
      _temporaryMatch.remove(patternContainer);
    }
 else {
      for (      Object relationObject : patternPort.linkedRelationList()) {
        Relation relation=(Relation)relationObject;
        if (!_ignoreObject(relation) && !_ignoreRelation(relation)) {
          patternList.add(relation);
        }
      }
      for (      Object relationObject : hostPort.linkedRelationList()) {
        Relation relation=(Relation)relationObject;
        if (!_ignoreObject(relation) && !_ignoreRelation(relation)) {
          hostList.add(relation);
        }
      }
    }
    success=_matchObject(patternList,hostList);
  }
  if (!success) {
    _match.retain(matchSize);
  }
  return success;
}