nus-yam/ex-repair huggingface dataset:
Program: 143192
Project: 143192
Buggy source:
private void deleteNode(PreNode node){
  for (DescendantAndSelfIterator itr=new DescendantAndSelfIterator(treeStructure,node,null); itr.hasNext(); ) {
    AbstractNode descendant=itr.next();
    if (descendant.isEnabled()) {
      edgeProcessor.clearMetaEdges(descendant);
    }
    edgeProcessor.clearEdges(descendant);
    if (descendant == descendant.getOriginalNode()) {
      CloneNode cn=descendant.getOriginalNode().getClones();
      while (cn != null) {
        treeStructure.deleteDescendantAndSelf(cn);
        cn=cn.getNext();
      }
    }
 else {
      treeStructure.deleteDescendantAndSelf(descendant.getOriginalNode());
      CloneNode cn=descendant.getOriginalNode().getClones();
      while (cn != null) {
        if (cn != descendant) {
          treeStructure.deleteDescendantAndSelf(cn);
        }
        cn=cn.getNext();
      }
    }
  }
  treeStructure.deleteDescendantAndSelf(node);
}

Fixed version (ground truth):
private void deleteNode(PreNode node){
  for (DescendantAndSelfIterator itr=new DescendantAndSelfIterator(treeStructure,node,null); itr.hasNext(); ) {
    AbstractNode descendant=itr.next();
    if (descendant.isEnabled()) {
      edgeProcessor.clearMetaEdges(descendant);
    }
    edgeProcessor.clearEdges(descendant);
    if (descendant == descendant.getOriginalNode()) {
      CloneNode cn=descendant.getOriginalNode().getClones();
      while (cn != null) {
        unAttachClones(cn);
        treeStructure.deleteDescendantAndSelf(cn);
        cn=cn.getNext();
      }
    }
 else {
      treeStructure.deleteDescendantAndSelf(descendant.getOriginalNode());
      CloneNode cn=descendant.getOriginalNode().getClones();
      while (cn != null) {
        if (cn != descendant) {
          treeStructure.deleteDescendantAndSelf(cn);
        }
        cn=cn.getNext();
      }
    }
  }
  treeStructure.deleteDescendantAndSelf(node);
}
Program: 143193
Project: 143193
Buggy source:
public boolean contains(Node node){
  if (node == null) {
    throw new NullPointerException();
  }
  AbstractNode absNode=(AbstractNode)node;
  readLock();
  if (!absNode.isValid()) {
    return false;
  }
  boolean res=false;
  if (nodeProposition.evaluate(absNode) && dhns.getTreeStructure().getTree().contains(absNode)) {
    res=true;
  }
  readUnlock();
  return res;
}

Fixed version (ground truth):
public boolean contains(Node node){
  if (node == null) {
    throw new NullPointerException();
  }
  AbstractNode absNode=(AbstractNode)node;
  readLock();
  boolean res=false;
  if (absNode.isValid()) {
    if (nodeProposition.evaluate(absNode) && dhns.getTreeStructure().getTree().contains(absNode)) {
      res=true;
    }
  }
  readUnlock();
  return res;
}
Program: 143194
Project: 143194
Buggy source:
@Test public void testCloneRemove(){
  graph1.removeNode(nodeMap.get("String_Node_Str"));
  assertFalse(graph1.contains(nodeMap.get("String_Node_Str")));
  assertEquals(1,((PreNode)nodeMap.get("String_Node_Str")).size);
  assertEquals(2,((PreNode)dhns1.getTreeStructure().root).size);
  assertEquals(2,graph1.getNodeCount());
  setUp();
  graph1.removeNode(nodeMap.get("String_Node_Str"));
  assertFalse(graph1.contains(nodeMap.get("String_Node_Str")));
  assertEquals(1,((PreNode)nodeMap.get("String_Node_Str")).size);
  assertEquals(2,((PreNode)dhns1.getTreeStructure().root).size);
  assertEquals(2,graph1.getNodeCount());
  DhnsGraphController controller=new DhnsGraphController();
  Dhns dhns=controller.getMainDhns();
  ClusteredDirectedGraphImpl graph=new ClusteredDirectedGraphImpl(dhns,false);
  GraphFactoryImpl factory=controller.factory();
  AbstractNode nodeA=factory.newNode();
  AbstractNode nodeB=factory.newNode();
  AbstractNode nodeC=factory.newNode();
  AbstractNode nodeD=factory.newNode();
  graph.addNode(nodeA);
  graph.addNode(nodeB,nodeA);
  graph.addNode(nodeC,nodeA);
  graph.addNode(nodeD,nodeB);
  graph.addNode(nodeD,nodeC);
  graph.addNode(nodeD,nodeA);
  graph.removeNode(nodeD);
  assertFalse(graph1.contains(nodeD));
  assertEquals(2,((PreNode)nodeA).size);
}

