nus-yam/ex-repair huggingface dataset:
Program: 183949
Project: 183949
Buggy source:
private boolean generateSchedule(final List<Integer> possibleChoices,Set<IntPair> positions,int[][] schedule){
  if (positions == null || positions.size() == 0)   return true;
  IntPair minPosition=positions.iterator().next();
  for (  IntPair position : positions)   if (position.getFirst() < minPosition.getFirst() || (position.getFirst() == minPosition.getFirst() && position.getSecond() < minPosition.getSecond()))   minPosition=position;
  int t=minPosition.getFirst();
  int w=minPosition.getSecond();
  List<Integer> choices=new ArrayList<Integer>(possibleChoices);
  int indexToRemove=(Math.abs(t) - 1) * 2;
  choices.remove(indexToRemove);
  choices.remove(indexToRemove);
  Collections.shuffle(choices);
  for (  Integer o : choices) {
    IntPair randomChoice=new IntPair(o,w);
    if (positions.contains(randomChoice))     continue;
    schedule[w][t - 1]=o;
    if (o > 0)     schedule[w][o - 1]=-t;
 else     schedule[w][-o - 1]=t;
    Set<IntPair> newPositions=new HashSet<IntPair>(positions);
    IntPair absoluteRandomChoice=new IntPair(Math.abs(o),w);
    newPositions.remove(absoluteRandomChoice);
    newPositions.remove(minPosition);
    if (generateSchedule(possibleChoices,newPositions,schedule))     return true;
  }
  return false;
}

Fixed version (ground truth):
private boolean generateSchedule(final List<Integer> possibleChoices,Set<IntPair> positions,int[][] schedule){
  if (positions == null || positions.size() == 0)   return true;
  IntPair minPosition=positions.iterator().next();
  for (  IntPair position : positions)   if (position.getFirst() < minPosition.getFirst() || (position.getFirst() == minPosition.getFirst() && position.getSecond() < minPosition.getSecond()))   minPosition=position;
  int t=minPosition.getFirst();
  int w=minPosition.getSecond();
  List<Integer> choices=new ArrayList<Integer>(possibleChoices);
  int indexToRemove=(Math.abs(t) - 1) * 2;
  choices.remove(indexToRemove);
  choices.remove(indexToRemove);
  Collections.shuffle(choices);
  for (  Integer o : choices) {
    IntPair randomChoice=new IntPair(o,w);
    IntPair absoluteRandomChoice=new IntPair(Math.abs(o),w);
    if (!positions.contains(absoluteRandomChoice))     continue;
    boolean found=false;
    for (int i=0; i < w; i++) {
      if (schedule[i][t - 1] == o.intValue()) {
        found=true;
        break;
      }
    }
    if (found)     continue;
    schedule[w][t - 1]=o;
    if (o > 0)     schedule[w][o - 1]=-t;
 else     schedule[w][-o - 1]=t;
    Set<IntPair> newPositions=new HashSet<IntPair>(positions);
    newPositions.remove(absoluteRandomChoice);
    newPositions.remove(minPosition);
    if (generateSchedule(possibleChoices,newPositions,schedule))     return true;
  }
  return false;
}
Program: 183951
Project: 183951
Buggy source:
private static void writeResultHeader(File outputFile,String prefix,TTPResult result) throws IOException {
  if (!outputFile.exists()) {
    if (!outputFile.createNewFile()) {
      System.err.println("String_Node_Str" + outputFile.getCanonicalPath());
      return;
    }
  }
  PrintWriter writer=new PrintWriter(outputFile,"String_Node_Str");
  writer.print(prefix);
  writer.print(',');
  if (result.getLocalSearchStatistics() != null) {
    result.getLocalSearchStatistics().writeInformationHeader(writer);
  }
 else   if (result.getSearchStatistics() != null) {
    result.getSearchStatistics().writeStatisticsHeader(writer);
  }
  writer.close();
}

Fixed version (ground truth):
private static void writeResultHeader(File outputFile,String prefix,TTPResult result) throws IOException {
  if (!outputFile.exists()) {
    if (!outputFile.createNewFile()) {
      System.err.println("String_Node_Str" + outputFile.getCanonicalPath());
      return;
    }
  }
  PrintWriter writer=new PrintWriter(outputFile,"String_Node_Str");
  writer.print(prefix);
  writer.print(',');
  if (result.getLocalSearchStatistics() != null) {
    result.getLocalSearchStatistics().writeInformationHeader(writer);
  }
 else   if (result.getSearchStatistics() != null) {
    if (result.getSearchStatistics().getSolution() == null)     writer.println();
 else     result.getSearchStatistics().writeStatisticsHeader(writer);
  }
  writer.close();
}
Program: 183953
Project: 183953
Buggy source:
private static void writeGraspIterations(SearchStatistics searchStatistics,final File outputDirectory) throws IOException {
  File localSearchesOutFile=new File(outputDirectory,"String_Node_Str");
  PrintWriter localSearchesWriter=null;
  if (!localSearchesOutFile.createNewFile()) {
    System.err.println("String_Node_Str" + localSearchesOutFile.getCanonicalPath());
  }
 else {
    localSearchesWriter=new PrintWriter(localSearchesOutFile,"String_Node_Str");
    searchStatistics.getLocalSearchStatistics().entrySet().iterator().next().getValue().writeInformationHeader(localSearchesWriter);
  }
  for (  Map.Entry<Integer,LocalSearchStatistics> localSearch : searchStatistics.getLocalSearchStatistics().entrySet()) {
    int iteration=localSearch.getKey();
    LocalSearchStatistics localSearchStatistics=localSearch.getValue();
    writeLocalSearchIteration(iteration,localSearchStatistics,outputDirectory);
    localSearchStatistics.writeInformation(localSearchesWriter);
  }
  if (localSearchesWriter != null)   localSearchesWriter.close();
}

