nus-yam/ex-repair huggingface dataset:
Program: 12258
Project: 12258
Buggy source:
public synchronized void setInteger(String path,int intVal){
  getNode(path).setIntValue(intVal);
}

Fixed version (ground truth):
public synchronized void setInteger(String path,int intVal){
  getNode(path).setIntValue(intVal);
  fireChangeEvent();
}
Program: 12259
Project: 12259
Buggy source:
public synchronized void clear(String path){
  getNode(path).clearValue();
}

Fixed version (ground truth):
public synchronized void clear(String path){
  getNode(path).clearValue();
  fireChangeEvent();
}
Program: 12260
Project: 12260
Buggy source:
public synchronized void remove(String path){
  removeNode(path);
}

Fixed version (ground truth):
public synchronized void remove(String path){
  removeNode(path);
  fireChangeEvent();
}
Program: 12261
Project: 12261
Buggy source:
public synchronized void setDouble(String path,double doubleVal){
  getNode(path).setDoubleValue(doubleVal);
}

Fixed version (ground truth):
public synchronized void setDouble(String path,double doubleVal){
  getNode(path).setDoubleValue(doubleVal);
  fireChangeEvent();
}
Program: 12262
Project: 12262
Buggy source:
public synchronized void setString(String path,String strVal){
  getNode(path).setStringValue(strVal);
}

Fixed version (ground truth):
public synchronized void setString(String path,String strVal){
  getNode(path).setStringValue(strVal);
  fireChangeEvent();
}
Program: 12263
Project: 12263
Buggy source:
/** 
 * Set the source for this adapter. If a previous adapter was set, any WMEs created for that source are removed at the next input cycle.
 * @param source the new memory source for this adapter
 */
public void setSource(QMemory source){
synchronized (lock) {
    this.sourceChanged=this.sourceChanged | (this.source != source);
    this.source=source;
  }
}

Fixed version (ground truth):
/** 
 * Set the source for this adapter. If a previous adapter was set, any WMEs created for that source are removed at the next input cycle.
 * @param source the new memory source for this adapter
 */
public void setSource(QMemory source){
synchronized (lock) {
    if (this.source != null) {
      this.source.removeListener(this);
    }
    this.sourceChanged=this.sourceChanged | (this.source != source);
    this.source=source;
    if (this.source != null) {
      this.source.addListener(this);
    }
    if (sourceChanged && io != null) {
      io.asynchronousInputReady();
    }
  }
}
Program: 12267
Project: 12267
Buggy source:
/** 
 * reorder.cpp:303
 * @param conds_list
 * @return
 */
private SavedTest simplify_condition_list(Condition conds_list){
  SavedTest sts=null;
  for (Condition c=conds_list; c != null; c=c.next) {
    if (c.asConjunctiveNegationCondition() != null) {
      continue;
    }
    if (c.asPositiveCondition() != null) {
      PositiveCondition pc=c.asPositiveCondition();
      ByRef<Test> id_test=ByRef.create(pc.id_test);
      sts=simplify_test(id_test,sts);
      pc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(pc.attr_test);
      sts=simplify_test(attr_test,sts);
      pc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(pc.value_test);
      sts=simplify_test(value_test,sts);
      pc.value_test=value_test.value;
    }
 else     if (c.asNegativeCondition() != null) {
      NegativeCondition nc=c.asNegativeCondition();
      ByRef<Test> id_test=ByRef.create(nc.id_test);
      sts=simplify_test(id_test,sts);
      nc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(nc.attr_test);
      sts=simplify_test(attr_test,sts);
      nc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(nc.value_test);
      sts=simplify_test(value_test,sts);
      nc.value_test=value_test.value;
    }
  }
  return sts;
}

Fixed version (ground truth):
/** 
 * reorder.cpp:303
 * @param conds_list
 * @return
 */
private SavedTest simplify_condition_list(Condition conds_list){
  SavedTest sts=null;
  for (Condition c=conds_list; c != null; c=c.next) {
    if (c.asPositiveCondition() != null) {
      PositiveCondition pc=c.asPositiveCondition();
      ByRef<Test> id_test=ByRef.create(pc.id_test);
      sts=simplify_test(id_test,sts);
      pc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(pc.attr_test);
      sts=simplify_test(attr_test,sts);
      pc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(pc.value_test);
      sts=simplify_test(value_test,sts);
      pc.value_test=value_test.value;
    }
  }
  return sts;
}
Program: 12268
Project: 12268
Buggy source:
@Test public void testUnboundedVarInNegationBug517() throws Exception {
  agent.getProductions().loadProduction("String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str");
  JSoarTest.verifyProduction(agent,"String_Node_Str",ProductionType.USER,"String_Node_Str" + "String_Node_Str" + "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str"+ "String_Node_Str",true);
}

Fixed version (ground truth):
@Test public void testUnboundedVarInNegationBug517() throws Exception {
}
Program: 12269
Project: 12269
Buggy source:
/** 
 * reorder.cpp:1064:reorder_lhs
 * @param lhs_top
 * @param lhs_bottom
 * @param reorder_nccs
 * @throws ReordererException 
 */
public void reorder_lhs(ByRef<Condition> lhs_top,ByRef<Condition> lhs_bottom,boolean reorder_nccs) throws ReordererException {
  Marker tc=DefaultMarker.create();
  ListHead<Variable> roots=Conditions.collect_root_variables(lhs_top.value,tc,trace.getPrinter(),prodName);
  if (!roots.isEmpty()) {
    remove_isa_state_tests_for_non_roots(lhs_top,lhs_bottom,roots);
  }
  if (roots.isEmpty()) {
    for (Condition cond=lhs_top.value; cond != null; cond=cond.next) {
      PositiveCondition pc=cond.asPositiveCondition();
      if (pc != null && (Tests.test_includes_goal_or_impasse_id_test(pc.id_test,true,false))) {
        pc.id_test.addBoundVariables(tc,roots);
        if (!roots.isEmpty()) {
          break;
        }
      }
    }
  }
  if (roots.isEmpty()) {
    String message=String.format("String_Node_Str" + "String_Node_Str",prodName);
    trace.getPrinter().print(message);
    throw new ReordererException(message);
  }
  fill_in_vars_requiring_bindings(lhs_top.value,tc);
  reorder_condition_list(lhs_top,lhs_bottom,roots,tc,reorder_nccs);
  remove_vars_requiring_bindings(lhs_top.value);
}