Fixed version (ground truth):
@Test public void testCloneRemove(){
  graph1.removeNode(nodeMap.get("String_Node_Str"));
  assertFalse(graph1.contains(nodeMap.get("String_Node_Str")));
  assertEquals(1,((PreNode)nodeMap.get("String_Node_Str")).size);
  assertEquals(2,((PreNode)dhns1.getTreeStructure().root).size);
  assertEquals(2,graph1.getNodeCount());
  setUp();
  graph1.removeNode(nodeMap.get("String_Node_Str"));
  assertFalse(graph1.contains(nodeMap.get("String_Node_Str")));
  assertEquals(1,((PreNode)nodeMap.get("String_Node_Str")).size);
  assertEquals(2,((PreNode)dhns1.getTreeStructure().root).size);
  assertEquals(2,graph1.getNodeCount());
  DhnsGraphController controller=new DhnsGraphController();
  Dhns dhns=controller.getMainDhns();
  ClusteredDirectedGraphImpl graph=new ClusteredDirectedGraphImpl(dhns,false);
  GraphFactoryImpl factory=controller.factory();
  AbstractNode nodeA=factory.newNode();
  AbstractNode nodeB=factory.newNode();
  AbstractNode nodeC=factory.newNode();
  AbstractNode nodeD=factory.newNode();
  graph.addNode(nodeA);
  graph.addNode(nodeB,nodeA);
  graph.addNode(nodeC,nodeA);
  graph.addNode(nodeD,nodeB);
  graph.addNode(nodeD,nodeC);
  graph.addNode(nodeD,nodeA);
  graph.removeNode(nodeD);
  assertFalse(graph.contains(nodeD));
  assertEquals(2,((PreNode)nodeA).size);
  setUp();
  graph1.addNode(nodeMap.get("String_Node_Str"),nodeMap.get("String_Node_Str"));
  AbstractNode cloneAafterE=nodeMap.get("String_Node_Str").getOriginalNode().getClones();
  graph1.addNode(cloneAafterE,nodeMap.get("String_Node_Str"));
  graph1.removeNode(nodeMap.get("String_Node_Str"));
  assertEquals(2,graph1.getNodeCount());
  assertTrue(graph1.contains(nodeMap.get("String_Node_Str")));
  assertTrue(graph1.contains(nodeMap.get("String_Node_Str")));
}
Program: 143195
Project: 143195
Buggy source:
private void updateEdges(){
  Modeler edgeInit=engine.getModelClasses()[AbstractEngine.CLASS_EDGE].getCurrentModeler();
  Modeler arrowInit=engine.getModelClasses()[AbstractEngine.CLASS_ARROW].getCurrentModeler();
  EdgeIterable edgeIterable;
  if (vizConfig.isVisualizeTree()) {
    edgeIterable=graph.getHierarchyTree().getEdges();
  }
 else {
    edgeIterable=graph.getEdges();
  }
  for (  Edge edge : edgeIterable) {
    Model obj=edge.getEdgeData().getModel();
    if (obj == null) {
      obj=edgeInit.initModel(edge.getEdgeData());
      engine.addObject(AbstractEngine.CLASS_EDGE,(ModelImpl)obj);
      if (vizConfig.isShowArrows() && !edge.isSelfLoop()) {
        ModelImpl arrowObj=arrowInit.initModel(edge.getEdgeData());
        engine.addObject(AbstractEngine.CLASS_ARROW,arrowObj);
        arrowObj.setCacheMarker(cacheMarker);
        ((Edge2dModel)obj).setArrow(arrowObj);
      }
    }
 else     if (!obj.isValid()) {
      engine.addObject(AbstractEngine.CLASS_EDGE,(ModelImpl)obj);
      if (vizConfig.isShowArrows()) {
        ModelImpl arrowObj=((Edge2dModel)obj).getArrow();
        engine.addObject(AbstractEngine.CLASS_ARROW,arrowObj);
        arrowObj.setCacheMarker(cacheMarker);
      }
    }
    obj.setCacheMarker(cacheMarker);
  }
}

Fixed version (ground truth):
private void updateEdges(){
  Modeler edgeInit=engine.getModelClasses()[AbstractEngine.CLASS_EDGE].getCurrentModeler();
  Modeler arrowInit=engine.getModelClasses()[AbstractEngine.CLASS_ARROW].getCurrentModeler();
  EdgeIterable edgeIterable;
  if (vizConfig.isVisualizeTree()) {
    edgeIterable=graph.getHierarchyTree().getEdges();
  }
 else {
    edgeIterable=graph.getEdges();
  }
  for (  Edge edge : edgeIterable) {
    Model obj=edge.getEdgeData().getModel();
    if (obj == null) {
      obj=edgeInit.initModel(edge.getEdgeData());
      engine.addObject(AbstractEngine.CLASS_EDGE,(ModelImpl)obj);
      if (vizConfig.isShowArrows() && !edge.isSelfLoop()) {
        ModelImpl arrowObj=arrowInit.initModel(edge.getEdgeData());
        engine.addObject(AbstractEngine.CLASS_ARROW,arrowObj);
        arrowObj.setCacheMarker(cacheMarker);
        ((Edge2dModel)obj).setArrow(arrowObj);
      }
    }
 else     if (!obj.isValid()) {
      engine.addObject(AbstractEngine.CLASS_EDGE,(ModelImpl)obj);
      if (vizConfig.isShowArrows() && !edge.isSelfLoop()) {
        ModelImpl arrowObj=((Edge2dModel)obj).getArrow();
        engine.addObject(AbstractEngine.CLASS_ARROW,arrowObj);
        arrowObj.setCacheMarker(cacheMarker);
      }
    }
    obj.setCacheMarker(cacheMarker);
  }
}
Program: 143196
Project: 143196
Buggy source:
public GraphFactoryImpl(IDGen idGen,AttributeRowFactory attributesFactory){
  this.idGen=idGen;
}

Fixed version (ground truth):
public GraphFactoryImpl(IDGen idGen,AttributeRowFactory attributesFactory){
  this.idGen=idGen;
  this.attributesFactory=attributesFactory;
}
Program: 143197
Project: 143197
Buggy source:
private void importText(FileObject fileObject,Importer importer,final Container container){
  final BufferedReader reader=getTextReader(fileObject);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      NotifyDescriptor.Exception ex=new NotifyDescriptor.Exception(t);
      DialogDisplayer.getDefault().notify(ex);
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        textImporter.importData(reader,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt(),errorHandler);
}

Fixed version (ground truth):
private void importText(FileObject fileObject,Importer importer,final Container container){
  final BufferedReader reader=getTextReader(fileObject);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      NotifyDescriptor.Exception ex=new NotifyDescriptor.Exception(t);
      DialogDisplayer.getDefault().notify(ex);
      t.printStackTrace();
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        textImporter.importData(reader,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt(),errorHandler);
}
Program: 143198
Project: 143198
Buggy source:
public void logIssue(Issue issue){
  entries.add(new ReportEntry(issue));
  if (criticalException && issue.getLevel().equals(Issue.Level.CRITICAL)) {
    if (issue.getThrowable() != null) {
      throw new RuntimeException(issue.getMessage(),issue.getThrowable());
    }
 else {
      throw new RuntimeException(issue.getMessage());
    }
  }
}

