Program: 74086
Project: 74086
Buggy source:
/** 
 * Determine the direction of dataflow of all edges and store it in the local maps. Iterate all edges and try to deduce the type of each edge's endpoints, i.e. whether it is an source or target. Do this in multiple iterations by first getting clear information from input and output ports and then propagate this information to the adjacent edges. Work only on the local maps, i.e. get the list of all edges of the _ptolemyDiva2KielerEdges map and store the source and target information in _divaEdgeSource resp. _divaEdgeTarget.
 */
private void _storeEndpoints(){
  ActorGraphModel aGraph=(ActorGraphModel)this.getLayoutTarget().getGraphModel();
  boolean allDirectionsSet=false;
  Set edges=_ptolemyDiva2KielerEdges.keySet();
  while (!allDirectionsSet) {
    allDirectionsSet=true;
    for (Iterator edgeIter=edges.iterator(); edgeIter.hasNext(); ) {
      Object edge=(Object)edgeIter.next();
      EdgeModel edgeModel=aGraph.getEdgeModel(edge);
      Object endpoint1=edgeModel.getHead(edge);
      Object endpoint2=edgeModel.getTail(edge);
      if (_divaEdgeTarget.containsKey(edge) && _divaEdgeSource.containsKey(edge))       continue;
      if (endpoint1 instanceof Port) {
        if (PtolemyModelUtil._isInput((Port)endpoint1)) {
          _divaEdgeTarget.put(edge,endpoint1);
          _divaEdgeSource.put(edge,endpoint2);
        }
 else {
          _divaEdgeTarget.put(edge,endpoint2);
          _divaEdgeSource.put(edge,endpoint1);
        }
      }
 else       if (endpoint2 instanceof Port) {
        if (PtolemyModelUtil._isInput((Port)endpoint2)) {
          _divaEdgeTarget.put(edge,endpoint2);
          _divaEdgeSource.put(edge,endpoint1);
        }
 else {
          _divaEdgeTarget.put(edge,endpoint1);
          _divaEdgeSource.put(edge,endpoint2);
        }
      }
 else       if (_divaEdgeTarget.containsValue(endpoint1)) {
        _divaEdgeTarget.put(edge,endpoint2);
        _divaEdgeSource.put(edge,endpoint1);
      }
 else       if (_divaEdgeTarget.containsValue(endpoint2)) {
        _divaEdgeTarget.put(edge,endpoint1);
        _divaEdgeSource.put(edge,endpoint2);
      }
 else       if (_divaEdgeSource.containsValue(endpoint1)) {
        _divaEdgeTarget.put(edge,endpoint1);
        _divaEdgeSource.put(edge,endpoint2);
      }
 else       if (_divaEdgeSource.containsValue(endpoint2)) {
        _divaEdgeTarget.put(edge,endpoint2);
        _divaEdgeSource.put(edge,endpoint1);
      }
 else {
        allDirectionsSet=false;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Determine the direction of dataflow of all edges and store it in the local maps. Iterate all edges and try to deduce the type of each edge's endpoints, i.e. whether it is an source or target. Do this in multiple iterations by first getting clear information from input and output ports and then propagate this information to the adjacent edges. Work only on the local maps, i.e. get the list of all edges of the _ptolemyDiva2KielerEdges map and store the source and target information in _divaEdgeSource resp. _divaEdgeTarget.
 */
private void _storeEndpoints(){
  ActorGraphModel aGraph=(ActorGraphModel)this.getLayoutTarget().getGraphModel();
  boolean allDirectionsSet=false;
  Set edges=_ptolemyDiva2KielerEdges.keySet();
  while (!allDirectionsSet) {
    allDirectionsSet=true;
    for (Iterator edgeIter=edges.iterator(); edgeIter.hasNext(); ) {
      Object edge=(Object)edgeIter.next();
      EdgeModel edgeModel=aGraph.getEdgeModel(edge);
      Object simpleEndpoint1=edgeModel.getHead(edge);
      Object simpleEndpoint2=edgeModel.getTail(edge);
      Object endpoint1=aGraph.getSemanticObject(simpleEndpoint1);
      Object endpoint2=aGraph.getSemanticObject(simpleEndpoint2);
      if (_divaEdgeTarget.containsKey(edge) && _divaEdgeSource.containsKey(edge))       continue;
      if (endpoint1 instanceof Port) {
        boolean isInput1=PtolemyModelUtil._isInput((Port)endpoint1);
        if (simpleEndpoint1 instanceof Location)         isInput1=!isInput1;
        if (isInput1) {
          _divaEdgeTarget.put(edge,simpleEndpoint1);
          _divaEdgeSource.put(edge,simpleEndpoint2);
        }
 else {
          _divaEdgeTarget.put(edge,simpleEndpoint2);
          _divaEdgeSource.put(edge,simpleEndpoint1);
        }
      }
 else       if (endpoint2 instanceof Port) {
        boolean isInput2=PtolemyModelUtil._isInput((Port)endpoint2);
        if (simpleEndpoint2 instanceof Location)         isInput2=!isInput2;
        if (isInput2) {
          _divaEdgeTarget.put(edge,simpleEndpoint2);
          _divaEdgeSource.put(edge,simpleEndpoint1);
        }
 else {
          _divaEdgeTarget.put(edge,simpleEndpoint1);
          _divaEdgeSource.put(edge,simpleEndpoint2);
        }
      }
 else       if (_divaEdgeTarget.containsValue(endpoint1)) {
        _divaEdgeTarget.put(edge,simpleEndpoint2);
        _divaEdgeSource.put(edge,simpleEndpoint1);
      }
 else       if (_divaEdgeTarget.containsValue(endpoint2)) {
        _divaEdgeTarget.put(edge,simpleEndpoint1);
        _divaEdgeSource.put(edge,simpleEndpoint2);
      }
 else       if (_divaEdgeSource.containsValue(endpoint1)) {
        _divaEdgeTarget.put(edge,simpleEndpoint1);
        _divaEdgeSource.put(edge,simpleEndpoint2);
      }
 else       if (_divaEdgeSource.containsValue(endpoint2)) {
        _divaEdgeTarget.put(edge,simpleEndpoint2);
        _divaEdgeSource.put(edge,simpleEndpoint1);
      }
 else {
        allDirectionsSet=false;
      }
    }
  }
}