Fixed version (ground truth):
/** 
 * reorder.cpp:1064:reorder_lhs
 * @param lhs_top
 * @param lhs_bottom
 * @param reorder_nccs
 * @throws ReordererException 
 */
public void reorder_lhs(ByRef<Condition> lhs_top,ByRef<Condition> lhs_bottom,boolean reorder_nccs) throws ReordererException {
  Marker tc=DefaultMarker.create();
  ListHead<Variable> roots=Conditions.collect_root_variables(lhs_top.value,tc,trace.getPrinter(),prodName);
  if (!roots.isEmpty()) {
    remove_isa_state_tests_for_non_roots(lhs_top,lhs_bottom,roots);
  }
  if (roots.isEmpty()) {
    for (Condition cond=lhs_top.value; cond != null; cond=cond.next) {
      PositiveCondition pc=cond.asPositiveCondition();
      if (pc != null && (Tests.test_includes_goal_or_impasse_id_test(pc.id_test,true,false))) {
        pc.id_test.addBoundVariables(tc,roots);
        if (!roots.isEmpty()) {
          break;
        }
      }
    }
  }
  if (roots.isEmpty()) {
    String message=String.format("String_Node_Str" + "String_Node_Str",prodName);
    trace.getPrinter().print(message);
    throw new ReordererException(message);
  }
  fill_in_vars_requiring_bindings(lhs_top.value,tc);
  reorder_condition_list(lhs_top,lhs_bottom,roots,tc,reorder_nccs);
  remove_vars_requiring_bindings(lhs_top.value);
  check_negative_relational_test_bindings(lhs_top.value,DefaultMarker.create());
}
Program: 12270
Project: 12270
Buggy source:
/** 
 * init_soar.cpp:350:reinitialize_soar
 */
private void reinitialize_soar(){
  getEventManager().fireEvent(new BeforeInitSoarEvent(this));
  boolean traceState=trace.isEnabled();
  trace.setEnabled(false);
  rl.rl_reset_data();
  decider.clear_goal_stack();
  io.do_input_cycle();
  io.do_output_cycle();
  rl.rl_reset_stats();
  decider.active_level=0;
  recMemory.FIRING_TYPE=SavedFiringType.IE_PRODS;
  recMemory.do_preference_phase(decider.top_goal);
  explain.reset_explain();
  syms.reset();
  workingMemory.reset();
  decisionCycle.reset();
  recMemory.reset();
  reset_statistics();
  trace.setEnabled(traceState);
  getEventManager().fireEvent(new AfterInitSoarEvent(this));
}

Fixed version (ground truth):
/** 
 * init_soar.cpp:350:reinitialize_soar
 */
private void reinitialize_soar(){
  getEventManager().fireEvent(new BeforeInitSoarEvent(this));
  boolean traceState=trace.isEnabled();
  trace.setEnabled(false);
  rl.rl_reset_data();
  decider.clear_goal_stack();
  io.do_input_cycle();
  io.do_output_cycle();
  rl.rl_reset_stats();
  decider.active_level=0;
  recMemory.FIRING_TYPE=SavedFiringType.IE_PRODS;
  recMemory.do_preference_phase(decider.top_goal);
  explain.reset_explain();
  syms.reset();
  workingMemory.reset();
  decisionCycle.reset();
  recMemory.reset();
  chunker.reset();
  reset_statistics();
  trace.setEnabled(traceState);
  getEventManager().fireEvent(new AfterInitSoarEvent(this));
}
Program: 12271
Project: 12271
Buggy source:
/** 
 * This scans down the goal stack and checks the consistency of the current decision versus the current preferences for the slot, if the preferences have changed. consistency.cpp:326:check_context_slot_decisions
 * @param level
 * @return
 */