Fixed version (ground truth):
public void logIssue(Issue issue){
  entries.add(new ReportEntry(issue));
  if (issue.getLevel().toInteger() >= exceptionLevel.toInteger()) {
    if (issue.getThrowable() != null) {
      throw new RuntimeException(issue.getMessage(),issue.getThrowable());
    }
 else {
      throw new RuntimeException(issue.getMessage());
    }
  }
}
Program: 143199
Project: 143199
Buggy source:
private void flushToNode(NodeDraftGetter nodeDraft,Node node){
  if (nodeDraft.getColor() != null) {
    node.getNodeData().setR(nodeDraft.getColor().getRed() / 255f);
    node.getNodeData().setG(nodeDraft.getColor().getGreen() / 255f);
    node.getNodeData().setB(nodeDraft.getColor().getBlue() / 255f);
  }
  if (nodeDraft.getLabel() != null) {
    node.getNodeData().setLabel(nodeDraft.getLabel());
  }
  if (nodeDraft.getX() != 0) {
    node.getNodeData().setX(nodeDraft.getX());
  }
 else {
    node.getNodeData().setX((float)((0.01 + Math.random()) * 1000) - 500);
  }
  if (nodeDraft.getY() != 0) {
    node.getNodeData().setY(nodeDraft.getY());
  }
 else {
    node.getNodeData().setY((float)((0.01 + Math.random()) * 1000) - 500);
  }
  if (nodeDraft.getZ() != 0) {
    node.getNodeData().setZ(nodeDraft.getZ());
  }
  if (nodeDraft.getSize() != 0) {
    node.getNodeData().setSize(nodeDraft.getSize());
  }
  if (node.getNodeData().getAttributes() != null) {
    AttributeRow row=(AttributeRow)node.getNodeData().getAttributes();
    for (    AttributeValue val : nodeDraft.getAttributeValues()) {
      row.setValue(val.getColumn(),val.getValue());
    }
  }
}

Fixed version (ground truth):
private void flushToNode(NodeDraftGetter nodeDraft,Node node){
  if (nodeDraft.getColor() != null) {
    node.getNodeData().setR(nodeDraft.getColor().getRed() / 255f);
    node.getNodeData().setG(nodeDraft.getColor().getGreen() / 255f);
    node.getNodeData().setB(nodeDraft.getColor().getBlue() / 255f);
  }
  if (nodeDraft.getLabel() != null) {
    node.getNodeData().setLabel(nodeDraft.getLabel());
  }
  if (nodeDraft.getX() != 0) {
    node.getNodeData().setX(nodeDraft.getX());
  }
 else {
    node.getNodeData().setX((float)((0.01 + Math.random()) * 1000) - 500);
  }
  if (nodeDraft.getY() != 0) {
    node.getNodeData().setY(nodeDraft.getY());
  }
 else {
    node.getNodeData().setY((float)((0.01 + Math.random()) * 1000) - 500);
  }
  if (nodeDraft.getZ() != 0) {
    node.getNodeData().setZ(nodeDraft.getZ());
  }
  if (nodeDraft.getSize() != 0) {
    node.getNodeData().setSize(nodeDraft.getSize());
  }
  if (nodeDraft.getId() != null) {
    node.getNodeData().setId(nodeDraft.getId());
  }
  if (node.getNodeData().getAttributes() != null) {
    AttributeRow row=(AttributeRow)node.getNodeData().getAttributes();
    for (    AttributeValue val : nodeDraft.getAttributeValues()) {
      row.setValue(val.getColumn(),val.getValue());
    }
  }
}
Program: 143200
Project: 143200
Buggy source:
public void executeLayout(final Layout layout){
  executor.execute(new Runnable(){
    public void run(){
      GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
      layout.initAlgo(graphController);
      layout.resetPropertiesValues();
      while (layout.canAlgo()) {
        layout.goAlgo();
      }
      layout.endAlgo();
    }
  }
);
}

Fixed version (ground truth):
public void executeLayout(final Layout layout){
  System.out.println("String_Node_Str");
  executor.execute(new Runnable(){
    public void run(){
      GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
      System.out.println("String_Node_Str");
      layout.initAlgo(graphController);
      layout.resetPropertiesValues();
      while (layout.canAlgo()) {
        layout.goAlgo();
      }
      System.out.println("String_Node_Str");
      layout.endAlgo();
    }
  }
);
}
Program: 143201
Project: 143201
Buggy source:
public LayoutControllerImpl(){
  layouts=new ArrayList<Layout>(Lookup.getDefault().lookupAll(Layout.class));
  executor=Executors.newSingleThreadExecutor();
}

Fixed version (ground truth):
public LayoutControllerImpl(){
  layouts=new ArrayList<LayoutBuilder>(Lookup.getDefault().lookupAll(LayoutBuilder.class));
  executor=Executors.newSingleThreadExecutor();
}
Program: 143202
Project: 143202
Buggy source:
public void run(){
  GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
  layout.initAlgo(graphController);
  layout.resetPropertiesValues();
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  layout.endAlgo();
}

Fixed version (ground truth):
public void run(){
  GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
  System.out.println("String_Node_Str");
  layout.initAlgo(graphController);
  layout.resetPropertiesValues();
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  System.out.println("String_Node_Str");
  layout.endAlgo();
}
Program: 143203
Project: 143203
Buggy source:
public void goAlgo(){
  BarnesHut barnes=new BarnesHut(getNodeForce());
  barnes.theta=getBarnesHutTheta();
  QuadTree tree=QuadTree.buildTree(graph,getBarnesHutMaxLevel());
  for (  Node node : graph.getTopNodes()) {
    NodeData data=node.getNodeData();
    ForceVector layoutData=data.getLayoutData();
    if (layoutData == null) {
      System.out.println("String_Node_Str" + graph.getLevel(node));
    }
 else {
      ForceVector f=barnes.calculateForce(data,tree);
      layoutData.add(f);
    }
  }
  AbstractForce edgeForce=getEdgeForce();
  for (  Edge e : graph.getEdges()) {
    if (graph.getLevel(e.getSource()) == 0 && graph.getLevel(e.getTarget()) == 0) {
      NodeData n1=e.getSource().getNodeData();
      NodeData n2=e.getTarget().getNodeData();
      ForceVector f1=n1.getLayoutData();
      ForceVector f2=n2.getLayoutData();
      ForceVector f=edgeForce.calculateForce(n1,n2);
      f1.add(f);
      f2.subtract(f);
    }
  }
  energy0=energy;
  energy=0;
  Displacement displacement=getDisplacement();
  for (  Node n : graph.getTopNodes()) {
    NodeData data=n.getNodeData();
    ForceVector force=data.getLayoutData();
    energy+=force.getEnergy();
    displacement.moveNode(data,force);
  }
  postAlgo();
}