Fixed version (ground truth):
private static void writeGraspIterations(SearchStatistics searchStatistics,final File outputDirectory) throws IOException {
  File localSearchesOutFile=new File(outputDirectory,"String_Node_Str");
  PrintWriter localSearchesWriter=null;
  if (searchStatistics.getLocalSearchStatistics().size() > 0)   if (!localSearchesOutFile.createNewFile()) {
    System.err.println("String_Node_Str" + localSearchesOutFile.getCanonicalPath());
  }
 else {
    localSearchesWriter=new PrintWriter(localSearchesOutFile,"String_Node_Str");
    searchStatistics.getLocalSearchStatistics().entrySet().iterator().next().getValue().writeInformationHeader(localSearchesWriter);
  }
 else   return;
  for (  Map.Entry<Integer,LocalSearchStatistics> localSearch : searchStatistics.getLocalSearchStatistics().entrySet()) {
    int iteration=localSearch.getKey();
    LocalSearchStatistics localSearchStatistics=localSearch.getValue();
    writeLocalSearchIteration(iteration,localSearchStatistics,outputDirectory);
    localSearchStatistics.writeInformation(localSearchesWriter);
  }
  if (localSearchesWriter != null)   localSearchesWriter.close();
}
Program: 183954
Project: 183954
Buggy source:
private static void writeResultsFile(TTPSolution solution,SearchStatistics searchStatistics,LocalSearchStatistics localSearchStatistics,final File outputDirectory) throws IOException {
  File resultOutFile=new File(outputDirectory,"String_Node_Str");
  if (resultOutFile.createNewFile()) {
    PrintWriter resultWriter=new PrintWriter(resultOutFile,"String_Node_Str");
    resultWriter.println(solution.toString());
    resultWriter.println("String_Node_Str" + solution.getCost());
    resultWriter.println("String_Node_Str" + solution.getCostWithPenalty());
    resultWriter.println("String_Node_Str" + solution.getPenalty());
    resultWriter.println("String_Node_Str" + solution.getScTotal());
    if (searchStatistics != null) {
      resultWriter.println("String_Node_Str" + searchStatistics.getStart());
      resultWriter.println("String_Node_Str" + searchStatistics.getEnd());
      resultWriter.println("String_Node_Str" + searchStatistics.getDurationInMilliSeconds() + "String_Node_Str");
      resultWriter.println("String_Node_Str");
      searchStatistics.writeStatisticSum(resultWriter);
      resultWriter.println("String_Node_Str");
      searchStatistics.writeStatisticAverage(resultWriter);
    }
    if (localSearchStatistics != null) {
      localSearchStatistics.writeInformationHeader(resultWriter);
      localSearchStatistics.writeInformation(resultWriter);
    }
    resultWriter.close();
  }
 else   System.err.println("String_Node_Str" + resultOutFile.getCanonicalPath());
}

Fixed version (ground truth):
private static void writeResultsFile(TTPSolution solution,SearchStatistics searchStatistics,LocalSearchStatistics localSearchStatistics,final File outputDirectory) throws IOException {
  File resultOutFile=new File(outputDirectory,"String_Node_Str");
  if (solution == null)   return;
  if (resultOutFile.createNewFile()) {
    PrintWriter resultWriter=new PrintWriter(resultOutFile,"String_Node_Str");
    resultWriter.println(solution.toString());
    resultWriter.println("String_Node_Str" + solution.getCost());
    resultWriter.println("String_Node_Str" + solution.getCostWithPenalty());
    resultWriter.println("String_Node_Str" + solution.getPenalty());
    resultWriter.println("String_Node_Str" + solution.getScTotal());
    if (searchStatistics != null) {
      resultWriter.println("String_Node_Str" + searchStatistics.getStart());
      resultWriter.println("String_Node_Str" + searchStatistics.getEnd());
      resultWriter.println("String_Node_Str" + searchStatistics.getDurationInMilliSeconds() + "String_Node_Str");
      resultWriter.println("String_Node_Str");
      searchStatistics.writeStatisticSum(resultWriter);
      resultWriter.println("String_Node_Str");
      searchStatistics.writeStatisticAverage(resultWriter);
    }
    if (localSearchStatistics != null) {
      localSearchStatistics.writeInformationHeader(resultWriter);
      localSearchStatistics.writeInformation(resultWriter);
    }
    resultWriter.close();
  }
 else   System.err.println("String_Node_Str" + resultOutFile.getCanonicalPath());
}
Program: 183955
Project: 183955
Buggy source:
@Override public TTPSolution getNext(){
  TTPSolution next=new TTPSolution(baseSolution);
  int[][] schedule=next.getSchedule();
  int tmp;
  for (int i=0; i < totalGames; i++) {
    if (schedule[i][index1] == (index2 + 1)) {
      schedule[i][index1]=-(index2 + 1);
      schedule[i][index2]=(index1 + 1);
    }
 else     if (schedule[i][index1] == -(index2 + 1)) {
      schedule[i][index1]=(index2 + 1);
      schedule[i][index2]=-(index1 + 1);
    }
 else {
      tmp=schedule[i][index1];
      schedule[i][index1]=schedule[i][index2];
      schedule[i][index2]=tmp;
      if (schedule[i][index1] < 0)       schedule[i][-schedule[i][index1] - 1]=index1 + 1;
 else       schedule[i][schedule[i][index1] - 1]=-(index1 + 1);
      if (schedule[i][index2] < 0)       schedule[i][-schedule[i][index2] - 1]=index2 + 1;
 else       schedule[i][schedule[i][index2] - 1]=-(index2 + 1);
    }
  }
  next.setSchedule(schedule);
  TtpSolutionHelper.updateTeam(next,index1 + 1);
  TtpSolutionHelper.updateTeam(next,index2 + 1);
  index2++;
  if (index2 == totalTeams) {
    index1++;
    index2=index1 + 1;
  }
  return next;
}

Fixed version (ground truth):
@Override public TTPSolution getNext(){
  TTPSolution next=new TTPSolution(baseSolution);
  int[][] schedule=next.getSchedule();
  int tmp;
  for (int i=0; i < totalGames; i++) {
    if (schedule[i][index1] == (index2 + 1)) {
      schedule[i][index1]=-(index2 + 1);
      schedule[i][index2]=(index1 + 1);
    }
 else     if (schedule[i][index1] == -(index2 + 1)) {
      schedule[i][index1]=(index2 + 1);
      schedule[i][index2]=-(index1 + 1);
    }
 else {
      tmp=schedule[i][index1];
      schedule[i][index1]=schedule[i][index2];
      schedule[i][index2]=tmp;
      if (schedule[i][index1] < 0)       schedule[i][-schedule[i][index1] - 1]=index1 + 1;
 else       schedule[i][schedule[i][index1] - 1]=-(index1 + 1);
      if (schedule[i][index2] < 0)       schedule[i][-schedule[i][index2] - 1]=index2 + 1;
 else       schedule[i][schedule[i][index2] - 1]=-(index2 + 1);
    }
  }
  next.setSchedule(schedule);
  TtpSolutionHelper.updateAll(next);
  index2++;
  if (index2 == totalTeams) {
    index1++;
    index2=index1 + 1;
  }
  return next;
}
Program: 183956
Project: 183956
Buggy source:
public void setCost(int cost){
  this.cost=cost;
  if (cost < 0) {
    int wtf=0;
    wtf++;
  }
}