private boolean check_context_slot_decisions(int level){
  if (DEBUG_CONSISTENCY_CHECK) {
    if (tempMemory.highest_goal_whose_context_changed != null)     context.getPrinter().print("String_Node_Str",tempMemory.highest_goal_whose_context_changed);
  }
  for (IdentifierImpl goal=tempMemory.highest_goal_whose_context_changed; goal != null && goal.level <= level; goal=goal.lower_goal) {
    if (DEBUG_CONSISTENCY_CHECK) {
      context.getPrinter().print("String_Node_Str",goal);
    }
    Slot s=goal.operator_slot;
    if ((goal.lower_goal != null) || (s.getWmes() != null)) {
      if (DEBUG_CONSISTENCY_CHECK) {
        context.getPrinter().print("String_Node_Str");
      }
      if (s.changed != null) {
        if (DEBUG_CONSISTENCY_CHECK) {
          context.getPrinter().print("String_Node_Str");
        }
        if (!decision_consistent_with_current_preferences(goal,s)) {
          if (DEBUG_CONSISTENCY_CHECK) {
            context.getPrinter().print("String_Node_Str",goal);
          }
          if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES))           context.getTrace().print("String_Node_Str",goal);
          remove_current_decision(s);
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * This scans down the goal stack and checks the consistency of the current decision versus the current preferences for the slot, if the preferences have changed. consistency.cpp:326:check_context_slot_decisions
 * @param level
 * @return
 */
private boolean check_context_slot_decisions(int level){
  if (DEBUG_CONSISTENCY_CHECK) {
    if (tempMemory.highest_goal_whose_context_changed != null)     context.getPrinter().print("String_Node_Str",tempMemory.highest_goal_whose_context_changed);
  }
  for (IdentifierImpl goal=tempMemory.highest_goal_whose_context_changed; goal != null && goal.level <= level; goal=goal.lower_goal) {
    if (DEBUG_CONSISTENCY_CHECK) {
      context.getPrinter().print("String_Node_Str",goal);
    }
    Slot s=goal.operator_slot;
    if ((goal.lower_goal != null) || (s.getWmes() != null)) {
      if (DEBUG_CONSISTENCY_CHECK) {
        context.getPrinter().print("String_Node_Str");
      }
      if (s.changed != null) {
        if (DEBUG_CONSISTENCY_CHECK) {
          context.getPrinter().print("String_Node_Str");
        }
        if (!decision_consistent_with_current_preferences(goal,s)) {
          if (DEBUG_CONSISTENCY_CHECK) {
            context.getPrinter().print("String_Node_Str",goal);
          }
          context.getTrace().print(EnumSet.of(Category.VERBOSE,Category.WM_CHANGES),"String_Node_Str",goal);
          remove_current_decision(s);
          return false;
        }
      }
    }
  }
  return true;
}
Program: 12273
Project: 12273
Buggy source:
/** 
 * <p>Moved here from consistency since it accesses no other state and is only ever called from decider. <p>consistency.cpp:41:remove_operator_if_necessary
 * @param s
 * @param w
 */
private void remove_operator_if_necessary(Slot s,WmeImpl w){
  if (s.getWmes() != null) {
    if (s.getWmes().value == w.value) {
      context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w);
      this.remove_wmes_for_context_slot(s);
      if (s.id.lower_goal != null) {
        if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES))         context.getTrace().print("String_Node_Str",s.id.lower_goal);
        this.remove_existing_context_and_descendents(s.id.lower_goal);
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>Moved here from consistency since it accesses no other state and is only ever called from decider. <p>consistency.cpp:41:remove_operator_if_necessary
 * @param s
 * @param w
 */
private void remove_operator_if_necessary(Slot s,WmeImpl w){
  if (s.getWmes() != null) {
    if (s.getWmes().value == w.value) {
      context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w);
      this.remove_wmes_for_context_slot(s);
      if (s.id.lower_goal != null) {
        context.getTrace().print(EnumSet.of(Category.VERBOSE,Category.WM_CHANGES),"String_Node_Str",s.id.lower_goal);
        this.remove_existing_context_and_descendents(s.id.lower_goal);
      }
    }
  }
}
Program: 12276
Project: 12276
Buggy source:
/** 
 * REW BUG: this needs to be smarter to deal with wmes that get support  from multiple instantiations. for example ^enemy-out-there could be  made by 50 instantiations. if one of those instantiations goes, should  the goal be killed???? This routine says "yes" -- anytime a dependent  item gets changed, we're gonna yank out the goal -- even when that  i-supported element itself may not be removed (due to multiple  preferences). So, we'll say that this is a "twitchy" version of OPERAND2,  and leave open the possibility that other approaches may be better <p>decide.cpp:3040:gds_invalid_so_remove_goal
 * @param w
 */
public void gds_invalid_so_remove_goal(WmeImpl w){
  if (tempMemory.highest_goal_whose_context_changed != null) {
    if (tempMemory.highest_goal_whose_context_changed.level >= w.gds.getGoal().level) {
      tempMemory.highest_goal_whose_context_changed=w.gds.getGoal().higher_goal;
    }
  }
 else {
    tempMemory.highest_goal_whose_context_changed=w.gds.getGoal().higher_goal;
  }
  context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w.gds.getGoal(),w);
  remove_existing_context_and_descendents(w.gds.getGoal());
}

Fixed version (ground truth):
/** 
 * REW BUG: this needs to be smarter to deal with wmes that get support  from multiple instantiations. for example ^enemy-out-there could be  made by 50 instantiations. if one of those instantiations goes, should  the goal be killed???? This routine says "yes" -- anytime a dependent  item gets changed, we're gonna yank out the goal -- even when that  i-supported element itself may not be removed (due to multiple  preferences). So, we'll say that this is a "twitchy" version of OPERAND2,  and leave open the possibility that other approaches may be better <p>decide.cpp:3040:gds_invalid_so_remove_goal
 * @param w
 */
public void gds_invalid_so_remove_goal(WmeImpl w){
  if (tempMemory.highest_goal_whose_context_changed != null) {
    if (tempMemory.highest_goal_whose_context_changed.level >= w.gds.getGoal().level) {
      tempMemory.highest_goal_whose_context_changed=w.gds.getGoal().higher_goal;
    }
  }
 else {
    tempMemory.highest_goal_whose_context_changed=w.gds.getGoal().higher_goal;
    for (ListItem<Slot> sit=tempMemory.highest_goal_whose_context_changed.slots.first; sit != null; sit=sit.next) {
      final Slot s=sit.item;
      if (s.isa_context_slot && s.changed == null) {
        s.changed=s;
      }
    }
  }
  context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w.gds.getGoal(),w);
  remove_existing_context_and_descendents(w.gds.getGoal());
}
Program: 12279
Project: 12279
Buggy source:
/** 
 * Halt this agent. A halted agent can only be restarted with an init-soar.
 * @param string Reason for the halt
 */
public void halt(String string){
  stop_soar=true;
  system_halted=true;
  reason_for_stopping="String_Node_Str";
}

Fixed version (ground truth):
/** 
 * Halt this agent. A halted agent can only be restarted with an init-soar.
 * @param string Reason for the halt
 */
public void halt(String string){
  stop_soar=true;
  system_halted=true;
  reason_for_stopping=string;
}
Program: 12283
Project: 12283
Buggy source:
/** 
 * reorder.cpp:303
 * @param conds_list
 * @return
 */
private SavedTest simplify_condition_list(Condition conds_list){
  SavedTest sts=null;
  for (Condition c=conds_list; c != null; c=c.next) {
    PositiveCondition pc=c.asPositiveCondition();
    if (pc != null) {
      ByRef<Test> id_test=ByRef.create(pc.id_test);
      sts=simplify_test(id_test,sts);
      pc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(pc.attr_test);
      sts=simplify_test(attr_test,sts);
      pc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(pc.value_test);
      sts=simplify_test(value_test,sts);
      pc.value_test=value_test.value;
    }
  }
  return sts;
}

Fixed version (ground truth):
/** 
 * reorder.cpp:303
 * @param conds_list
 * @return
 */
private SavedTest simplify_condition_list(Condition conds_list){
  SavedTest sts=null;
  for (Condition c=conds_list; c != null; c=c.next) {
    if (c.asConjunctiveNegationCondition() != null) {
      continue;
    }
    if (c.asPositiveCondition() != null) {
      PositiveCondition pc=c.asPositiveCondition();
      ByRef<Test> id_test=ByRef.create(pc.id_test);
      sts=simplify_test(id_test,sts);
      pc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(pc.attr_test);
      sts=simplify_test(attr_test,sts);
      pc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(pc.value_test);
      sts=simplify_test(value_test,sts);
      pc.value_test=value_test.value;
    }
 else     if (c.asNegativeCondition() != null) {
      NegativeCondition nc=c.asNegativeCondition();
      ByRef<Test> id_test=ByRef.create(nc.id_test);
      sts=simplify_test(id_test,sts);
      nc.id_test=id_test.value;
      ByRef<Test> attr_test=ByRef.create(nc.attr_test);
      sts=simplify_test(attr_test,sts);
      nc.attr_test=attr_test.value;
      ByRef<Test> value_test=ByRef.create(nc.value_test);
      sts=simplify_test(value_test,sts);
      nc.value_test=value_test.value;
    }
  }
  return sts;
}
Program: 12284
Project: 12284
Buggy source:
/** 
 * This scans down the goal stack and checks the consistency of the current decision versus the current preferences for the slot, if the preferences have changed. consistency.cpp:326:check_context_slot_decisions
 * @param level
 * @return
 */
private boolean check_context_slot_decisions(int level){
  if (DEBUG_CONSISTENCY_CHECK) {
    if (tempMemory.highest_goal_whose_context_changed != null)     context.getPrinter().print("String_Node_Str",tempMemory.highest_goal_whose_context_changed);
  }
  for (IdentifierImpl goal=tempMemory.highest_goal_whose_context_changed; goal != null && goal.level <= level; goal=goal.lower_goal) {
    if (DEBUG_CONSISTENCY_CHECK) {
      context.getPrinter().print("String_Node_Str",goal);
    }
    Slot s=goal.operator_slot;
    if ((goal.lower_goal != null) || (s.getWmes() != null)) {
      if (DEBUG_CONSISTENCY_CHECK) {
        context.getPrinter().print("String_Node_Str");
      }
      if (s.changed != null) {
        if (DEBUG_CONSISTENCY_CHECK) {
          context.getPrinter().print("String_Node_Str");
        }
        if (!decision_consistent_with_current_preferences(goal,s)) {
          if (DEBUG_CONSISTENCY_CHECK) {
            context.getPrinter().print("String_Node_Str",goal);
          }
          remove_current_decision(s);
          return false;
        }
      }
    }
  }
  return true;
}

Fixed version (ground truth):
/** 
 * This scans down the goal stack and checks the consistency of the current decision versus the current preferences for the slot, if the preferences have changed. consistency.cpp:326:check_context_slot_decisions
 * @param level
 * @return
 */
private boolean check_context_slot_decisions(int level){
  if (DEBUG_CONSISTENCY_CHECK) {
    if (tempMemory.highest_goal_whose_context_changed != null)     context.getPrinter().print("String_Node_Str",tempMemory.highest_goal_whose_context_changed);
  }
  for (IdentifierImpl goal=tempMemory.highest_goal_whose_context_changed; goal != null && goal.level <= level; goal=goal.lower_goal) {
    if (DEBUG_CONSISTENCY_CHECK) {
      context.getPrinter().print("String_Node_Str",goal);
    }
    Slot s=goal.operator_slot;
    if ((goal.lower_goal != null) || (s.getWmes() != null)) {
      if (DEBUG_CONSISTENCY_CHECK) {
        context.getPrinter().print("String_Node_Str");
      }
      if (s.changed != null) {
        if (DEBUG_CONSISTENCY_CHECK) {
          context.getPrinter().print("String_Node_Str");
        }
        if (!decision_consistent_with_current_preferences(goal,s)) {
          if (DEBUG_CONSISTENCY_CHECK) {
            context.getPrinter().print("String_Node_Str",goal);
          }
          if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES))           context.getTrace().print("String_Node_Str",goal);
          remove_current_decision(s);
          return false;
        }
      }
    }
  }
  return true;
}
Program: 12286
Project: 12286
Buggy source:
/** 
 * <p>Moved here from consistency since it accesses no other state and is only ever called from decider. <p>consistency.cpp:41:remove_operator_if_necessary
 * @param s
 * @param w
 */