Fixed version (ground truth):
public void goAlgo(){
  BarnesHut barnes=new BarnesHut(getNodeForce());
  barnes.theta=getBarnesHutTheta();
  QuadTree tree=QuadTree.buildTree(graph,getBarnesHutMaxLevel());
  for (  Node node : graph.getTopNodes()) {
    NodeData data=node.getNodeData();
    ForceVector layoutData=data.getLayoutData();
    if (layoutData == null) {
      System.out.println("String_Node_Str" + graph.getLevel(node));
    }
 else {
      ForceVector f=barnes.calculateForce(data,tree);
      layoutData.add(f);
    }
  }
  AbstractForce edgeForce=getEdgeForce();
  int count=0;
  for (  Edge e : getTopEdges(graph)) {
    count++;
    if (graph.getLevel(e.getSource()) == 0 && graph.getLevel(e.getTarget()) == 0) {
      NodeData n1=e.getSource().getNodeData();
      NodeData n2=e.getTarget().getNodeData();
      ForceVector f1=n1.getLayoutData();
      ForceVector f2=n2.getLayoutData();
      ForceVector f=edgeForce.calculateForce(n1,n2);
      f1.add(f);
      f2.subtract(f);
    }
  }
  System.out.println("String_Node_Str" + count);
  energy0=energy;
  energy=0;
  Displacement displacement=getDisplacement();
  for (  Node n : graph.getTopNodes()) {
    NodeData data=n.getNodeData();
    ForceVector force=data.getLayoutData();
    energy+=force.getEnergy();
    displacement.moveNode(data,force);
  }
  postAlgo();
}
Program: 143204
Project: 143204
Buggy source:
public void moveNode(NodeData node,ForceVector forceData){
  if (forceData.getNorm() > 1e-3) {
    ForceVector displacement=forceData.normalize();
    displacement.multiply(step);
    float x=node.x();
    float y=node.y();
    node.setX(node.x() + displacement.x());
    node.setY(node.y() + displacement.y());
  }
}

Fixed version (ground truth):
public void moveNode(NodeData node,ForceVector forceData){
  ForceVector displacement=forceData;
  displacement.multiply(step);
  float x=node.x();
  float y=node.y();
  node.setX(node.x() + displacement.x());
  node.setY(node.y() + displacement.y());
}
Program: 143205
Project: 143205
Buggy source:
public static QuadTree buildTree(ClusteredGraph graph,int maxLevel){
  float minX=Float.NEGATIVE_INFINITY;
  float maxX=Float.POSITIVE_INFINITY;
  float minY=Float.NEGATIVE_INFINITY;
  float maxY=Float.POSITIVE_INFINITY;
  for (  Node node : graph.getNodes(0)) {
    minX=Math.min(minX,node.getNodeData().x());
    maxX=Math.max(maxX,node.getNodeData().x());
    minY=Math.min(minY,node.getNodeData().y());
    maxY=Math.max(maxY,node.getNodeData().y());
  }
  float size=Math.max(maxY - minY,maxX - minX);
  QuadTree tree=new QuadTree(minX,minY,size,maxLevel);
  for (  Node node : graph.getNodes(0)) {
    tree.addNode(node.getNodeData());
  }
  return tree;
}

Fixed version (ground truth):
public static QuadTree buildTree(ClusteredGraph graph,int maxLevel){
  float minX=Float.POSITIVE_INFINITY;
  float maxX=Float.NEGATIVE_INFINITY;
  float minY=Float.POSITIVE_INFINITY;
  float maxY=Float.NEGATIVE_INFINITY;
  for (  Node node : graph.getTopNodes()) {
    minX=Math.min(minX,node.getNodeData().x());
    maxX=Math.max(maxX,node.getNodeData().x());
    minY=Math.min(minY,node.getNodeData().y());
    maxY=Math.max(maxY,node.getNodeData().y());
  }
  float size=Math.max(maxY - minY,maxX - minX);
  QuadTree tree=new QuadTree(minX,minY,size,maxLevel);
  for (  Node node : graph.getTopNodes()) {
    tree.addNode(node.getNodeData());
  }
  return tree;
}
Program: 143206
Project: 143206
Buggy source:
public void resetPropertiesValues(){
  stepRatio=(float)0.9;
  progress=0;
  converged=false;
  optimalDistance=10;
  step=optimalDistance / 10;
  relativeStrength=(float)0.1;
}

Fixed version (ground truth):
public void resetPropertiesValues(){
  stepRatio=(float)0.9;
  progress=0;
  converged=false;
  optimalDistance=getAverageEdge(graph);
  System.out.println("String_Node_Str" + optimalDistance);
  step=(float)optimalDistance / 10000;
  relativeStrength=(float)0.2;
}
Program: 143207
Project: 143207
Buggy source:
private void updateStep(){
  if (energy < energy0) {
    progress++;
    if (progress >= 5) {
      progress=0;
      step/=stepRatio;
    }
  }
 else {
    progress=0;
    step*=stepRatio;
  }
  if (Math.abs(energy - energy0) < optimalDistance * 1e-6) {
    converged=true;
  }
}

Fixed version (ground truth):
private void updateStep(){
  if (energy < energy0) {
    progress++;
    if (progress >= 5) {
      progress=0;
      step/=stepRatio;
    }
  }
 else {
    progress=0;
    step*=stepRatio;
  }
  if (Math.abs((energy - energy0) / energy) < 1e-3) {
    converged=true;
  }
}
Program: 143208
Project: 143208
Buggy source:
@Override public ForceVector calculateForce(Spatial node1,Spatial node2,float distance){
  ForceVector f=new ForceVector(node2.x() - node1.x(),node2.y() - node1.y());
  f.multiply(forceConstant / distance);
  return f;
}

Fixed version (ground truth):
@Override public ForceVector calculateForce(Spatial node1,Spatial node2,float distance){
  ForceVector f=new ForceVector(node2.x() - node1.x(),node2.y() - node1.y());
  f.multiply(-relativeStrength * optimalDistance * optimalDistance / (distance * distance));
  if (Float.isNaN(f.x()) || Float.isNaN(f.y())) {
    f=new ForceVector(100,100);
  }
  return f;
}
Program: 143209
Project: 143209
Buggy source:
public void initAlgo(GraphController graphController){
  graph=graphController.getClusteredDirectedGraph();
}

