Program: 117729
Project: 117729
Buggy source:
public void refreshGraph(){
  if (model != null && projection != null) {
    projection.set(Projection.VIEW_WIDTH,this.getWidth());
    projection.set(Projection.VIEW_HEIGHT,this.getHeight());
  }
synchronized (this) {
    needsRefresh=false;
    TopicMap tm=tmModel.getTopicMap();
    VModel oldModel=model;
    TopicMapModel oldTMModel=tmModel;
    Topic oldRoot=rootTopic;
    ArrayList<VNode> oldNodes=oldModel.getNodes();
    ArrayList<VEdge> oldEdges=oldModel.getEdges();
    remakeModels(tm);
    try {
      for (      VNode vnode : oldNodes) {
        Node node=vnode.getNode();
        VNode nn=null;
        if (node instanceof TopicNode) {
          TopicNode tn=(TopicNode)node;
          Topic t=tn.getTopic();
          Topic nt=getNewTopicFor(t,tm);
          if (nt != null) {
            nn=model.addNode(tmModel.getNodeFor(nt));
          }
        }
 else         if (node instanceof AssociationNode) {
          AssociationNode an=(AssociationNode)node;
          Association a=an.getAssociation();
          Association na=getNewAssociationFor(a,tm);
          if (na != null) {
            if (na.getRoles().size() != 2) {
              nn=model.addNode(tmModel.getNodeFor(na));
            }
          }
        }
 else         if (node instanceof OccurrenceNode) {
          OccurrenceNode on=(OccurrenceNode)node;
          Topic carrier=on.getCarrier();
          Topic type=on.getType();
          Topic scope=on.getScope();
          String o=carrier.getData(type,scope);
          if (o != null) {
            nn=model.addNode(tmModel.getNodeFor(carrier,type,scope,o));
          }
        }
        if (nn != null) {
          nn.x=vnode.x;
          nn.y=vnode.y;
          nn.pinned=vnode.pinned;
          if (vnode.selected)           model.addSelection(nn);
        }
      }
      for (      VEdge vedge : oldEdges) {
        Edge edge=vedge.getEdge();
        VEdge ne=null;
        if (edge instanceof AssociationEdge) {
          AssociationEdge ae=(AssociationEdge)edge;
          Association a=ae.getAssociation();
          Association na=getNewAssociationFor(a,tm);
          if (na != null) {
            if (a.getRoles().size() == na.getRoles().size()) {
              if (a.getRoles().size() == 2) {
                ne=model.addEdge(tmModel.getEdgeFor(na));
              }
 else {
                AssociationNode an=tmModel.getNodeFor(na);
                VNode vn=model.addNode(an);
                model.openNode(vn);
              }
            }
          }
        }
 else         if (edge instanceof InstanceEdge) {
          InstanceEdge ie=(InstanceEdge)edge;
          Topic instance=ie.getInstance();
          Topic type=ie.getType();
          Topic ninstance=getNewTopicFor(instance,tm);
          Topic ntype=getNewTopicFor(type,tm);
          if (ninstance != null && ntype != null) {
            ne=model.addEdge(tmModel.getInstanceEdgeFor(ntype,ninstance));
          }
        }
 else         if (edge instanceof OccurrenceEdge) {
          OccurrenceEdge oe=(OccurrenceEdge)edge;
          Topic carrier=oe.getCarrier();
          Topic type=oe.getType();
          Topic scope=oe.getScope();
          String o=carrier.getData(type,scope);
          if (o != null) {
            ne=model.addEdge(tmModel.getOccurrenceEdgeFor(carrier,type,scope,o));
          }
        }
        if (ne != null) {
          if (vedge.selected) {
            model.setSelection(ne);
          }
          ne.mouseOver=vedge.mouseOver;
          ne.labelEdges=vedge.labelEdges;
          ne.curvature=vedge.curvature;
        }
      }
      rootTopic=getNewTopicFor(oldRoot,tm);
      followNode=null;
    }
 catch (    TopicMapException tme) {
      tme.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public void refreshGraph(){
  if (model != null && projection != null) {
    projection.set(Projection.VIEW_WIDTH,this.getWidth());
    projection.set(Projection.VIEW_HEIGHT,this.getHeight());
  }
synchronized (this) {
    needsRefresh=false;
    TopicMap tm=tmModel.getTopicMap();
    VModel oldModel=model;
    TopicMapModel oldTMModel=tmModel;
    Topic oldRoot=rootTopic;
    ArrayList<VNode> oldNodes=oldModel.getNodes();
    ArrayList<VEdge> oldEdges=oldModel.getEdges();
    remakeModels(tm);
    try {
      for (      VNode vnode : oldNodes) {
        Node node=vnode.getNode();
        VNode nn=null;
        if (node instanceof TopicNode) {
          TopicNode tn=(TopicNode)node;
          Topic t=tn.getTopic();
          Topic nt=getNewTopicFor(t,tm);
          if (nt != null) {
            nn=model.addNode(tmModel.getNodeFor(nt));
          }
        }
 else         if (node instanceof AssociationNode) {
          AssociationNode an=(AssociationNode)node;
          Association a=an.getAssociation();
          Association na=getNewAssociationFor(a,tm);
          if (na != null) {
            if (na.getRoles().size() != 2) {
              nn=model.addNode(tmModel.getNodeFor(na));
            }
          }
        }
 else         if (node instanceof OccurrenceNode) {
          OccurrenceNode on=(OccurrenceNode)node;
          Topic carrier=on.getCarrier();
          Topic type=on.getType();
          Topic scope=on.getScope();
          Topic ncarrier=getNewTopicFor(carrier,tm);
          Topic ntype=getNewTopicFor(type,tm);
          Topic nscope=getNewTopicFor(scope,tm);
          if (ncarrier != null && ntype != null && nscope != null) {
            String o=ncarrier.getData(ntype,nscope);
            if (o != null) {
              nn=model.addNode(tmModel.getNodeFor(ncarrier,ntype,nscope,o));
            }
          }
        }
        if (nn != null) {
          nn.x=vnode.x;
          nn.y=vnode.y;
          nn.pinned=vnode.pinned;
          if (vnode.selected)           model.addSelection(nn);
        }
      }
      for (      VEdge vedge : oldEdges) {
        Edge edge=vedge.getEdge();
        VEdge ne=null;
        if (edge instanceof AssociationEdge) {
          AssociationEdge ae=(AssociationEdge)edge;
          Association a=ae.getAssociation();
          Association na=getNewAssociationFor(a,tm);
          if (na != null) {
            if (a.getRoles().size() == na.getRoles().size()) {
              if (a.getRoles().size() == 2) {
                ne=model.addEdge(tmModel.getEdgeFor(na));
              }
 else {
                AssociationNode an=tmModel.getNodeFor(na);
                VNode vn=model.addNode(an);
                model.openNode(vn);
              }
            }
          }
        }
 else         if (edge instanceof InstanceEdge) {
          InstanceEdge ie=(InstanceEdge)edge;
          Topic instance=ie.getInstance();
          Topic type=ie.getType();
          Topic ninstance=getNewTopicFor(instance,tm);
          Topic ntype=getNewTopicFor(type,tm);
          if (ninstance != null && ntype != null) {
            ne=model.addEdge(tmModel.getInstanceEdgeFor(ntype,ninstance));
          }
        }
 else         if (edge instanceof OccurrenceEdge) {
          OccurrenceEdge oe=(OccurrenceEdge)edge;
          Topic carrier=oe.getCarrier();
          Topic type=oe.getType();
          Topic scope=oe.getScope();
          Topic ncarrier=getNewTopicFor(carrier,tm);
          Topic ntype=getNewTopicFor(type,tm);
          Topic nscope=getNewTopicFor(scope,tm);
          if (ntype != null && nscope != null && ncarrier != null) {
            String o=ncarrier.getData(ntype,nscope);
            if (o != null) {
              ne=model.addEdge(tmModel.getOccurrenceEdgeFor(ncarrier,ntype,nscope,o));
            }
          }
        }
        if (ne != null) {
          if (vedge.selected) {
            model.setSelection(ne);
          }
          ne.mouseOver=vedge.mouseOver;
          ne.labelEdges=vedge.labelEdges;
          ne.curvature=vedge.curvature;
        }
      }
      rootTopic=getNewTopicFor(oldRoot,tm);
      followNode=null;
    }
 catch (    TopicMapException tme) {
      tme.printStackTrace();
    }
  }
}