private void remove_operator_if_necessary(Slot s,WmeImpl w){
  if (s.getWmes() != null) {
    if (s.getWmes().value == w.value) {
      context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w);
      this.remove_wmes_for_context_slot(s);
      if (s.id.lower_goal != null)       this.remove_existing_context_and_descendents(s.id.lower_goal);
    }
  }
}

Fixed version (ground truth):
/** 
 * <p>Moved here from consistency since it accesses no other state and is only ever called from decider. <p>consistency.cpp:41:remove_operator_if_necessary
 * @param s
 * @param w
 */
private void remove_operator_if_necessary(Slot s,WmeImpl w){
  if (s.getWmes() != null) {
    if (s.getWmes().value == w.value) {
      context.getTrace().print(Category.OPERAND2_REMOVALS,"String_Node_Str",w);
      this.remove_wmes_for_context_slot(s);
      if (s.id.lower_goal != null) {
        if (context.getTrace().isEnabled(Category.VERBOSE) || context.getTrace().isEnabled(Category.WM_CHANGES))         context.getTrace().print("String_Node_Str",s.id.lower_goal);
        this.remove_existing_context_and_descendents(s.id.lower_goal);
      }
    }
  }
}
Program: 12287
Project: 12287
Buggy source:
/** 
 * <p>chunk.cpp:251:copy_and_variablize_result_list
 * @param pref
 * @return
 */
private MakeAction copy_and_variablize_result_list(Preference pref){
  if (pref == null)   return null;
  MakeAction a=new MakeAction();
  a.id=new RhsSymbolValue(variablize_symbol(pref.id));
  a.attr=new RhsSymbolValue(variablize_symbol(pref.attr));
  a.value=new RhsSymbolValue(variablize_symbol(pref.value));
  a.preference_type=pref.type;
  if (pref.type.isBinary()) {
    a.referent=new RhsSymbolValue(variablize_symbol(pref.referent));
  }
  a.next=copy_and_variablize_result_list(pref.next_result);
  return a;
}

Fixed version (ground truth):
/** 
 * <p>chunk.cpp:251:copy_and_variablize_result_list
 * @param pref
 * @return
 */
private MakeAction copy_and_variablize_result_list(Preference pref){
  if (pref == null)   return null;
  MakeAction a=new MakeAction();
  a.id=variablize_symbol(pref.id).toRhsValue();
  a.attr=variablize_symbol(pref.attr).toRhsValue();
  a.value=variablize_symbol(pref.value).toRhsValue();
  a.preference_type=pref.type;
  if (pref.type.isBinary()) {
    a.referent=variablize_symbol(pref.referent).toRhsValue();
  }
  a.next=copy_and_variablize_result_list(pref.next_result);
  return a;
}
Program: 12288
Project: 12288
Buggy source:
/** 
 * reinforcement_learning.cpp:992:rl_make_simple_action
 * @param id_sym
 * @param attr_sym
 * @param val_sym
 * @param ref_sym
 * @return
 */