Fixed version (ground truth):
public void initAlgo(GraphController graphController){
  graph=graphController.getClusteredDirectedGraph();
  level=1;
  CoarseningStrategy coarsening=getCoarseningStrategy();
  coarsening.coarsen(getGraph());
  layout=getForceLayout();
}
Program: 143210
Project: 143210
Buggy source:
private void recursiveLayout(int level){
  System.out.println(graph.getLevelSize(0) + "String_Node_Str" + graph.getEdgeCount());
  if (graph.getLevelSize(0) > 100) {
    CoarseningStrategy coarsening=getCoarseningStrategy();
    coarsening.coarsen(graph);
    recursiveLayout(level + 1);
    layoutLevel(level);
    coarsening.refine(graph);
  }
  System.out.println("String_Node_Str" + level);
}

Fixed version (ground truth):
private void recursiveLayout(int level){
  System.out.println(getGraph().getLevelSize(0) + "String_Node_Str" + getGraph().getEdgeCount());
  if (level < 2) {
    CoarseningStrategy coarsening=getCoarseningStrategy();
    coarsening.coarsen(getGraph());
    recursiveLayout(level + 1);
    layoutLevel(level);
    coarsening.refine(getGraph());
  }
  System.out.println("String_Node_Str" + level);
}
Program: 143211
Project: 143211
Buggy source:
public void goAlgo(){
  recursiveLayout(0);
  acabou=true;
}

Fixed version (ground truth):
public void goAlgo(){
  if (layout.canAlgo()) {
    layout.goAlgo();
  }
 else {
    layout.endAlgo();
    if (level > 0) {
      CoarseningStrategy coarsening=getCoarseningStrategy();
      coarsening.refine(getGraph());
      level--;
    }
 else {
      acabou=true;
    }
  }
}
Program: 143212
Project: 143212
Buggy source:
private void layoutLevel(int level){
  YifanHu layout=getForceLayout();
  layout.initAlgo(graph);
  layout.resetPropertiesValues();
  layout.optimalDistance=10000000;
  layout.optimalDistance*=Math.pow(4.0 / 7,level / 2.0);
  System.out.println("String_Node_Str" + layout.optimalDistance);
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  layout.endAlgo();
}

Fixed version (ground truth):
private void layoutLevel(int level){
  YifanHu layout=getForceLayout();
  System.out.println("String_Node_Str" + layout.optimalDistance);
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  layout.endAlgo();
}
Program: 143213
Project: 143213
Buggy source:
public boolean cancel(){
  if (inBackground) {
    if (future.cancel(false)) {
      return true;
    }
  }
  return task.cancel();
}

Fixed version (ground truth):
public boolean cancel(){
  if (inBackground) {
    if (future.cancel(false)) {
      return true;
    }
  }
  if (task != null) {
    return task.cancel();
  }
  return false;
}
Program: 143214
Project: 143214
Buggy source:
public RunningLongTask(LongTask task,Runnable runnable,String taskName){
  this.task=task;
  this.runnable=runnable;
  this.progress=new ProgressTicket(taskName,new Cancellable(){
    public boolean cancel(){
      LongTaskExecutor.this.cancel();
      return true;
    }
  }
);
  task.setProgressTicket(progress);
}