Fixed version (ground truth):
public void setCost(int cost){
  this.cost=cost;
}
Program: 183957
Project: 183957
Buggy source:
public static void updateAll(TTPSolution next){
  for (int i=0; i < next.getSchedule()[0].length; i++) {
    updateTeam(next,i + 1);
  }
}

Fixed version (ground truth):
public static void updateAll(TTPSolution sol){
  int costs=0;
  for (int i=0; i < sol.getSchedule()[0].length; i++) {
    sol.getTeamCost()[i]=calculateTeamCosts(i + 1,sol);
    costs+=sol.getTeamCost()[i];
    sol.updateSoftConstraintsViolations(i,calculateWeakViolations(i + 1,sol));
  }
  sol.setCost(costs);
}
Program: 183958
Project: 183958
Buggy source:
@Test public void testTabuSearch_ShouldReturnSolution_1(){
  sc.setProblemInstance(instance);
  TTPSolution sol=sc.getInitialSolution();
  int[][] schedule={{-5,-3,2,6,1,-4},{-3,6,1,-5,4,-2},{2,-1,-4,3,-6,5},{4,-5,6,-1,2,-3},{-6,3,-2,5,-4,1},{-4,-6,5,1,-3,2},{-2,1,4,-3,6,-5},{3,5,-1,-6,-2,4},{6,4,-5,-2,3,-1},{5,-4,-6,2,-1,3}};
  sol.setSchedule(schedule);
  TtpSolutionHelper.initializeSolution(sol,instance);
  System.out.println("String_Node_Str" + sol.getCost() + "String_Node_Str"+ sol.isLegal());
  TTPSolution tabuSol=ts.doLocalSearch(sol);
  assertThat(tabuSol,notNullValue());
  assertThat(TtpSolutionHelper.checkSolution(tabuSol),is(true));
  System.out.println("String_Node_Str" + tabuSol.getCost() + "String_Node_Str"+ tabuSol.isLegal());
}

Fixed version (ground truth):
@Test public void testTabuSearch_ShouldReturnSolution_1(){
  sc.setProblemInstance(instance);
  TTPSolution sol=sc.getInitialSolution();
  TtpSolutionHelper.initializeSolution(sol,instance);
  System.out.println("String_Node_Str" + sol.getCost() + "String_Node_Str"+ sol.isLegal());
  TTPSolution tabuSol=ts.doLocalSearch(sol);
  assertThat(tabuSol,notNullValue());
  assertThat(TtpSolutionHelper.checkSolution(tabuSol),is(true));
  int costs=TtpSolutionHelper.calculateCosts(tabuSol.getSchedule(),instance);
  assertThat(tabuSol.getCost(),is(costs));
  System.out.println("String_Node_Str" + tabuSol.getCost() + "String_Node_Str"+ tabuSol.isLegal());
}
Program: 183959
Project: 183959
Buggy source:
@Before public void setUp() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  sc=new SimpleConstruction();
  ts=new TabuSearch();
  NeighborhoodUnion<TTPSolution> neighborhood=new NeighborhoodUnion<TTPSolution>();
  neighborhood.addNeighborhood(new TwoOptSwapRoundsNeighborhood());
  neighborhood.addNeighborhood(new TwoOptSwapTeamsNeighborhood());
  neighborhood.addNeighborhood(new SwapHomeVisitorNeighborhood());
  ts.setNeighborhood(neighborhood);
}

Fixed version (ground truth):
@Before public void setUp() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  sc=new SimpleConstruction();
  ts=new TabuSearch();
  ts.setTabuListLength(50);
  ts.setMaxNoImprovement(500);
  NeighborhoodUnion<TTPSolution> neighborhood=new NeighborhoodUnion<TTPSolution>();
  neighborhood.addNeighborhood(new TwoOptSwapRoundsNeighborhood());
  neighborhood.addNeighborhood(new TwoOptSwapTeamsNeighborhood());
  neighborhood.addNeighborhood(new SwapHomeVisitorNeighborhood());
  ts.setNeighborhood(neighborhood);
}
Program: 183960
Project: 183960
Buggy source:
@Test public void testCalculateCosts_shouldReturn23916() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  sc.setProblemInstance(instance);
  TTPSolution sol=sc.getInitialSolution();
  int[][] schedule={{5,-6,-4,3,-1,2},{2,-1,5,-6,-3,4},{6,-5,4,-3,2,-1},{-3,4,1,-2,6,-5},{-4,5,-6,1,-2,3},{-6,-3,2,5,-4,1},{3,-4,-1,2,-6,5},{4,6,-5,-1,3,-2},{-2,1,6,-5,4,-3},{-5,3,-2,6,1,-4}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(23916));
}

Fixed version (ground truth):
@Test public void testCalculateCosts_shouldReturn23916() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  int[][] schedule={{5,-6,-4,3,-1,2},{2,-1,5,-6,-3,4},{6,-5,4,-3,2,-1},{-3,4,1,-2,6,-5},{-4,5,-6,1,-2,3},{-6,-3,2,5,-4,1},{3,-4,-1,2,-6,5},{4,6,-5,-1,3,-2},{-2,1,6,-5,4,-3},{-5,3,-2,6,1,-4}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(23916));
}
Program: 183961
Project: 183961
Buggy source:
@Test public void testCalculateCosts_shouldReturn8276(){
  sc.setProblemInstance(instance);
  TTPSolution sol=sc.getInitialSolution();
  int[][] schedule={{3,4,-1,-2},{2,-1,4,-3},{4,-3,2,-1},{-3,-4,1,2},{-2,1,-4,3},{-4,3,-2,1}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(8276));
}

Fixed version (ground truth):
@Test public void testCalculateCosts_shouldReturn8276(){
  int[][] schedule={{3,4,-1,-2},{2,-1,4,-3},{4,-3,2,-1},{-3,-4,1,2},{-2,1,-4,3},{-4,3,-2,1}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(8276));
}
Program: 183962
Project: 183962
Buggy source:
@Test public void testCalculateCosts_shouldReturn23978() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  sc.setProblemInstance(instance);
  TTPSolution sol=sc.getInitialSolution();
  int[][] schedule={{-5,-3,2,6,1,-4},{-3,6,1,-5,4,-2},{4,-5,6,-1,2,-3},{2,-1,-4,3,-6,5},{-6,3,-2,5,-4,1},{-4,-6,5,1,-3,2},{-2,1,4,-3,6,-5},{6,4,-5,-2,3,-1},{3,5,-1,-6,-2,4},{5,-4,-6,2,-1,3}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(23978));
}