MakeAction rl_make_simple_action(IdentifierImpl id_sym,SymbolImpl attr_sym,SymbolImpl val_sym,SymbolImpl ref_sym){
  MakeAction rhs=new MakeAction();
  rhs.id=new RhsSymbolValue(this.chunker.variablize_symbol(id_sym));
  rhs.attr=new RhsSymbolValue(this.chunker.variablize_symbol(attr_sym));
  rhs.value=new RhsSymbolValue(this.chunker.variablize_symbol(val_sym));
  rhs.referent=new RhsSymbolValue(this.chunker.variablize_symbol(ref_sym));
  return rhs;
}

Fixed version (ground truth):
/** 
 * reinforcement_learning.cpp:992:rl_make_simple_action
 * @param id_sym
 * @param attr_sym
 * @param val_sym
 * @param ref_sym
 * @return
 */
MakeAction rl_make_simple_action(IdentifierImpl id_sym,SymbolImpl attr_sym,SymbolImpl val_sym,SymbolImpl ref_sym){
  MakeAction rhs=new MakeAction();
  rhs.id=this.chunker.variablize_symbol(id_sym).toRhsValue();
  rhs.attr=this.chunker.variablize_symbol(attr_sym).toRhsValue();
  rhs.value=this.chunker.variablize_symbol(val_sym).toRhsValue();
  rhs.referent=this.chunker.variablize_symbol(ref_sym).toRhsValue();
  return rhs;
}
Program: 12293
Project: 12293
Buggy source:
/** 
 * Parses an   {@code <rhs_value>}. Returns an rhs_value, or null if any error occurred. <pre>  {@code <rhs_value> ::= <constant> | <function_call> | variable  <constant> ::= sym_constant | int_constant | float_constant}</pre> <p>parser.cpp::parse_rhs_value
 * @return
 * @throws IOException
 * @throws ParserException
 */
RhsValue parse_rhs_value() throws IOException, ParserException {
  if (currentType() == LexemeType.L_PAREN) {
    lexer.getNextLexeme();
    return parse_function_call_after_lparen(false);
  }
  if ((currentType() == LexemeType.SYM_CONSTANT) || (currentType() == LexemeType.INTEGER) || (currentType() == LexemeType.FLOAT)|| (currentType() == LexemeType.VARIABLE)) {
    RhsValue rv=new RhsSymbolValue(make_symbol_for_current_lexeme());
    lexer.getNextLexeme();
    return rv;
  }
  error("String_Node_Str");
  throw new IllegalStateException("String_Node_Str");
}

Fixed version (ground truth):
/** 
 * Parses an   {@code <rhs_value>}. Returns an rhs_value, or null if any error occurred. <pre>  {@code <rhs_value> ::= <constant> | <function_call> | variable  <constant> ::= sym_constant | int_constant | float_constant}</pre> <p>parser.cpp::parse_rhs_value
 * @return
 * @throws IOException
 * @throws ParserException
 */
RhsValue parse_rhs_value() throws IOException, ParserException {
  if (currentType() == LexemeType.L_PAREN) {
    lexer.getNextLexeme();
    return parse_function_call_after_lparen(false);
  }
  if ((currentType() == LexemeType.SYM_CONSTANT) || (currentType() == LexemeType.INTEGER) || (currentType() == LexemeType.FLOAT)|| (currentType() == LexemeType.VARIABLE)) {
    RhsValue rv=make_symbol_for_current_lexeme().toRhsValue();
    lexer.getNextLexeme();
    return rv;
  }
  error("String_Node_Str");
  throw new IllegalStateException("String_Node_Str");
}
Program: 12294
Project: 12294
Buggy source:
/** 
 * Tests whether two RHS's (i.e., action lists) are the same (except for function calls).  This is used for finding duplicate productions. rete.cpp:3374:same_rhs
 * @param rhs1
 * @param rhs2
 * @return
 */
public static boolean same_rhs(Action rhs1,Action rhs2){
  Action a1=rhs1;
  Action a2=rhs2;
  while (a1 != null && a2 != null) {
    if (a1.asFunctionAction() != null)     return false;
    if (a2.asFunctionAction() != null)     return false;
    if (a1.preference_type != a2.preference_type)     return false;
    MakeAction ma1=a1.asMakeAction();
    MakeAction ma2=a2.asMakeAction();
    if (ma1.id != ma2.id)     return false;
    if (ma1.attr != ma2.attr)     return false;
    if (ma1.value != ma2.value)     return false;
    if (ma1.preference_type.isBinary()) {
      if (ma1.referent != ma2.referent) {
        return false;
      }
    }
    a1=a1.next;
    a2=a2.next;
  }
  if (a1 != a2)   return false;
  return true;
}

Fixed version (ground truth):
/** 
 * Tests whether two RHS's (i.e., action lists) are the same (except for function calls).  This is used for finding duplicate productions. <p>rete.cpp:3374:same_rhs
 * @param rhs1
 * @param rhs2
 * @return
 */
public static boolean same_rhs(Action rhs1,Action rhs2){
  Action a1=rhs1;
  Action a2=rhs2;
  while (a1 != null && a2 != null) {
    if (a1.asFunctionAction() != null)     return false;
    if (a2.asFunctionAction() != null)     return false;
    if (a1.preference_type != a2.preference_type)     return false;
    MakeAction ma1=a1.asMakeAction();
    MakeAction ma2=a2.asMakeAction();
    if (!ma1.id.equals(ma2.id))     return false;
    if (!ma1.attr.equals(ma2.attr))     return false;
    if (!ma1.value.equals(ma2.value))     return false;
    if (ma1.preference_type.isBinary()) {
      if (ma1.referent != ma2.referent) {
        return false;
      }
    }
    a1=a1.next;
    a2=a2.next;
  }
  if (a1 != a2)   return false;
  return true;
}
Program: 12295
Project: 12295
Buggy source:
/** 
 * @param fieldNum
 * @param levelsUp
 */
public ReteLocation(int fieldNum,int levelsUp){
  this.fieldNum=fieldNum;
  this.levelsUp=levelsUp;
}

Fixed version (ground truth):
private ReteLocation(int fieldNum,int levelsUp){
  this.fieldNum=fieldNum;
  this.levelsUp=levelsUp;
}
Program: 12296
Project: 12296
Buggy source:
public RhsSymbolValue(SymbolImpl sym){
  this.sym=sym;
}

Fixed version (ground truth):
/** 
 * Construct a RHS symbol value. <b>This should only be used by  {@link SymbolImpl}! If you want one of these, get it through  {@link SymbolImpl#toRhsValue()}.
 * @param sym the symbol
 */