Fixed version (ground truth):
public RunningLongTask(LongTask task,Runnable runnable,String taskName){
  this.task=task;
  this.runnable=runnable;
  this.progress=new ProgressTicket(taskName,new Cancellable(){
    public boolean cancel(){
      LongTaskExecutor.this.cancel();
      return true;
    }
  }
);
  if (task != null) {
    task.setProgressTicket(progress);
  }
}
Program: 143215
Project: 143215
Buggy source:
public void execute(LongTask task,Runnable runnable){
  execute(task,runnable,"String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Execute a long task with cancel and progress support. Task can be <code>null</code>. In this case <code>runnable</code> will be executed normally, but without cancel and progress support.
 * @param task the task to be executed, can be <code>null</code>.
 * @param runnable the runnable to be executed
 * @throws NullPointerException if <code>runnable</code> is null
 * @throws IllegalStateException if a task is still executing at this time
 */
public void execute(LongTask task,Runnable runnable){
  execute(task,runnable,"String_Node_Str");
}
Program: 143216
Project: 143216
Buggy source:
public void generate(final Generator generator){
  String title=generator.getName();
  GeneratorUI ui=generator.getUI();
  if (ui != null) {
    ui.setup(generator);
    DialogDescriptor dd=new DialogDescriptor(ui.getPanel(),title);
    Object result=DialogDisplayer.getDefault().notify(dd);
    if (result != NotifyDescriptor.OK_OPTION) {
      return;
    }
    ui.unsetup();
  }
  final Container container=Lookup.getDefault().lookup(Container.class);
  container.setSource("String_Node_Str" + generator.getName());
  String taskname="String_Node_Str" + generator.getName();
  executor.execute(generator,new Runnable(){
    public void run(){
      generator.generate(container.getLoader());
      Lookup.getDefault().lookup(Processor.class).process(container.getUnloader());
    }
  }
,taskname);
}

Fixed version (ground truth):
public void generate(final Generator generator){
  String title=generator.getName();
  GeneratorUI ui=generator.getUI();
  if (ui != null) {
    ui.setup(generator);
    DialogDescriptor dd=new DialogDescriptor(ui.getPanel(),title);
    Object result=DialogDisplayer.getDefault().notify(dd);
    if (result != NotifyDescriptor.OK_OPTION) {
      return;
    }
    ui.unsetup();
  }
  final Container container=Lookup.getDefault().lookup(Container.class);
  container.setSource("String_Node_Str" + generator.getName());
  String taskname="String_Node_Str" + generator.getName();
  LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      NotifyDescriptor.Exception ex=new NotifyDescriptor.Exception(t);
      DialogDisplayer.getDefault().notify(ex);
    }
  }
;
  executor.execute(generator,new Runnable(){
    public void run(){
      generator.generate(container.getLoader());
      Lookup.getDefault().lookup(Processor.class).process(container.getUnloader());
    }
  }
,taskname,errorHandler);
}
Program: 143217
Project: 143217
Buggy source:
private void importXML(FileObject fileObject,Importer importer,final Container container){
  final Document document=getDocument(fileObject);
  final XMLImporter xmlImporter=(XMLImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        xmlImporter.importData(document,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        Exceptions.printStackTrace(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt());
}

Fixed version (ground truth):
private void importXML(FileObject fileObject,Importer importer,final Container container){
  final Document document=getDocument(fileObject);
  final XMLImporter xmlImporter=(XMLImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        xmlImporter.importData(document,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        Exceptions.printStackTrace(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt(),new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      NotifyDescriptor.Exception ex=new NotifyDescriptor.Exception(t);
      DialogDisplayer.getDefault().notify(ex);
    }
  }
);
}
Program: 143218
Project: 143218
Buggy source:
public void run(){
  try {
    textImporter.importData(reader,container.getLoader(),report);
    finishImport(container);
  }
 catch (  Exception ex) {
    Exceptions.printStackTrace(ex);
  }
}

Fixed version (ground truth):
public void run(){
  try {
    textImporter.importData(reader,container.getLoader(),report);
    finishImport(container);
  }
 catch (  Exception ex) {
    throw new RuntimeException(ex);
  }
}
Program: 143219
Project: 143219
Buggy source:
private void importText(FileObject fileObject,Importer importer,final Container container){
  final BufferedReader reader=getTextReader(fileObject);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        textImporter.importData(reader,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        Exceptions.printStackTrace(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt());
}

Fixed version (ground truth):
private void importText(FileObject fileObject,Importer importer,final Container container){
  final BufferedReader reader=getTextReader(fileObject);
  final TextImporter textImporter=(TextImporter)importer;
  final Report report=container.getReport();
  LongTask task=null;
  if (importer instanceof LongTask) {
    task=(LongTask)importer;
  }
  final LongTaskErrorHandler errorHandler=new LongTaskErrorHandler(){
    public void fatalError(    Throwable t){
      NotifyDescriptor.Exception ex=new NotifyDescriptor.Exception(t);
      DialogDisplayer.getDefault().notify(ex);
    }
  }
;
  executor.execute(task,new Runnable(){
    public void run(){
      try {
        textImporter.importData(reader,container.getLoader(),report);
        finishImport(container);
      }
 catch (      Exception ex) {
        throw new RuntimeException(ex);
      }
    }
  }
,"String_Node_Str" + fileObject.getNameExt(),errorHandler);
}
Program: 143220
Project: 143220
Buggy source:
public void generate(ContainerLoader container){
  int max=numberOfNodes;
  if (wiringProbability > 0) {
    max+=numberOfNodes - 1;
  }
  progress.start(max);
  int progressUnit=0;
  Random random=new Random();
  NodeDraft[] nodeArray=new NodeDraft[numberOfNodes];
  for (int i=0; i < numberOfNodes && !cancel; i++) {
    NodeDraft nodeDraft=container.factory().newNodeDraft();
    nodeDraft.setId("String_Node_Str" + i);
    container.addNode(nodeDraft);
    nodeArray[i]=nodeDraft;
    progress.progress(++progressUnit);
  }
  if (wiringProbability > 0) {
    for (int i=0; i < numberOfNodes - 1 && !cancel; i++) {
      NodeDraft node1=nodeArray[i];
      for (int j=i + 1; j < numberOfNodes && !cancel; j++) {
        NodeDraft node2=nodeArray[j];
        if (random.nextDouble() < wiringProbability) {
          EdgeDraft edgeDraft=container.factory().newEdgeDraft();
          edgeDraft.setSource(node1);
          edgeDraft.setTarget(node2);
          container.addEdge(edgeDraft);
        }
      }
      progress.progress(++progressUnit);
    }
  }
}

Fixed version (ground truth):
public void generate(ContainerLoader container){
  int max=numberOfNodes;
  if (wiringProbability > 0) {
    max+=numberOfNodes - 1;
  }
  Progress.start(progress,max);
  int progressUnit=0;
  Random random=new Random();
  NodeDraft[] nodeArray=new NodeDraft[numberOfNodes];
  for (int i=0; i < numberOfNodes && !cancel; i++) {
    NodeDraft nodeDraft=container.factory().newNodeDraft();
    nodeDraft.setId("String_Node_Str" + i);
    container.addNode(nodeDraft);
    nodeArray[i]=nodeDraft;
    Progress.progress(progress,++progressUnit);
  }
  if (wiringProbability > 0) {
    for (int i=0; i < numberOfNodes - 1 && !cancel; i++) {
      NodeDraft node1=nodeArray[i];
      for (int j=i + 1; j < numberOfNodes && !cancel; j++) {
        NodeDraft node2=nodeArray[j];
        if (random.nextDouble() < wiringProbability) {
          EdgeDraft edgeDraft=container.factory().newEdgeDraft();
          edgeDraft.setSource(node1);
          edgeDraft.setTarget(node2);
          container.addEdge(edgeDraft);
        }
      }
      Progress.progress(progress,++progressUnit);
    }
  }
}
Program: 143221
Project: 143221
Buggy source:
/** 
 * Notify the user about completed workunits and show additional detailed message.
 * @param message details about the status of the task
 * @param workunit a cumulative number of workunits completed so far
 */
public void progress(String message,int workunit){
  if (handle != null) {
    int ratioProgress=(int)(100.0 * workunit / progressTotal);
    if (ratioProgress != progress100) {
      progress100=ratioProgress;
      handle.progress(message,ratioProgress);
    }
  }
}

Fixed version (ground truth):
/** 
 * Notify the user about completed workunits and show additional detailed message.
 * @param message details about the status of the task
 * @param workunit a cumulative number of workunits completed so far
 */
public void progress(String message,int workunit){
  currentUnit=workunit;
  if (handle != null) {
    int ratioProgress=(int)(100.0 * workunit / progressTotal);
    if (ratioProgress != progress100) {
      progress100=ratioProgress;
      handle.progress(message,ratioProgress);
    }
  }
}
Program: 143222
Project: 143222
Buggy source:
/** 
 * Currently indeterminate task can be switched to show percentage completed.
 * @param workunits workunits total number of workunits that will be processed
 */
public void switchToDeterminate(int workunits){
  if (handle != null) {
    this.progressTotal=workunits;
    handle.switchToDeterminate(workunits);
  }
}

Fixed version (ground truth):
/** 
 * Currently indeterminate task can be switched to show percentage completed.
 * @param workunits workunits total number of workunits that will be processed
 */
public void switchToDeterminate(int workunits){
  if (handle != null) {
    this.progressTotal=workunits;
    handle.switchToDeterminate(100);
  }
}
Program: 143223
Project: 143223
Buggy source:
public void executeLayout(final Layout layout){
  executor.execute(new Runnable(){
    public void run(){
      GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
      layout.initAlgo(graphController);
      layout.resetPropertiesValues();
      while (layout.canAlgo()) {
        layout.goAlgo();
      }
      layout.endAlgo();
    }
  }
);
}

Fixed version (ground truth):
public void executeLayout(final Layout layout){
  System.out.println("String_Node_Str");
  executor.execute(new Runnable(){
    public void run(){
      GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
      System.out.println("String_Node_Str");
      layout.initAlgo(graphController);
      layout.resetPropertiesValues();
      while (layout.canAlgo()) {
        layout.goAlgo();
      }
      System.out.println("String_Node_Str");
      layout.endAlgo();
    }
  }
);
}
Program: 143224
Project: 143224
Buggy source:
public LayoutControllerImpl(){
  layouts=new ArrayList<Layout>(Lookup.getDefault().lookupAll(Layout.class));
  executor=Executors.newSingleThreadExecutor();
}

Fixed version (ground truth):
public LayoutControllerImpl(){
  layouts=new ArrayList<LayoutBuilder>(Lookup.getDefault().lookupAll(LayoutBuilder.class));
  executor=Executors.newSingleThreadExecutor();
}
Program: 143225
Project: 143225
Buggy source:
public void run(){
  GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
  layout.initAlgo(graphController);
  layout.resetPropertiesValues();
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  layout.endAlgo();
}

Fixed version (ground truth):
public void run(){
  GraphController graphController=Lookup.getDefault().lookup(GraphController.class);
  System.out.println("String_Node_Str");
  layout.initAlgo(graphController);
  layout.resetPropertiesValues();
  while (layout.canAlgo()) {
    layout.goAlgo();
  }
  System.out.println("String_Node_Str");
  layout.endAlgo();
}
Program: 143226
Project: 143226
Buggy source:
public void setInited(){
  if (!inited) {
    inited=true;
    if (requestAnimation) {
      startAnimating();
      requestAnimation=false;
    }
  }
}

Fixed version (ground truth):
public void setInited(){
  if (!inited) {
    inited=true;
    if (requestAnimation) {
      graphDrawable.display();
      startAnimating();
      requestAnimation=false;
    }
  }
}
Program: 143227
Project: 143227
Buggy source:
@Override public void startAnimating(){
  if (!scheduler.isAnimating()) {
    System.out.println("String_Node_Str");
    scheduler.start();
  }
}

Fixed version (ground truth):
@Override public void startAnimating(){
  if (!scheduler.isAnimating()) {
    System.out.println("String_Node_Str");
    scheduler.start();
    graphIO.startMouseListening();
  }
}
Program: 143228
Project: 143228
Buggy source:
@Override public void stopAnimating(){
  if (scheduler.isAnimating()) {
    System.out.println("String_Node_Str");
    scheduler.stop();
  }
}

Fixed version (ground truth):
@Override public void stopAnimating(){
  if (scheduler.isAnimating()) {
    System.out.println("String_Node_Str");
    scheduler.stop();
    graphIO.stopMouseListening();
  }
}
Program: 143229
Project: 143229
Buggy source:
@Override protected void init(GL gl){
  System.out.println("String_Node_Str");
  graphComponent.setCursor(Cursor.getDefaultCursor());
  engine.initEngine(gl,glu);
  VizController.getInstance().getGraphIO().startMouseListening();
}

Fixed version (ground truth):
@Override protected void init(GL gl){
  System.out.println("String_Node_Str");
  graphComponent.setCursor(Cursor.getDefaultCursor());
  engine.initEngine(gl,glu);
}
Program: 143230
Project: 143230
Buggy source:
private void importFakeGraph(){
  CompleteTreeImporter importer=new CompleteTreeImporter(treeStructure,sightManager.getMainSight());
  importer.importGraph(3,false);
  System.out.println("String_Node_Str" + treeStructure.getTreeSize());
  RandomEdgesGenerator reg=new RandomEdgesGenerator(treeStructure);
  reg.generatPhysicalEdges(10);
  freeMode.init();
}

Fixed version (ground truth):
private void importFakeGraph(){
  CompleteTreeImporter importer=new CompleteTreeImporter(treeStructure,sightManager.getMainSight());
  importer.importGraph(5,true);
  System.out.println("String_Node_Str" + treeStructure.getTreeSize());
  RandomEdgesGenerator reg=new RandomEdgesGenerator(treeStructure);
  reg.generatPhysicalEdges(300);
  freeMode.init();
}
Program: 143231
Project: 143231
Buggy source:
public void init(){
  SightImpl sight=sightManager.getMainSight();
  SightTreeIterator enabledNodes=new SightTreeIterator(treeStructure,sight);
  for (; enabledNodes.hasNext(); ) {
    PreNode n=enabledNodes.next();
    NodeImpl ni=n.getNode();
    ni.setX(n.getPre() * 50);
    ni.setY(n.getPost() * 50);
  }
  edgeProcessing.init(sightManager.getMainSight());
  sightManager.getMainSight().getSightCache().reset();
}

Fixed version (ground truth):
public void init(){
  SightImpl sight=sightManager.getMainSight();
  edgeProcessing.init(sightManager.getMainSight());
  sightManager.getMainSight().getSightCache().reset();
}
Program: 143232
Project: 143232
Buggy source:
public NodeImpl(){
  x=((float)Math.random()) * 2000 - 1000.0f;
  y=((float)Math.random()) * 2000 - 1000.0f;
  r=(float)Math.random();
  g=(float)Math.random();
  b=(float)Math.random();
}

Fixed version (ground truth):
public NodeImpl(){
  x=((float)Math.random()) * 2000 - 1000.0f;
  y=((float)Math.random()) * 2000 - 1000.0f;
  r=(float)Math.random();
  g=(float)Math.random();
  b=(float)Math.random();
  size=((float)Math.random()) * 20 + 10;
}
Program: 143233
Project: 143233
Buggy source:
private void loadConfig(){
  NB_SUBDIVISIONS=4;
switch (potato.getLevel()) {
case 0:
    RAYON=21f;
  INFLUENCE=0.71f;
RAYON_INFLUENCE_MAX=97f;
break;
case 1:
RAYON=26.5f;
INFLUENCE=0.41f;
RAYON_INFLUENCE_MAX=127.5f;
break;
default :
RAYON=39f;
INFLUENCE=0.2f;
RAYON_INFLUENCE_MAX=179f;
break;
}
INTER=RAYON * Math.sqrt(2.0) / NB_SUBDIVISIONS;
}

Fixed version (ground truth):
private void loadConfig(Node node){
  NB_SUBDIVISIONS=4;
switch (potato.getLevel()) {
case 0:
    RAYON=21f;
  INFLUENCE=0.71f;
RAYON_INFLUENCE_MAX=97f;
break;
case 1:
RAYON=26.5f;
INFLUENCE=0.41f;
RAYON_INFLUENCE_MAX=127.5f;
break;
default :
RAYON=39f;
INFLUENCE=0.2f;
RAYON_INFLUENCE_MAX=179f;
break;
}
INTER=RAYON * Math.sqrt(2.0) / NB_SUBDIVISIONS;
}
Program: 143235
Project: 143235
Buggy source:
public void showTreeAsTable(){
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  int pre=0;
  for (  PreNode p : tree) {
    System.out.println(p.pre + "String_Node_Str" + p.size+ "String_Node_Str"+ p.level+ "String_Node_Str"+ p.parent+ "String_Node_Str"+ p.post+ "String_Node_Str"+ p.preTrace);
    pre++;
  }
}

Fixed version (ground truth):
public void showTreeAsTable(SightImpl sight){
  System.out.println("String_Node_Str");
  System.out.println("String_Node_Str");
  int pre=0;
  for (  PreNode p : tree) {
    boolean enabled=p.isEnabled(sight);
    System.out.println(p.pre + "String_Node_Str" + p.size+ "String_Node_Str"+ p.level+ "String_Node_Str"+ p.parent+ "String_Node_Str"+ p.post+ "String_Node_Str"+ p.preTrace+ "String_Node_Str"+ enabled);
    pre++;
  }
}
Program: 143236
Project: 143236
Buggy source:
public EntityType(final String type){
  this.type=type;
}

Fixed version (ground truth):
@JsonCreator public EntityType(@JsonProperty("String_Node_Str") final String type){
  this.type=type;
}
Program: 143237
Project: 143237
Buggy source:
@JsonCreator public Phrase(@JsonProperty("String_Node_Str") final List<Token> tokens,@JsonProperty("String_Node_Str") final int _phrasePos,@JsonProperty("String_Node_Str") final int _phraseLen,@JsonProperty("String_Node_Str") final int _stubPos){
  phrasePosition=_phrasePos;
  phraseLength=_phraseLen;
  phrase=ImmutableList.copyOf(tokens);
  phraseType=UNKNOWN;
  attachedWordMap=new HashMap<>();
  phraseStubPosition=_stubPos;
  phraseStubLength=phrase.size();
}

Fixed version (ground truth):
@JsonCreator public Phrase(@JsonProperty("String_Node_Str") final List<Token> tokens,@JsonProperty("String_Node_Str") final int _phrasePos,@JsonProperty("String_Node_Str") final int _phraseLen,@JsonProperty("String_Node_Str") final int _stubPos,@JsonProperty("String_Node_Str") final EntityType type){
  phrasePosition=_phrasePos;
  phraseLength=_phraseLen;
  phrase=ImmutableList.copyOf(tokens);
  phraseType=type;
  attachedWordMap=new HashMap<>();
  phraseStubPosition=_stubPos;
  phraseStubLength=phrase.size();
}
Program: 143238
Project: 143238
Buggy source:
public Date(final List<Token> tokens,final int pos,final int len,final int stubPos){
  super(tokens,pos,len,stubPos);
  this.phraseType=EntityType.DATE;
  this.isDate=true;
}

Fixed version (ground truth):
public Date(final List<Token> tokens,final int pos,final int len,final int stubPos){
  super(tokens,pos,len,stubPos,EntityType.DATE);
  this.isDate=true;
}
Program: 143239
Project: 143239
Buggy source:
public Name(final List<Token> tokens,final int pos,final int len,final int stubPos){
  super(tokens,pos,len,stubPos);
}

Fixed version (ground truth):
public Name(final List<Token> tokens,final int pos,final int len,final int stubPos){
  super(tokens,pos,len,stubPos,EntityType.UNKNOWN);
}
Program: 143240
Project: 143240
Buggy source:
/** 
 * This method will do the classification of a Phrase with a EntityType. 
 */
public void classify(){
  EntityType type=null;
  double s=0;
  boolean ambiguous=false;
  for (  final Map.Entry<EntityType,Double> e : score.entrySet()) {
    if (type == null) {
      type=e.getKey();
      s=e.getValue();
    }
 else {
      if (Double.compare(s,e.getValue()) < 0) {
        type=e.getKey();
        s=e.getValue();
      }
 else       if (Double.compare(s,e.getValue()) == 0) {
        ambiguous=true;
      }
    }
  }
  this.phraseType=ambiguous ? UNKNOWN : type;
}

Fixed version (ground truth):
/** 
 * This method will do the classification of a Phrase with a EntityType. 
 */
public void classify(){
  EntityType type=null;
  double s=0;
  boolean ambiguous=false;
  for (  final Map.Entry<EntityType,Double> e : score.entrySet()) {
    if (type == null) {
      type=e.getKey();
      s=e.getValue();
    }
 else {
      if (Double.compare(e.getValue(),s) > 0) {
        type=e.getKey();
        s=e.getValue();
        ambiguous=false;
      }
 else       if (Double.compare(s,e.getValue()) == 0) {
        ambiguous=true;
      }
    }
  }
  this.phraseType=ambiguous ? UNKNOWN : type;
}
Program: 143241
Project: 143241
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public double score(final Phrase p,final int weightIndex){
  final int w=getWeight(weightIndex);
  if (w == 0)   return 0;
  double score=0.0;
  for (  final Token t : p.phrase) {
    final String word=Strings.simplify(toEngLowerCase(t.text));
    final double x=(WORDS.contains(word)) ? 1.0 : 0.0;
    score+=x;
  }
  return score * w;
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") @Override public double score(final Phrase p,final int weightIndex){
  final int w=getWeight(weightIndex);
  if (w == 0)   return 0;
  double score=0.0;
  for (  final Token t : p.phrase) {
    final String word=Strings.simplify(t.text);
    final double x=(WORDS.contains(word)) ? 1.0 : 0.0;
    score+=x;
  }
  return score * w;
}