Fixed version (ground truth):
@Test public void testCalculateCosts_shouldReturn23978() throws Exception {
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str");
  instance=TTPProblemInstanceReader.readProblemInstance(file);
  int[][] schedule={{-5,-3,2,6,1,-4},{-3,6,1,-5,4,-2},{4,-5,6,-1,2,-3},{2,-1,-4,3,-6,5},{-6,3,-2,5,-4,1},{-4,-6,5,1,-3,2},{-2,1,4,-3,6,-5},{6,4,-5,-2,3,-1},{3,5,-1,-6,-2,4},{5,-4,-6,2,-1,3}};
  int result=TtpSolutionHelper.calculateCosts(schedule,instance);
  assertThat(result,is(23978));
}
Program: 183963
Project: 183963
Buggy source:
@Override public void init(T solution){
  this.baseSolution=solution;
  neighborhood_one.init(baseSolution);
  currentBase=null;
}

Fixed version (ground truth):
@Override public void init(T solution){
  lastSolution=solution;
  newNeighborhood=true;
  nIndex=0;
}
Program: 183964
Project: 183964
Buggy source:
@Override public boolean hasNext(){
  if (currentBase == null) {
    if (neighborhood_one.hasNext()) {
      return true;
    }
 else     return false;
  }
 else {
    if (neighborhood_Two.hasNext()) {
      return true;
    }
 else {
      if (neighborhood_one.hasNext()) {
        return true;
      }
 else       return false;
    }
  }
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  if (currentNeighborhood != null) {
    while (!currentNeighborhood.hasNext() && !newNeighborhood) {
      nIndex--;
      newNeighborhood=false;
      if (nIndex < 0)       break;
      currentNeighborhood=neighborhoods.get(nIndex);
    }
  }
  if (nIndex >= 0)   return true;
  return false;
}
Program: 183965
Project: 183965
Buggy source:
@Override public T getNext(){
  if (currentBase == null) {
    if (neighborhood_one.hasNext()) {
      currentBase=neighborhood_one.getNext();
      neighborhood_Two.init(currentBase);
      return currentBase;
    }
 else     return null;
  }
 else {
    if (neighborhood_Two.hasNext()) {
      return neighborhood_Two.getNext();
    }
 else {
      if (neighborhood_one.hasNext()) {
        currentBase=neighborhood_one.getNext();
        neighborhood_Two.init(currentBase);
        return currentBase;
      }
 else       return null;
    }
  }
}

Fixed version (ground truth):
@Override public T getNext(){
  if (newNeighborhood) {
    currentNeighborhood=neighborhoods.get(nIndex);
    currentNeighborhood.init(lastSolution);
    if ((nIndex + 1) < neighborhoods.size()) {
      nIndex++;
      newNeighborhood=true;
      return getNext();
    }
 else {
      newNeighborhood=false;
      lastSolution=currentNeighborhood.getNext();
      return lastSolution;
    }
  }
 else {
    while (!currentNeighborhood.hasNext()) {
      nIndex--;
      newNeighborhood=false;
      if (nIndex < 0)       break;
      currentNeighborhood=neighborhoods.get(nIndex);
    }
    if (nIndex >= 0) {
      lastSolution=currentNeighborhood.getNext();
      if ((nIndex + 1) < neighborhoods.size()) {
        nIndex++;
        newNeighborhood=true;
      }
      return lastSolution;
    }
 else     return null;
  }
}
Program: 183966
Project: 183966
Buggy source:
public static boolean checkSolution(TTPSolution next){
  for (int i=0; i < next.getSchedule().length; i++) {
    for (int j=0; j < next.getSchedule()[i].length; j++) {
      int enemy=next.getSchedule()[i][j];
      if (enemy < 0) {
        if (next.getSchedule()[i][-enemy - 1] != j + 1)         return false;
        if (-enemy == j + 1)         return false;
      }
 else {
        if (next.getSchedule()[i][enemy - 1] != -(j + 1))         return false;
        if (enemy == j + 1)         return false;
      }
    }
  }
  return true;
}

Fixed version (ground truth):
public static boolean checkSolution(TTPSolution next){
  for (int i=0; i < next.getSchedule().length; i++) {
    for (int j=0; j < next.getSchedule()[i].length; j++) {
      int enemy=next.getSchedule()[i][j];
      if (enemy < 0) {
        if (next.getSchedule()[i][-enemy - 1] != j + 1)         return false;
        if (-enemy == j + 1)         return false;
      }
 else {
        if (next.getSchedule()[i][enemy - 1] != -(j + 1))         return false;
        if (enemy == j + 1)         return false;
      }
    }
  }
  for (int i=0; i < next.getSchedule()[0].length; i++) {
    boolean[] homeGames=new boolean[next.getSchedule()[i].length];
    boolean[] visitorGames=new boolean[next.getSchedule()[i].length];
    for (int j=0; j < next.getSchedule().length; j++) {
      if (next.getSchedule()[j][i] > 0) {
        homeGames[next.getSchedule()[j][i] - 1]=true;
      }
 else {
        visitorGames[-next.getSchedule()[j][i] - 1]=true;
      }
    }
    for (int k=0; k < next.getSchedule()[i].length - 1; k++) {
      if (k == i)       continue;
      if (!homeGames[k])       return false;
      if (!visitorGames[k])       return false;
    }
  }
  return true;
}
Program: 183967
Project: 183967
Buggy source:
public SlapCommand(SlapPlugin plugin){
  this.plugin=plugin;
}