public RhsSymbolValue(SymbolImpl sym){
  this.sym=sym;
}
Program: 12297
Project: 12297
Buggy source:
/** 
 * "Change" the symbol this value refers to, this method creates and  returns a new value, or returns <code>this</code> if the symbol is the same as the one it already holds. This takes advantage of the fact that these objects are immutable to avoid unnecessary allocations.
 * @param newSym The new symbol for the value
 * @return New RhsSymbolValue with the given symbol value
 */
public RhsSymbolValue setSymbol(SymbolImpl newSym){
  return sym == newSym ? this : new RhsSymbolValue(newSym);
}

Fixed version (ground truth):
/** 
 * "Change" the symbol this value refers to, this method creates and  returns a new value, or returns <code>this</code> if the symbol is the same as the one it already holds. This takes advantage of the fact that these objects are immutable to avoid unnecessary allocations.
 * @param newSym The new symbol for the value
 * @return New RhsSymbolValue with the given symbol value
 */
public RhsSymbolValue setSymbol(SymbolImpl newSym){
  return sym == newSym ? this : newSym.toRhsValue();
}
Program: 12299
Project: 12299
Buggy source:
/** 
 * Initialize the lexer routine table <p>lexer.cpp::init_lexer
 */
private void init_lexer(){
  for (int i=0; i < lexer_routines.length; i++) {
switch (i) {
case '@':
      lexer_routines[i]=new BasicLexerRoutine(LexemeType.AT);
    break;
case '(':
  lexer_routines[i]=lex_lparen;
break;
case ')':
lexer_routines[i]=lex_rparen;
break;
case '+':
lexer_routines[i]=lex_plus;
break;
case '-':
lexer_routines[i]=lex_minus;
break;
case '~':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.TILDE);
break;
case '^':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.UP_ARROW);
break;
case '{':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.L_BRACE);
break;
case '}':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.R_BRACE);
break;
case '!':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.EXCLAMATION_POINT);
break;
case '>':
lexer_routines[i]=lex_greater;
break;
case '<':
lexer_routines[i]=lex_less;
break;
case '=':
lexer_routines[i]=lex_equal;
break;
case '&':
lexer_routines[i]=lex_ampersand;
break;
case '|':
lexer_routines[i]=lex_vbar;
break;
case ',':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.COMMA);
break;
case '.':
lexer_routines[i]=lex_period;
break;
case '"':
lexer_routines[i]=lex_quote;
break;
default :
if (Character.isDigit((char)i)) {
lexer_routines[i]=lex_digit;
}
 else if (constituent_char[i]) {
lexer_routines[i]=lex_constituent_string;
}
 else {
lexer_routines[i]=lex_unknown;
}
}
}
}

Fixed version (ground truth):
/** 
 * Initialize the lexer routine table <p>lexer.cpp::init_lexer
 */
private void init_lexer(){
  for (int i=0; i < lexer_routines.length; i++) {
switch (i) {
case '@':
      lexer_routines[i]=new BasicLexerRoutine(LexemeType.AT);
    break;
case '(':
  lexer_routines[i]=lex_lparen;
break;
case ')':
lexer_routines[i]=lex_rparen;
break;
case '+':
lexer_routines[i]=lex_plus;
break;
case '-':
lexer_routines[i]=lex_minus;
break;
case '~':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.TILDE);
break;
case '^':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.UP_ARROW);
break;
case '{':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.L_BRACE);
break;
case '}':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.R_BRACE);
break;
case '!':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.EXCLAMATION_POINT);
break;
case '>':
lexer_routines[i]=lex_greater;
break;
case '<':
lexer_routines[i]=lex_less;
break;
case '=':
lexer_routines[i]=lex_equal;
break;
case '&':
lexer_routines[i]=lex_ampersand;
break;
case '|':
lexer_routines[i]=lex_vbar;
break;
case ',':
lexer_routines[i]=new BasicLexerRoutine(LexemeType.COMMA);
break;
case '.':
lexer_routines[i]=lex_period;
break;
case '"':
lexer_routines[i]=lex_quote;
break;
default :
if (Character.isDigit((char)i)) {
lexer_routines[i]=lex_digit;
}
 else if (isConstituentChar((char)i)) {
lexer_routines[i]=lex_constituent_string;
}
 else {
lexer_routines[i]=lex_unknown;
}
}
}
}
Program: 12301
Project: 12301
Buggy source:
void read_constituent_string() throws IOException {
  while ((current_char != EOF_AS_CHAR) && constituent_char[current_char]) {
    store_and_advance();
  }
}

Fixed version (ground truth):
void read_constituent_string() throws IOException {
  while ((current_char != EOF_AS_CHAR) && isConstituentChar(current_char)) {
    store_and_advance();
  }
}
Program: 12302
Project: 12302
Buggy source:
/** 
 * Returns TRUE iff the two conditions are identical. <p>production.cpp:794:conditions_are_equal
 * @param c1 First condition to test
 * @param c2 Second condition to test
 * @return true iff the two conditions are identical
 */
public static boolean conditions_are_equal(Condition c1,Condition c2){
  if (!c1.getClass().equals(c2.getClass()))   return false;
  ThreeFieldCondition tfc1=c1.asThreeFieldCondition();
  if (tfc1 != null) {
    ThreeFieldCondition tfc2=c2.asThreeFieldCondition();
    if (!Tests.tests_are_equal(tfc1.id_test,tfc2.id_test))     return false;
    if (!Tests.tests_are_equal(tfc1.attr_test,tfc2.attr_test))     return false;
    if (!Tests.tests_are_equal(tfc1.value_test,tfc2.value_test))     return false;
    if (c1.test_for_acceptable_preference != c2.test_for_acceptable_preference)     return false;
    return true;
  }
  ConjunctiveNegationCondition ncc1=c1.asConjunctiveNegationCondition();
  if (ncc1 != null) {
    ConjunctiveNegationCondition ncc2=c2.asConjunctiveNegationCondition();
    for (c1=ncc1.top, c2=ncc2.top; ((c1 != null) && (c2 != null)); c1=c1.next, c2=c2.next)     if (!conditions_are_equal(c1,c2))     return false;
    if (c1 == c2)     return true;
    return false;
  }
  throw new IllegalStateException("String_Node_Str" + c1 + "String_Node_Str"+ c2);
}

Fixed version (ground truth):
/** 
 * Returns TRUE iff the two conditions are identical. <p>production.cpp:794:conditions_are_equal
 * @param c1 First condition to test
 * @param c2 Second condition to test
 * @return true iff the two conditions are identical
 */
public static boolean conditions_are_equal(Condition c1,Condition c2){
  if (!c1.getClass().equals(c2.getClass()))   return false;
  ThreeFieldCondition tfc1=c1.asThreeFieldCondition();
  if (tfc1 != null) {
    boolean neg=c1.asNegativeCondition() != null;
    ThreeFieldCondition tfc2=c2.asThreeFieldCondition();
    if (!Tests.tests_are_equal(tfc1.id_test,tfc2.id_test,neg))     return false;
    if (!Tests.tests_are_equal(tfc1.attr_test,tfc2.attr_test,neg))     return false;
    if (!Tests.tests_are_equal(tfc1.value_test,tfc2.value_test,neg))     return false;
    if (c1.test_for_acceptable_preference != c2.test_for_acceptable_preference)     return false;
    return true;
  }
  ConjunctiveNegationCondition ncc1=c1.asConjunctiveNegationCondition();
  if (ncc1 != null) {
    ConjunctiveNegationCondition ncc2=c2.asConjunctiveNegationCondition();
    for (c1=ncc1.top, c2=ncc2.top; ((c1 != null) && (c2 != null)); c1=c1.next, c2=c2.next)     if (!conditions_are_equal(c1,c2))     return false;
    if (c1 == c2)     return true;
    return false;
  }
  throw new IllegalStateException("String_Node_Str" + c1 + "String_Node_Str"+ c2);
}
Program: 12306
Project: 12306
Buggy source:
/** 
 * production.cpp:412:tests_are_equal
 * @param t1 first test to compare
 * @param t2 second test to compare
 * @return true if the two tests are equal
 */
static boolean tests_are_equal(Test t1,Test t2){
  if (t1 == t2) {
    return true;
  }
  if (t1.getClass() != t2.getClass()) {
    return false;
  }
  EqualityTest eq1=t1.asEqualityTest();
  if (eq1 != null) {
    return eq1.getReferent() == t2.asEqualityTest().getReferent();
  }
  if (t1.asGoalIdTest() != null || t1.asImpasseIdTest() != null) {
    return true;
  }
  DisjunctionTest dt=t1.asDisjunctionTest();
  if (dt != null) {
    return dt.disjunction_list.equals(t2.asDisjunctionTest().disjunction_list);
  }
  ConjunctiveTest ct=t1.asConjunctiveTest();
  if (ct != null) {
    List<Test> c1=ct.conjunct_list;
    List<Test> c2=t2.asConjunctiveTest().conjunct_list;
    if (c1.size() != c2.size()) {
      return false;
    }
    for (int i=0; i < c1.size(); ++i) {
      if (!tests_are_equal(c1.get(i),c2.get(i))) {
        return false;
      }
    }
    return true;
  }
  return t1.asRelationalTest().referent == t2.asRelationalTest().referent;
}

Fixed version (ground truth):
/** 
 * production.cpp:412:tests_are_equal
 * @param t1 first test to compare
 * @param t2 second test to compare
 * @param neg if tests are part of a negation
 * @return true if the two tests are equal
 */
static boolean tests_are_equal(Test t1,Test t2,boolean neg){
  if (t1 == t2) {
    return true;
  }
  if (t1.getClass() != t2.getClass()) {
    return false;
  }
  EqualityTest eq1=t1.asEqualityTest();
  if (eq1 != null) {
    if (neg) {
      if (eq1.getReferent().asVariable() != null) {
        EqualityTest eq2=t2.asEqualityTest();
        if (eq2 != null && eq2.getReferent().asVariable() != null) {
          return true;
        }
      }
    }
    return eq1.getReferent() == t2.asEqualityTest().getReferent();
  }
  if (t1.asGoalIdTest() != null || t1.asImpasseIdTest() != null) {
    return true;
  }
  DisjunctionTest dt=t1.asDisjunctionTest();
  if (dt != null) {
    return dt.disjunction_list.equals(t2.asDisjunctionTest().disjunction_list);
  }
  ConjunctiveTest ct=t1.asConjunctiveTest();
  if (ct != null) {
    List<Test> c1=ct.conjunct_list;
    List<Test> c2=t2.asConjunctiveTest().conjunct_list;
    if (c1.size() != c2.size()) {
      return false;
    }
    List<Test> copy2=Lists.newLinkedList(c2);
    for (int i=0; i < c1.size(); ++i) {
      for (int j=0; j < copy2.size(); ++j) {
        if (tests_are_equal(c1.get(i),copy2.get(j),neg)) {
          copy2.remove(j);
          break;
        }
      }
    }
    return copy2.size() == 0;
  }
  return t1.asRelationalTest().referent == t2.asRelationalTest().referent;
}
Program: 12307
Project: 12307
Buggy source:
/** 
 * Returns a hash value for the given test. <p>TODO make this polymorphic <p>production.cpp:450:hash_test
 * @param t The test to hash
 * @return The has value for the test
 */
public static int hash_test(Test t){
  if (Tests.isBlank(t))   return 0;
  EqualityTest eq=t.asEqualityTest();
  if (eq != null)   return eq.getReferent().hash_id;
  if (t.asGoalIdTest() != null) {
    return 34894895;
  }
  if (t.asImpasseIdTest() != null) {
    return 2089521;
  }
  DisjunctionTest dt=t.asDisjunctionTest();
  if (dt != null) {
    int result=7245;
    for (    SymbolImpl c : dt.disjunction_list)     result=result + c.hash_id;
    return result;
  }
  ConjunctiveTest ct=t.asConjunctiveTest();
  if (ct != null) {
    int result=100276;
    for (    Test c : ct.conjunct_list)     result=result + hash_test(c);
    return result;
  }
  RelationalTest rt=t.asRelationalTest();
  if (rt != null) {
    return (rt.type << 24) + rt.referent.hash_id;
  }
  throw new IllegalStateException("String_Node_Str" + t);
}

Fixed version (ground truth):
/** 
 * Returns a hash value for the given test. <p>TODO make this polymorphic <p>production.cpp:450:hash_test
 * @param t The test to hash
 * @return The has value for the test
 */