Fixed version (ground truth):
public SlapCommand(SlapPlugin plugin){
  this.plugin=plugin;
  this.methods=new SlapMethods(plugin);
}
Program: 183968
Project: 183968
Buggy source:
@Override public boolean onCommand(CommandSender slapper,Command command,String label,String[] split){
  if (plugin.usePermissions) {
    if (slapper instanceof Player && !(plugin.permissionHandler.has((Player)slapper,"String_Node_Str"))) {
      slapper.sendMessage(ChatColor.RED + "String_Node_Str");
      return true;
    }
  }
 else   if (!(slapper.isOp())) {
    slapper.sendMessage(ChatColor.RED + "String_Node_Str");
    return true;
  }
  String slapperName;
  if (slapper instanceof Player) {
    Player slapperCast=(Player)slapper;
    slapperName=slapperCast.getDisplayName();
  }
 else   if (slapper instanceof ConsoleCommandSender) {
    slapperName="String_Node_Str";
  }
 else {
    slapperName="String_Node_Str";
  }
  if (split.length == 1 || split.length == 2) {
    List<Player> matchedPlayers=plugin.getServer().matchPlayer(split[0]);
    String slappeeName=split[0];
    if (matchedPlayers.size() == 1) {
      if (split.length == 1) {
        slapPlayer(matchedPlayers.get(0),2,slapperName);
      }
 else {
        float force;
        try {
          force=Float.parseFloat(split[1]);
        }
 catch (        NumberFormatException e) {
          slapper.sendMessage("String_Node_Str");
          return true;
        }
        if (force > 10) {
          force=10;
        }
 else         if (force <= 0) {
          force=0.1f;
        }
        slapPlayer(matchedPlayers.get(0),force,slapperName);
      }
    }
 else     if (matchedPlayers.isEmpty()) {
      slapper.sendMessage("String_Node_Str" + slappeeName + "String_Node_Str");
    }
 else     if (matchedPlayers.size() > 1) {
      slapper.sendMessage(slappeeName + "String_Node_Str");
    }
 else {
      slapper.sendMessage("String_Node_Str");
    }
    return true;
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
@Override public boolean onCommand(CommandSender slapper,Command command,String label,String[] split){
  String slapperName;
  if (slapper instanceof Player) {
    Player slapperCast=(Player)slapper;
    slapperName=slapperCast.getDisplayName();
  }
 else   if (slapper instanceof ConsoleCommandSender) {
    slapperName="String_Node_Str";
  }
 else {
    slapperName="String_Node_Str";
  }
  if (split.length == 1 || split.length == 2) {
    List<Player> matchedPlayers=plugin.getServer().matchPlayer(split[0]);
    String slappeeName=split[0];
    if (matchedPlayers.size() == 1) {
      slappeeName=matchedPlayers.get(0).getDisplayName();
      float force;
      if (split.length == 1) {
        force=2;
      }
 else {
        force=methods.getForce(split[1]);
        if (force == -1) {
          slapper.sendMessage("String_Node_Str");
          return true;
        }
      }
      methods.slapPlayer(matchedPlayers.get(0),force,slapperName,true);
    }
 else     if (matchedPlayers.isEmpty()) {
      slapper.sendMessage("String_Node_Str" + slappeeName + "String_Node_Str");
    }
 else     if (matchedPlayers.size() > 1) {
      slapper.sendMessage(slappeeName + "String_Node_Str");
    }
 else {
      slapper.sendMessage("String_Node_Str");
    }
    return true;
  }
 else {
    return false;
  }
}
Program: 183969
Project: 183969
Buggy source:
/** 
 * Load and parse the YAML config file
 */
public static void load(){
  File dataDirectory=new File("String_Node_Str" + File.separator + "String_Node_Str"+ File.separator);
  dataDirectory.mkdirs();
  File file=new File("String_Node_Str" + File.separator + "String_Node_Str","String_Node_Str");
  config=new Configuration(file);
  config.load();
  if (!file.exists()) {
    config.setProperty("String_Node_Str",getDefaultMessages());
    config.setProperty("String_Node_Str",debugMode);
    config.save();
  }
  setSettings();
}

Fixed version (ground truth):
public void load(){
  plugin.reloadConfig();
  config=plugin.getConfig();
  config.addDefault("String_Node_Str",false);
  config.addDefault("String_Node_Str","String_Node_Str");
  config.addDefault("String_Node_Str","String_Node_Str");
  config.addDefault("String_Node_Str","String_Node_Str");
  config.addDefault("String_Node_Str","String_Node_Str");
  config.addDefault("String_Node_Str","String_Node_Str");
  config.options().copyDefaults(true);
  loadMessages();
  isDebug=config.getBoolean("String_Node_Str");
  plugin.saveConfig();
}
Program: 183970
Project: 183970
Buggy source:
public void debug(String s){
  if (SlapConfig.debugMode) {
    logger.log(Level.INFO,"String_Node_Str" + s);
  }
}

Fixed version (ground truth):
public void debug(String s){
  if (plugin.config.isDebug()) {
    logger.log(Level.INFO,"String_Node_Str" + s);
  }
}
Program: 183974
Project: 183974
Buggy source:
public void readFromParcel(Parcel source){
  final int size=source.readInt();
  for (int i=0; i < size; i++) {
    this.add(source.<EntityDelta>readParcelable(null));
  }
}

Fixed version (ground truth):
public void readFromParcel(Parcel source){
  final ClassLoader loader=getClass().getClassLoader();
  final int size=source.readInt();
  for (int i=0; i < size; i++) {
    this.add(source.<EntityDelta>readParcelable(loader));
  }
}
Program: 183975
Project: 183975
Buggy source:
public void onClick(DialogInterface dialog,int which){
  dialog.dismiss();
  final ValuesDelta structuredName=allNames.get(which);
  structuredName.put(Data.IS_PRIMARY,1);
  structuredName.put(Data.IS_SUPER_PRIMARY,1);
}

Fixed version (ground truth):
public void onClick(DialogInterface dialog,int which){
  dialog.dismiss();
  final Account account=accountAdapter.getItem(which);
  createContact(account);
}
Program: 183976
Project: 183976
Buggy source:
@Override protected AlertDialog.Builder doInBackground(final EditContactActivity target,Void... params){
  final Sources sources=Sources.getInstance(target);
  final Context dialogContext=new ContextThemeWrapper(target,android.R.style.Theme_Light);
  final LayoutInflater dialogInflater=(LayoutInflater)dialogContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
  final ArrayList<Account> writable=sources.getAccounts(true);
  if (writable.isEmpty()) {
    selectAccount(null);
    return null;
  }
  if (writable.size() == 1) {
    selectAccount(writable.get(0));
    return null;
  }
  final ArrayAdapter<Account> accountAdapter=new ArrayAdapter<Account>(target,android.R.layout.simple_list_item_2,writable){
    @Override public View getView(    int position,    View convertView,    ViewGroup parent){
      if (convertView == null) {
        convertView=dialogInflater.inflate(android.R.layout.simple_list_item_2,parent,false);
      }
      final TextView text1=(TextView)convertView.findViewById(android.R.id.text1);
      final TextView text2=(TextView)convertView.findViewById(android.R.id.text2);
      final Account account=this.getItem(position);
      final ContactsSource source=sources.getInflatedSource(account.type,ContactsSource.LEVEL_SUMMARY);
      text1.setText(account.name);
      text2.setText(source.getDisplayLabel(target));
      return convertView;
    }
  }
;
  final DialogInterface.OnClickListener clickListener=new DialogInterface.OnClickListener(){
    public void onClick(    DialogInterface dialog,    int which){
      dialog.dismiss();
      final Account account=accountAdapter.getItem(which);
      selectAccount(account);
      EditContactActivity target=mTarget.get();
      if (target != null) {
        target.bindEditors();
      }
    }
  }
;
  final DialogInterface.OnCancelListener cancelListener=new DialogInterface.OnCancelListener(){
    public void onCancel(    DialogInterface dialog){
      if (!target.hasValidState()) {
        target.finish();
      }
    }
  }
;
  final AlertDialog.Builder builder=new AlertDialog.Builder(target);
  builder.setTitle(R.string.dialog_new_contact_account);
  builder.setSingleChoiceItems(accountAdapter,0,clickListener);
  builder.setOnCancelListener(cancelListener);
  return builder;
}

Fixed version (ground truth):
@Override protected ArrayList<Account> doInBackground(final EditContactActivity target,Void... params){
  return Sources.getInstance(target).getAccounts(true);
}
Program: 183977
Project: 183977
Buggy source:
@Override protected void onPostExecute(EditContactActivity target,AlertDialog.Builder result){
  if (result != null) {
    target.showAndManageDialog(result.create());
  }
 else {
    target.bindEditors();
  }
}

Fixed version (ground truth):
@Override protected void onPostExecute(final EditContactActivity target,ArrayList<Account> accounts){
  target.selectAccountAndCreateContact(accounts);
}
Program: 183978
Project: 183978
Buggy source:
@Override public View getView(int position,View convertView,ViewGroup parent){
  if (convertView == null) {
    convertView=dialogInflater.inflate(android.R.layout.simple_list_item_1,parent,false);
  }
  final ValuesDelta structuredName=this.getItem(position);
  final String displayName=structuredName.getAsString(StructuredName.DISPLAY_NAME);
  ((TextView)convertView).setText(displayName);
  return convertView;
}

Fixed version (ground truth):
@Override public View getView(int position,View convertView,ViewGroup parent){
  if (convertView == null) {
    convertView=dialogInflater.inflate(android.R.layout.simple_list_item_2,parent,false);
  }
  final TextView text1=(TextView)convertView.findViewById(android.R.id.text1);
  final TextView text2=(TextView)convertView.findViewById(android.R.id.text2);
  final Account account=this.getItem(position);
  final ContactsSource source=sources.getInflatedSource(account.type,ContactsSource.LEVEL_SUMMARY);
  text1.setText(account.name);
  text2.setText(source.getDisplayLabel(EditContactActivity.this));
  return convertView;
}
Program: 183979
Project: 183979
Buggy source:
public void onCancel(DialogInterface dialog){
  if (!target.hasValidState()) {
    target.finish();
  }
}

Fixed version (ground truth):
public void onCancel(DialogInterface dialog){
  if (!hasValidState()) {
    finish();
  }
}
Program: 183980
Project: 183980
Buggy source:
/** 
 * Return   {@link ContactsSource} for the given account type.
 */
public ContactsSource getInflatedSource(String accountType,int inflateLevel){
  ContactsSource source=mSources.get(accountType);
  if (source == null)   source=mFallbackSource;
  if (source.isInflated(inflateLevel)) {
    return source;
  }
 else {
    source.ensureInflated(mApplicationContext,inflateLevel);
    return source;
  }
}

Fixed version (ground truth):
/** 
 * Return   {@link ContactsSource} for the given account type.
 */
public ContactsSource getInflatedSource(String accountType,int inflateLevel){
  ContactsSource source=mSources.get(accountType);
  if (source == null)   source=mFallbackSource;
  if (source.isInflated(inflateLevel)) {
    return source;
  }
 else {
    source.ensureInflated(mContext,inflateLevel);
    return source;
  }
}
Program: 183983
Project: 183983
Buggy source:
private Bitmap loadContactPhoto(Uri lookupUri,BitmapFactory.Options options){
  Cursor cursor=null;
  Bitmap bm=null;
  try {
    Uri contactUri=Contacts.lookupContact(getContentResolver(),lookupUri);
    Uri photoUri=Uri.withAppendedPath(contactUri,Contacts.Photo.CONTENT_DIRECTORY);
    cursor=getContentResolver().query(photoUri,new String[]{Photo.PHOTO},null,null,null);
    if (cursor != null && cursor.moveToFirst()) {
      bm=ContactsUtils.loadContactPhoto(cursor,0,options);
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  if (bm == null) {
    final int[] fallbacks={R.drawable.ic_contact_picture,R.drawable.ic_contact_picture_2,R.drawable.ic_contact_picture_3};
    bm=BitmapFactory.decodeResource(getResources(),fallbacks[new Random().nextInt(fallbacks.length)]);
  }
  return bm;
}

Fixed version (ground truth):
private Bitmap loadContactPhoto(Uri selectedUri,BitmapFactory.Options options){
  Uri contactUri=null;
  if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(selectedUri))) {
    contactUri=Contacts.lookupContact(getContentResolver(),selectedUri);
  }
 else {
    Cursor cursor=getContentResolver().query(selectedUri,new String[]{Data.CONTACT_ID},null,null,null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        final long contactId=cursor.getLong(0);
        contactUri=ContentUris.withAppendedId(Contacts.CONTENT_URI,contactId);
      }
    }
  finally {
      if (cursor != null)       cursor.close();
    }
  }
  Cursor cursor=null;
  Bitmap bm=null;
  try {
    Uri photoUri=Uri.withAppendedPath(contactUri,Contacts.Photo.CONTENT_DIRECTORY);
    cursor=getContentResolver().query(photoUri,new String[]{Photo.PHOTO},null,null,null);
    if (cursor != null && cursor.moveToFirst()) {
      bm=ContactsUtils.loadContactPhoto(cursor,0,options);
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  if (bm == null) {
    final int[] fallbacks={R.drawable.ic_contact_picture,R.drawable.ic_contact_picture_2,R.drawable.ic_contact_picture_3};
    bm=BitmapFactory.decodeResource(getResources(),fallbacks[new Random().nextInt(fallbacks.length)]);
  }
  return bm;
}
Program: 183984
Project: 183984
Buggy source:
@Override public Object getItem(int pos){
  if (mSuggestionsCursorCount != 0 && pos <= mSuggestionsCursorCount) {
    mSuggestionsCursor.moveToPosition(getRealPosition(pos));
    return mSuggestionsCursor;
  }
 else {
    return super.getItem(getRealPosition(pos));
  }
}

Fixed version (ground truth):
@Override public Object getItem(int pos){
  if (mSuggestionsCursorCount != 0 && pos <= mSuggestionsCursorCount) {
    mSuggestionsCursor.moveToPosition(getRealPosition(pos));
    return mSuggestionsCursor;
  }
 else   if (isSearchAllContactsItemPosition(pos)) {
    return null;
  }
 else {
    return super.getItem(getRealPosition(pos));
  }
}
Program: 183985
Project: 183985
Buggy source:
@Override public long getItemId(int pos){
  if (mSuggestionsCursorCount != 0 && pos < mSuggestionsCursorCount + 2) {
    if (mSuggestionsCursor.moveToPosition(pos - 1)) {
      return mSuggestionsCursor.getLong(mRowIDColumn);
    }
 else {
      return 0;
    }
  }
  return super.getItemId(getRealPosition(pos));
}

Fixed version (ground truth):
@Override public long getItemId(int pos){
  if (mSuggestionsCursorCount != 0 && pos < mSuggestionsCursorCount + 2) {
    if (mSuggestionsCursor.moveToPosition(pos - 1)) {
      return mSuggestionsCursor.getLong(mRowIDColumn);
    }
 else {
      return 0;
    }
  }
 else   if (isSearchAllContactsItemPosition(pos)) {
    return 0;
  }
  return super.getItemId(getRealPosition(pos));
}
Program: 183988
Project: 183988
Buggy source:
private Bitmap loadContactPhoto(Uri lookupUri,BitmapFactory.Options options){
  Cursor cursor=null;
  Bitmap bm=null;
  try {
    Uri contactUri=Contacts.lookupContact(getContentResolver(),lookupUri);
    Uri photoUri=Uri.withAppendedPath(contactUri,Contacts.Photo.CONTENT_DIRECTORY);
    cursor=getContentResolver().query(photoUri,new String[]{Photo.PHOTO},null,null,null);
    if (cursor != null && cursor.moveToFirst()) {
      bm=ContactsUtils.loadContactPhoto(cursor,0,options);
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  if (bm == null) {
    final int[] fallbacks={R.drawable.ic_contact_picture,R.drawable.ic_contact_picture_2,R.drawable.ic_contact_picture_3};
    bm=BitmapFactory.decodeResource(getResources(),fallbacks[new Random().nextInt(fallbacks.length)]);
  }
  return bm;
}

Fixed version (ground truth):
private Bitmap loadContactPhoto(Uri selectedUri,BitmapFactory.Options options){
  Uri contactUri=null;
  if (Contacts.CONTENT_ITEM_TYPE.equals(getContentResolver().getType(selectedUri))) {
    contactUri=Contacts.lookupContact(getContentResolver(),selectedUri);
  }
 else {
    Cursor cursor=getContentResolver().query(selectedUri,new String[]{Data.CONTACT_ID},null,null,null);
    try {
      if (cursor != null && cursor.moveToFirst()) {
        final long contactId=cursor.getLong(0);
        contactUri=ContentUris.withAppendedId(Contacts.CONTENT_URI,contactId);
      }
    }
  finally {
      if (cursor != null)       cursor.close();
    }
  }
  Cursor cursor=null;
  Bitmap bm=null;
  try {
    Uri photoUri=Uri.withAppendedPath(contactUri,Contacts.Photo.CONTENT_DIRECTORY);
    cursor=getContentResolver().query(photoUri,new String[]{Photo.PHOTO},null,null,null);
    if (cursor != null && cursor.moveToFirst()) {
      bm=ContactsUtils.loadContactPhoto(cursor,0,options);
    }
  }
  finally {
    if (cursor != null) {
      cursor.close();
    }
  }
  if (bm == null) {
    final int[] fallbacks={R.drawable.ic_contact_picture,R.drawable.ic_contact_picture_2,R.drawable.ic_contact_picture_3};
    bm=BitmapFactory.decodeResource(getResources(),fallbacks[new Random().nextInt(fallbacks.length)]);
  }
  return bm;
}
Program: 183989
Project: 183989
Buggy source:
private void sendFetchImageMessage(ImageView view){
  final PhotoInfo info=(PhotoInfo)view.getTag();
  if (info == null) {
    return;
  }
  final long photoId=info.photoId;
  if (photoId == 0) {
    return;
  }
  mImageFetcher=new ImageDbFetcher(photoId,view);
synchronized (ContactsListActivity.this) {
    if (sImageFetchThreadPool == null) {
      sImageFetchThreadPool=Executors.newFixedThreadPool(3);
    }
    sImageFetchThreadPool.execute(mImageFetcher);
  }
}

Fixed version (ground truth):
private void sendFetchImageMessage(ImageView view){
  final PhotoInfo info=(PhotoInfo)view.getTag();
  if (info == null) {
    return;
  }
  final long photoId=info.photoId;
  if (photoId == 0) {
    return;
  }
  mImageFetcher=new ImageDbFetcher(photoId,view);
synchronized (ContactsListActivity.this) {
    if (sImageFetchThreadPool == null) {
      sImageFetchThreadPool=Executors.newFixedThreadPool(1);
    }
    sImageFetchThreadPool.execute(mImageFetcher);
  }
}
Program: 183990
Project: 183990
Buggy source:
private void sendFetchImageMessage(ImageView view){
  final PhotoInfo info=(PhotoInfo)view.getTag();
  if (info == null) {
    return;
  }
  final long photoId=info.photoId;
  if (photoId == 0) {
    return;
  }
  mImageFetcher=new ImageDbFetcher(photoId,view);
synchronized (ContactsListActivity.this) {
    if (sImageFetchThreadPool == null) {
      sImageFetchThreadPool=Executors.newFixedThreadPool(3);
    }
    sImageFetchThreadPool.execute(mImageFetcher);
  }
}

Fixed version (ground truth):
private void sendFetchImageMessage(ImageView view){
  final PhotoInfo info=(PhotoInfo)view.getTag();
  if (info == null) {
    return;
  }
  final long photoId=info.photoId;
  if (photoId == 0) {
    return;
  }
  mImageFetcher=new ImageDbFetcher(photoId,view);
synchronized (ContactsListActivity.this) {
    if (sImageFetchThreadPool == null) {
      sImageFetchThreadPool=Executors.newFixedThreadPool(1);
    }
    sImageFetchThreadPool.execute(mImageFetcher);
  }
}
Program: 183991
Project: 183991
Buggy source:
/** 
 * @return true if the widget with the phone number digits is empty.
 */
private boolean isDigitsEmpty(){
  return mDigits.length() != 0;
}

Fixed version (ground truth):
/** 
 * @return true if the widget with the phone number digits is empty.
 */
private boolean isDigitsEmpty(){
  return mDigits.length() == 0;
}
Program: 183992
Project: 183992
Buggy source:
/** 
 * Set the visibility of secondary sections, along with header icon. <p>If the source is read-only and there's no secondary fields, the entire secondary section will be hidden.
 */
private void setSecondaryVisible(boolean makeVisible){
  mSecondaryVisible=makeVisible;
  if (!mIsSourceReadOnly && mSecondary.getChildCount() > 0) {
    mSecondary.setVisibility(makeVisible ? View.VISIBLE : View.GONE);
    mSecondaryHeader.setCompoundDrawablesWithIntrinsicBounds(makeVisible ? mSecondaryOpen : mSecondaryClosed,null,null,null);
  }
 else {
    mSecondaryHeader.setVisibility(View.GONE);
    mSecondary.setVisibility(View.GONE);
  }
}

Fixed version (ground truth):
/** 
 * Set the visibility of secondary sections, along with header icon. <p>If the source is read-only and there's no secondary fields, the entire secondary section will be hidden.
 */
private void setSecondaryVisible(boolean makeVisible){
  mSecondaryVisible=makeVisible;
  if (!mIsSourceReadOnly && mSecondary.getChildCount() > 0) {
    mSecondaryHeader.setVisibility(View.VISIBLE);
    mSecondaryHeader.setCompoundDrawablesWithIntrinsicBounds(makeVisible ? mSecondaryOpen : mSecondaryClosed,null,null,null);
    mSecondary.setVisibility(makeVisible ? View.VISIBLE : View.GONE);
  }
 else {
    mSecondaryHeader.setVisibility(View.GONE);
    mSecondary.setVisibility(View.GONE);
  }
}
Program: 183993
Project: 183993
Buggy source:
@Override protected void onResume(){
  super.onResume();
  mDTMFToneEnabled=Settings.System.getInt(getContentResolver(),Settings.System.DTMF_TONE_WHEN_DIALING,1) == 1;
synchronized (mToneGeneratorLock) {
    if (mToneGenerator == null) {
      try {
        mToneGenerator=new ToneGenerator(AudioManager.STREAM_DTMF,TONE_RELATIVE_VOLUME);
      }
 catch (      RuntimeException e) {
        Log.w(TAG,"String_Node_Str" + e);
        mToneGenerator=null;
      }
    }
  }
  Activity parent=getParent();
  if (parent != null && parent instanceof DialtactsActivity) {
    Uri dialUri=((DialtactsActivity)parent).getAndClearDialUri();
    if (dialUri != null) {
      resolveIntent();
    }
  }
  TelephonyManager telephonyManager=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  telephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  if (phoneIsInUse()) {
    mDigits.setHint(R.string.dialerDialpadHintText);
  }
 else {
    mDigits.setHint(null);
    showDialpadChooser(false);
  }
  updateDialAndDeleteButtonStateEnabledAttr();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mDTMFToneEnabled=Settings.System.getInt(getContentResolver(),Settings.System.DTMF_TONE_WHEN_DIALING,1) == 1;
synchronized (mToneGeneratorLock) {
    if (mToneGenerator == null) {
      try {
        mToneGenerator=new ToneGenerator(DIAL_TONE_STREAM_TYPE,TONE_RELATIVE_VOLUME);
        setVolumeControlStream(DIAL_TONE_STREAM_TYPE);
      }
 catch (      RuntimeException e) {
        Log.w(TAG,"String_Node_Str" + e);
        mToneGenerator=null;
      }
    }
  }
  Activity parent=getParent();
  if (parent != null && parent instanceof DialtactsActivity) {
    Uri dialUri=((DialtactsActivity)parent).getAndClearDialUri();
    if (dialUri != null) {
      resolveIntent();
    }
  }
  TelephonyManager telephonyManager=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  telephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  if (phoneIsInUse()) {
    mDigits.setHint(R.string.dialerDialpadHintText);
  }
 else {
    mDigits.setHint(null);
    showDialpadChooser(false);
  }
  updateDialAndDeleteButtonStateEnabledAttr();
}
Program: 183994
Project: 183994
Buggy source:
@Override protected void onResume(){
  super.onResume();
  mDTMFToneEnabled=Settings.System.getInt(getContentResolver(),Settings.System.DTMF_TONE_WHEN_DIALING,1) == 1;
synchronized (mToneGeneratorLock) {
    if (mToneGenerator == null) {
      try {
        mToneGenerator=new ToneGenerator(AudioManager.STREAM_DTMF,TONE_RELATIVE_VOLUME);
      }
 catch (      RuntimeException e) {
        Log.w(TAG,"String_Node_Str" + e);
        mToneGenerator=null;
      }
    }
  }
  Activity parent=getParent();
  if (parent != null && parent instanceof DialtactsActivity) {
    Uri dialUri=((DialtactsActivity)parent).getAndClearDialUri();
    if (dialUri != null) {
      resolveIntent();
    }
  }
  TelephonyManager telephonyManager=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  telephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  if (phoneIsInUse()) {
    mDigits.setHint(R.string.dialerDialpadHintText);
  }
 else {
    mDigits.setHint(null);
    showDialpadChooser(false);
  }
  updateDialAndDeleteButtonStateEnabledAttr();
}

Fixed version (ground truth):
@Override protected void onResume(){
  super.onResume();
  mDTMFToneEnabled=Settings.System.getInt(getContentResolver(),Settings.System.DTMF_TONE_WHEN_DIALING,1) == 1;
synchronized (mToneGeneratorLock) {
    if (mToneGenerator == null) {
      try {
        mToneGenerator=new ToneGenerator(DIAL_TONE_STREAM_TYPE,TONE_RELATIVE_VOLUME);
        setVolumeControlStream(DIAL_TONE_STREAM_TYPE);
      }
 catch (      RuntimeException e) {
        Log.w(TAG,"String_Node_Str" + e);
        mToneGenerator=null;
      }
    }
  }
  Activity parent=getParent();
  if (parent != null && parent instanceof DialtactsActivity) {
    Uri dialUri=((DialtactsActivity)parent).getAndClearDialUri();
    if (dialUri != null) {
      resolveIntent();
    }
  }
  TelephonyManager telephonyManager=(TelephonyManager)getSystemService(TELEPHONY_SERVICE);
  telephonyManager.listen(mPhoneStateListener,PhoneStateListener.LISTEN_CALL_STATE);
  if (phoneIsInUse()) {
    mDigits.setHint(R.string.dialerDialpadHintText);
  }
 else {
    mDigits.setHint(null);
    showDialpadChooser(false);
  }
  updateDialAndDeleteButtonStateEnabledAttr();
}