public static int hash_test(Test t){
  if (Tests.isBlank(t))   return 0;
  EqualityTest eq=t.asEqualityTest();
  if (eq != null)   return eq.getReferent().hash_id;
  if (t.asGoalIdTest() != null) {
    return 34894895;
  }
  if (t.asImpasseIdTest() != null) {
    return 2089521;
  }
  DisjunctionTest dt=t.asDisjunctionTest();
  if (dt != null) {
    int result=7245;
    for (    SymbolImpl c : dt.disjunction_list)     result=result + c.hash_id;
    return result;
  }
  ConjunctiveTest ct=t.asConjunctiveTest();
  if (ct != null) {
    int result=100276;
    return result;
  }
  RelationalTest rt=t.asRelationalTest();
  if (rt != null) {
    return (rt.type << 24) + rt.referent.hash_id;
  }
  throw new IllegalStateException("String_Node_Str" + t);
}
Program: 12308
Project: 12308
Buggy source:
/** 
 * Same as add_new_test_to_test(), only has no effect if the second test is already included in the first one. <p>production.cpp:384:add_new_test_to_test_if_not_already_there
 * @param t test to add new test to
 * @param add_me the test to add
 * @return resulting test, possibly t, but not necessarily.
 */
public static Test add_new_test_to_test_if_not_already_there(Test t,Test add_me){
  if (tests_are_equal(t,add_me)) {
    return t;
  }
  ConjunctiveTest ct=t.asConjunctiveTest();
  if (ct != null) {
    for (    Test child : ct.conjunct_list) {
      if (tests_are_equal(child,add_me)) {
        return t;
      }
    }
  }
  return add_new_test_to_test(t,add_me);
}

Fixed version (ground truth):
/** 
 * Same as add_new_test_to_test(), only has no effect if the second test is already included in the first one. <p>production.cpp:384:add_new_test_to_test_if_not_already_there
 * @param t test to add new test to
 * @param add_me the test to add
 * @param neg if part of a negative condition
 * @return resulting test, possibly t, but not necessarily.
 */
public static Test add_new_test_to_test_if_not_already_there(Test t,Test add_me,boolean neg){
  if (tests_are_equal(t,add_me,neg)) {
    return t;
  }
  ConjunctiveTest ct=t.asConjunctiveTest();
  if (ct != null) {
    for (    Test child : ct.conjunct_list) {
      if (tests_are_equal(child,add_me,neg)) {
        return t;
      }
    }
  }
  return add_new_test_to_test(t,add_me);
}
Program: 12309
Project: 12309
Buggy source:
/** 
 * @param agent the agent to wrap.
 */
private ThreadedAgent(Agent agent){
  this.agent=agent;
  agentThread.setName("String_Node_Str" + this.agent + "String_Node_Str");
  this.agent.getEventManager().addListener(RunLoopEvent.class,new SoarEventListener(){
    @Override public void onEvent(    SoarEvent event){
      if (Thread.interrupted()) {
        throw new InterruptAgentException();
      }
      Runnable runnable=commands.poll();
      while (runnable != null) {
        runnable.run();
        runnable=commands.poll();
      }
    }
  }
);
  waitFunction.attach(this);
}

Fixed version (ground truth):
/** 
 * @param agent the agent to wrap.
 */
private ThreadedAgent(Agent agent){
  this.agent=agent;
  agentThread.setName("String_Node_Str" + this.agent + "String_Node_Str");
  this.agent.getEventManager().addListener(RunLoopEvent.class,new SoarEventListener(){
    @Override public void onEvent(    SoarEvent event){
      if (Thread.currentThread().isInterrupted()) {
        throw new InterruptAgentException();
      }
      Runnable runnable=commands.poll();
      while (runnable != null) {
        runnable.run();
        runnable=commands.poll();
      }
    }
  }
);
  waitFunction.attach(this);
}
Program: 12310
Project: 12310
Buggy source:
@Override public void onEvent(SoarEvent event){
  if (Thread.interrupted()) {
    throw new InterruptAgentException();
  }
  Runnable runnable=commands.poll();
  while (runnable != null) {
    runnable.run();
    runnable=commands.poll();
  }
}

Fixed version (ground truth):
@Override public void onEvent(SoarEvent event){
  if (Thread.currentThread().isInterrupted()) {
    throw new InterruptAgentException();
  }
  Runnable runnable=commands.poll();
  while (runnable != null) {
    runnable.run();
    runnable=commands.poll();
  }
}
Program: 12311
Project: 12311
Buggy source:
private void doWait(){
  if (waitTimeout < -1) {
    inputReady.set(false);
    return;
  }
synchronized (this) {
    waiting.set(true);
  }
  final long start=System.currentTimeMillis();
  final BlockingQueue<Runnable> commands=agent.getCommandQueue();
  boolean done=isDoneWaiting();
  while (!done) {
    try {
      final long remaining=waitTimeout - (System.currentTimeMillis() - start);
      if (remaining <= 0) {
        done=true;
      }
      final Runnable command=commands.poll(remaining,TimeUnit.MILLISECONDS);
      if (command != null) {
        command.run();
        done=isDoneWaiting();
      }
 else {
        done=true;
      }
    }
 catch (    InterruptedException e) {
      done=true;
      break;
    }
  }
  waitTimeout=-1;
synchronized (this) {
    inputReady.set(false);
    waiting.set(false);
  }
}

Fixed version (ground truth):
private void doWait(){
  if (!requestedWaitInfo.waiting) {
    inputReady.set(false);
    return;
  }
synchronized (this) {
    waitInfo.set(requestedWaitInfo);
  }
  final long start=System.currentTimeMillis();
  final BlockingQueue<Runnable> commands=agent.getCommandQueue();
  boolean done=isDoneWaiting();
  while (!done) {
    try {
      final long remaining=requestedWaitInfo.timeout - (System.currentTimeMillis() - start);
      if (remaining <= 0) {
        done=true;
      }
      final Runnable command=commands.poll(remaining,TimeUnit.MILLISECONDS);
      if (command != null) {
        command.run();
        done=isDoneWaiting();
      }
 else {
        done=true;
      }
    }
 catch (    InterruptedException e) {
      done=true;
      Thread.currentThread().interrupt();
      break;
    }
  }
  requestedWaitInfo=WaitInfo.NOT_WAITING;
synchronized (this) {
    inputReady.set(false);
    waitInfo.set(WaitInfo.NOT_WAITING);
  }
}
Program: 12312
Project: 12312
Buggy source:
private synchronized void setNewInputAvailable(){
  inputReady.set(true);
  if (waiting.get()) {
    WaitRhsFunction.this.agent.execute(inputReadyCommand,null);
  }
}

Fixed version (ground truth):
private synchronized void setNewInputAvailable(){
  inputReady.set(true);
  if (waitInfo.get().waiting) {
    WaitRhsFunction.this.agent.execute(inputReadyCommand,null);
  }
}