nus-yam/ex-repair huggingface dataset:
Program: 146915
Project: 146915
Buggy source:
public void postProcessing(){
  CommCarePostFormEntryState httpAskSendState=new CommCarePostFormEntryState(message,CommCareSense.isAutoSendEnabled() || cacheable){
    public void goHome(){
      if (CommCareSense.isAutoSendEnabled()) {
        AutomatedSenderService.NotifyPending();
      }
      CommCareFormEntryState.this.goHome();
    }
  }
;
  J2MEDisplay.startStateWithLoadingScreen(httpAskSendState);
}

Fixed version (ground truth):
public void postProcessing(){
  CommCarePostFormEntryState httpAskSendState=new CommCarePostFormEntryState(message,CommCareSense.isAutoSendEnabled() || !cacheable){
    public void goHome(){
      if (CommCareSense.isAutoSendEnabled()) {
        AutomatedSenderService.NotifyPending();
      }
      CommCareFormEntryState.this.goHome();
    }
  }
;
  J2MEDisplay.startStateWithLoadingScreen(httpAskSendState);
}
Program: 146916
Project: 146916
Buggy source:
public void resetDemoData(){
  System.out.println("String_Node_Str");
  StorageManager.getStorage(Case.STORAGE_KEY).removeAll();
  StorageManager.getStorage(PatientReferral.STORAGE_KEY).removeAll();
  StorageManager.getStorage(FormInstance.STORAGE_KEY).removeAll();
}

Fixed version (ground truth):
public void resetDemoData(){
  System.out.println("String_Node_Str");
  StorageManager.getStorage(Case.STORAGE_KEY).removeAll();
  StorageManager.getStorage(PatientReferral.STORAGE_KEY).removeAll();
  StorageManager.getStorage(FormInstance.STORAGE_KEY).removeAll();
  StorageManager.getStorage(TransportMessageStore.Q_STORENAME).removeAll();
  StorageManager.getStorage(TransportMessageStore.RECENTLY_SENT_STORENAME).removeAll();
}
Program: 146917
Project: 146917
Buggy source:
public void toggleDemoMode(boolean demoOn){
  if (demoOn != inDemoMode) {
    inDemoMode=demoOn;
    if (demoOn) {
      registerDemoStorage(Case.STORAGE_KEY,Case.class);
      registerDemoStorage(PatientReferral.STORAGE_KEY,PatientReferral.class);
      registerDemoStorage(FormInstance.STORAGE_KEY,FormInstance.class);
    }
 else {
      StorageManager.registerStorage(Case.STORAGE_KEY,Case.class);
      StorageManager.registerStorage(PatientReferral.STORAGE_KEY,PatientReferral.class);
      StorageManager.registerStorage(FormInstance.STORAGE_KEY,FormInstance.class);
    }
  }
}

Fixed version (ground truth):
public void toggleDemoMode(boolean demoOn){
  if (demoOn != inDemoMode) {
    inDemoMode=demoOn;
    if (demoOn) {
      registerDemoStorage(Case.STORAGE_KEY,Case.class);
      registerDemoStorage(PatientReferral.STORAGE_KEY,PatientReferral.class);
      registerDemoStorage(FormInstance.STORAGE_KEY,FormInstance.class);
      registerWrappedDemoStorage(TransportMessageStore.Q_STORENAME,new TransportMessageSerializationWrapper());
      registerWrappedDemoStorage(TransportMessageStore.RECENTLY_SENT_STORENAME,new TransportMessageSerializationWrapper());
      TransportService.reinit();
    }
 else {
      StorageManager.registerStorage(Case.STORAGE_KEY,Case.class);
      StorageManager.registerStorage(PatientReferral.STORAGE_KEY,PatientReferral.class);
      StorageManager.registerStorage(FormInstance.STORAGE_KEY,FormInstance.class);
      StorageManager.registerWrappedStorage(TransportMessageStore.Q_STORENAME,TransportMessageStore.Q_STORENAME,new TransportMessageSerializationWrapper());
      StorageManager.registerWrappedStorage(TransportMessageStore.RECENTLY_SENT_STORENAME,TransportMessageStore.RECENTLY_SENT_STORENAME,new TransportMessageSerializationWrapper());
      TransportService.reinit();
    }
  }
}
Program: 146921
Project: 146921
Buggy source:
public boolean install(Resource r,ResourceLocation location,Reference ref,ResourceTable table,CommCareInstance instance,boolean upgrade) throws UnresolvedResourceException {
  if (location.getAuthority() == Resource.RESOURCE_AUTHORITY_CACHE) {
    return false;
  }
 else {
    try {
      SuiteParser parser=new SuiteParser(ref.getStream(),table,r.getRecordGuid());
      Suite s=parser.parse();
      storage().write(s);
      cacheLocation=s.getID();
      table.commit(r,Resource.RESOURCE_STATUS_INSTALLED);
      return true;
    }
 catch (    InvalidStructureException e) {
      e.printStackTrace();
      return false;
    }
catch (    StorageFullException e) {
      e.printStackTrace();
      return false;
    }
catch (    IOException e) {
      e.printStackTrace();
      return false;
    }
catch (    XmlPullParserException e) {
      e.printStackTrace();
      return false;
    }
  }
}

Fixed version (ground truth):
public boolean install(Resource r,ResourceLocation location,Reference ref,ResourceTable table,CommCareInstance instance,boolean upgrade) throws UnresolvedResourceException {
  if (location.getAuthority() == Resource.RESOURCE_AUTHORITY_CACHE) {
    return false;
  }
 else {
    try {
      SuiteParser parser=new SuiteParser(ref.getStream(),table,r.getRecordGuid());
      if (location.getAuthority() == Resource.RESOURCE_AUTHORITY_REMOTE) {
        parser.setMaximumAuthority(Resource.RESOURCE_AUTHORITY_REMOTE);
      }
      Suite s=parser.parse();
      storage().write(s);
      cacheLocation=s.getID();
      table.commit(r,Resource.RESOURCE_STATUS_INSTALLED);
      return true;
    }
 catch (    InvalidStructureException e) {
      e.printStackTrace();
      return false;
    }
catch (    StorageFullException e) {
      e.printStackTrace();
      return false;
    }
catch (    IOException e) {
      e.printStackTrace();
      return false;
    }
catch (    XmlPullParserException e) {
      e.printStackTrace();
      return false;
    }
  }
}
Program: 146922
Project: 146922
Buggy source:
public ResourceTable stageUpgradeTable(ResourceTable global,ResourceTable temporary,String profileRef) throws UnfullfilledRequirementsException, StorageFullException, UnresolvedResourceException {
  temporary.clear();
  Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
  locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_LOCAL,profileRef));
  Resource r=new Resource(Resource.RESOURCE_VERSION_UNKNOWN,APP_PROFILE_RESOURCE_ID,locations);
  temporary.addResource(r,temporary.getInstallers().getProfileInstaller(false),null);
  temporary.prepareResources(global,this,APP_PROFILE_RESOURCE_ID);
  return temporary;
}

Fixed version (ground truth):
public ResourceTable stageUpgradeTable(ResourceTable global,ResourceTable temporary,String profileRef) throws UnfullfilledRequirementsException, StorageFullException, UnresolvedResourceException {
  temporary.clear();
  Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
  locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_REMOTE,profileRef));
  Resource r=new Resource(Resource.RESOURCE_VERSION_UNKNOWN,APP_PROFILE_RESOURCE_ID,locations);
  temporary.addResource(r,temporary.getInstallers().getProfileInstaller(false),null);
  temporary.prepareResources(global,this,APP_PROFILE_RESOURCE_ID);
  return temporary;
}
Program: 146923
Project: 146923
Buggy source:
public void init(String profileReference,ResourceTable global,boolean forceInstall) throws UnfullfilledRequirementsException, UnresolvedResourceException {
  try {
    if (!global.isReady()) {
      global.prepareResources(null,this);
    }
    Resource profile=global.getResourceWithId(APP_PROFILE_RESOURCE_ID);
    if (profile == null) {
      Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
      locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_REMOTE,profileReference));
      Resource r=new Resource(Resource.RESOURCE_VERSION_UNKNOWN,APP_PROFILE_RESOURCE_ID,locations);
      global.addResource(r,global.getInstallers().getProfileInstaller(forceInstall),"String_Node_Str");
      global.prepareResources(null,this);
    }
 else {
    }
  }
 catch (  StorageFullException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void init(String profileReference,ResourceTable global,boolean forceInstall) throws UnfullfilledRequirementsException, UnresolvedResourceException {
  try {
    if (!global.isReady()) {
      global.prepareResources(null,this);
    }
    Resource profile=global.getResourceWithId(APP_PROFILE_RESOURCE_ID);
    if (profile == null) {
      Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
      locations.addElement(new ResourceLocation(Resource.RESOURCE_AUTHORITY_LOCAL,profileReference));
      Resource r=new Resource(Resource.RESOURCE_VERSION_UNKNOWN,APP_PROFILE_RESOURCE_ID,locations);
      global.addResource(r,global.getInstallers().getProfileInstaller(forceInstall),"String_Node_Str");
      global.prepareResources(null,this);
    }
 else {
    }
  }
 catch (  StorageFullException e) {
    e.printStackTrace();
  }
}
Program: 146924
Project: 146924
Buggy source:
public void upgrade(ResourceTable global,ResourceTable temporary) throws UnfullfilledRequirementsException {
  if (!global.isReady()) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    temporary.prepareResources(global,this);
    global.upgradeTable(temporary);
    temporary.destroy();
  }
 catch (  UnresolvedResourceException e) {
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str");
  }
  profile=-1;
  suites.removeAllElements();
  initialize(global);
}

Fixed version (ground truth):
public void upgrade(ResourceTable global,ResourceTable temporary) throws UnfullfilledRequirementsException {
  if (!global.isReady()) {
    throw new RuntimeException("String_Node_Str");
  }
  try {
    temporary.prepareResources(global,this);
    global.upgradeTable(temporary);
    temporary.destroy();
  }
 catch (  UnresolvedResourceException e) {
    Logger.exception(e);
    throw new RuntimeException("String_Node_Str");
  }
  profile=-1;
  suites.removeAllElements();
  initialize(global);
}
Program: 146926
Project: 146926
Buggy source:
public ResourceParser(KXmlParser parser){
  super(parser);
}

Fixed version (ground truth):
public ResourceParser(KXmlParser parser,int maximumAuthority){
  super(parser);
  this.maximumAuthority=maximumAuthority;
}
Program: 146927
Project: 146927
Buggy source:
public Resource parse() throws InvalidStructureException, IOException, XmlPullParserException {
  checkNode("String_Node_Str");
  String id=parser.getAttributeValue(null,"String_Node_Str");
  int version=parseInt(parser.getAttributeValue(null,"String_Node_Str"));
  Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
  while (nextTagInBlock("String_Node_Str")) {
    String sAuthority=parser.getAttributeValue(null,"String_Node_Str");
    String location=parser.nextText();
    int authority=Resource.RESOURCE_AUTHORITY_REMOTE;
    if (sAuthority.toLowerCase().equals("String_Node_Str")) {
      authority=Resource.RESOURCE_AUTHORITY_LOCAL;
    }
 else     if (sAuthority.toLowerCase().equals("String_Node_Str")) {
      authority=Resource.RESOURCE_AUTHORITY_REMOTE;
    }
    locations.addElement(new ResourceLocation(authority,location));
  }
  return new Resource(version,id,locations);
}

Fixed version (ground truth):
public Resource parse() throws InvalidStructureException, IOException, XmlPullParserException {
  checkNode("String_Node_Str");
  String id=parser.getAttributeValue(null,"String_Node_Str");
  int version=parseInt(parser.getAttributeValue(null,"String_Node_Str"));
  Vector<ResourceLocation> locations=new Vector<ResourceLocation>();
  while (nextTagInBlock("String_Node_Str")) {
    String sAuthority=parser.getAttributeValue(null,"String_Node_Str");
    String location=parser.nextText();
    int authority=Resource.RESOURCE_AUTHORITY_REMOTE;
    if (sAuthority.toLowerCase().equals("String_Node_Str")) {
      authority=Resource.RESOURCE_AUTHORITY_LOCAL;
    }
 else     if (sAuthority.toLowerCase().equals("String_Node_Str")) {
      authority=Resource.RESOURCE_AUTHORITY_REMOTE;
    }
    if (authority >= maximumAuthority) {
      locations.addElement(new ResourceLocation(authority,location));
    }
  }
  return new Resource(version,id,locations);
}
Program: 146929
Project: 146929
Buggy source:
private Vector scrapeForCaseElements(FormInstance tree){
  Vector caseElements=new Vector();
  Stack children=new Stack();
  children.push(tree.getRoot());
  while (!children.empty()) {
    TreeElement element=(TreeElement)children.pop();
    for (int i=0; i < element.getNumChildren(); ++i) {
      TreeElement caseElement=element.getChildAt(i);
      if (!caseElement.isRelevant()) {
        continue;
      }
      if (caseElement.getName().equals("String_Node_Str")) {
        caseElements.addElement(caseElement);
      }
 else {
        children.push(caseElement);
      }
    }
  }
  return caseElements;
}

Fixed version (ground truth):
private Vector scrapeForCaseElements(FormInstance tree){
  Vector caseElements=new Vector();
  Stack children=new Stack();
  children.push(tree.getRoot());
  while (!children.empty()) {
    TreeElement element=(TreeElement)children.pop();
    for (int i=0; i < element.getNumChildren(); ++i) {
      TreeElement caseElement=element.getChildAt(i);
      if (!caseElement.isRelevant() || caseElement.getMult() == TreeReference.INDEX_TEMPLATE) {
        continue;
      }
      if (caseElement.getName().equals("String_Node_Str")) {
        caseElements.addElement(caseElement);
      }
 else {
        children.push(caseElement);
      }
    }
  }
  return caseElements;
}
Program: 146930
Project: 146930
Buggy source:
/** 
 * Registers a resource file as a source of locale data for the specified locale.  
 * @param locale The locale of the definitions provided. 
 * @param resource A LocaleDataSource containing string data for the locale provided
 * @throws NullPointerException if resource or locale are null
 */
public void registerLocaleResource(String locale,LocaleDataSource resource){
  if (locale == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (resource == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Vector resources=new Vector();
  if (localeResources.containsKey(locale)) {
    resources=(Vector)localeResources.get(locale);
  }
  resources.addElement(resource);
  localeResources.put(locale,resources);
  if (locale.equals(currentLocale)) {
    loadCurrentLocaleResources();
  }
}

Fixed version (ground truth):
/** 
 * Registers a resource file as a source of locale data for the specified locale.  
 * @param locale The locale of the definitions provided. 
 * @param resource A LocaleDataSource containing string data for the locale provided
 * @throws NullPointerException if resource or locale are null
 */
public void registerLocaleResource(String locale,LocaleDataSource resource){
  if (locale == null) {
    throw new NullPointerException("String_Node_Str");
  }
  if (resource == null) {
    throw new NullPointerException("String_Node_Str");
  }
  Vector resources=new Vector();
  if (localeResources.containsKey(locale)) {
    resources=(Vector)localeResources.get(locale);
  }
  resources.addElement(resource);
  localeResources.put(locale,resources);
  if (locale.equals(currentLocale) || locale.equals(defaultLocale)) {
    loadCurrentLocaleResources();
  }
}
Program: 146931
Project: 146931
Buggy source:
/** 
 * Load the ID index from the indexing/meta-data RMS
 * @return index hashtable, which maps integer record ID -> record locator
 */
public Hashtable getIDIndexRecord(){
  return (Hashtable)getIndexStore().readRecord(ID_INDEX_REC_ID,new ExtWrapMap(Integer.class,RMSRecordLoc.class));
}

Fixed version (ground truth):
/** 
 * Load the ID index from the indexing/meta-data RMS
 * @return index hashtable, which maps integer record ID -> record locator
 */
public Hashtable getIDIndexRecord(){
  if (this.transactionKey != null) {
    return (Hashtable)this.deleteActionCache[1];
  }
  return (Hashtable)getIndexStore().readRecord(ID_INDEX_REC_ID,new ExtWrapMap(Integer.class,RMSRecordLoc.class));
}
Program: 146932
Project: 146932
Buggy source:
/** 
 * Check that the StorageUtility is in an initialized, consistent, non-corrupt state. Throw an exception if it is not If the StorageUtility was not properly initialized, this call will fail. If transactions on this StorageUtility are currently in progress (such as by other threads), or a past transaction failed and did not properly clean itself up, this call will fail. 
 */
public void checkNotCorrupt(){
  checkStatusOK(false);
}

Fixed version (ground truth):
/** 
 * Check that the StorageUtility is in an initialized, consistent, non-corrupt state. Throw an exception if it is not If the StorageUtility was not properly initialized, this call will fail. If transactions on this StorageUtility are currently in progress (such as by other threads), or a past transaction failed and did not properly clean itself up, this call will fail. 
 */
public void checkNotCorrupt(){
  if (this.transactionKey == null) {
    checkStatusOK(false);
  }
 else {
    checkStatusOK(true);
  }
}
Program: 146934
Project: 146934
Buggy source:
protected void setMessage(String message){
  interaction.setMessage(message);
}

Fixed version (ground truth):
protected void setMessage(String message){
  interaction.setMessage(message,true);
}
Program: 146935
Project: 146935
Buggy source:
public CommCareListView(String title,boolean autoSelect,boolean numericNavigation){
  super(title,List.IMPLICIT);
  this.addCommand(BACK);
  this.choiceGroup=new CustomChoiceGroup(null,ChoiceGroup.IMPLICIT,autoSelect,numericNavigation){
    public void playAudio(    int index){
      if (audioLocations.size() > index && audioLocations.elementAt(index) != null) {
        MediaUtils.playAudio(audioLocations.elementAt(index));
      }
    }
  }
;
  this.choiceGroup.isFocused=true;
  this.container=this.choiceGroup;
}

Fixed version (ground truth):
public CommCareListView(String title,boolean autoSelect,boolean numericNavigation){
  super(title,List.IMPLICIT);
  this.choiceGroup=new CustomChoiceGroup(null,ChoiceGroup.IMPLICIT,autoSelect,numericNavigation){
    public void playAudio(    int index){
      if (audioLocations.size() > index && audioLocations.elementAt(index) != null) {
        MediaUtils.playAudio(audioLocations.elementAt(index));
      }
    }
  }
;
  this.choiceGroup.isFocused=true;
  this.container=this.choiceGroup;
}
Program: 146936
Project: 146936
Buggy source:
public CommCareStartupInteraction(String message){
  super(failSafeText("String_Node_Str","String_Node_Str"));
  messageItem=new StringItem(null,message);
  this.append(messageItem);
  this.setCommandListener(this);
}

Fixed version (ground truth):
public CommCareStartupInteraction(String message){
  super(failSafeText("String_Node_Str","String_Node_Str"));
  messageItem=new StringItem(null,null);
  gauge=new Gauge(null,false,Gauge.INDEFINITE,Gauge.CONTINUOUS_RUNNING);
  this.append(messageItem);
  this.append(gauge);
  gauge.setVisible(false);
  this.setCommandListener(this);
  setMessage(message,true);
}
Program: 146937
Project: 146937
Buggy source:
public void AskYesNo(String message,YesNoListener listener){
  messageItem.setText(message);
  this.listener=listener;
  if (yes == null) {
    yes=new Command(failSafeText("String_Node_Str","String_Node_Str"),Command.OK,0);
    no=new Command(failSafeText("String_Node_Str","String_Node_Str"),Command.CANCEL,0);
    this.addCommand(yes);
    this.addCommand(no);
  }
}

Fixed version (ground truth):
public void AskYesNo(String message,YesNoListener listener){
  setMessage(message,false);
  this.listener=listener;
  if (yes == null) {
    yes=new Command(failSafeText("String_Node_Str","String_Node_Str"),Command.OK,0);
    no=new Command(failSafeText("String_Node_Str","String_Node_Str"),Command.CANCEL,0);
    this.addCommand(yes);
    this.addCommand(no);
  }
}
Program: 146938
Project: 146938
Buggy source:
public void setMessage(String message){
  this.messageItem.setText(message);
}

Fixed version (ground truth):
public void setMessage(String message,boolean showSpinner){
  this.messageItem.setText(message);
  gauge.setVisible(showSpinner);
}
Program: 146939
Project: 146939
Buggy source:
public CommCareSuiteController(CommCareSessionController controller,Menu m){
  this.m=m;
  this.controller=controller;
  view=new CommCareListView(m.getName().evaluate());
  view.setCommandListener(this);
}

Fixed version (ground truth):
public CommCareSuiteController(CommCareSessionController controller,Menu m){
  this.m=m;
  this.controller=controller;
  view=new CommCareListView(m.getName().evaluate());
  view.setCommandListener(this);
  view.addCommand(BACK);
}
Program: 146940
Project: 146940
Buggy source:
public void _commandAction(Command c,Displayable d){
  if (c.equals(List.SELECT_COMMAND)) {
    controller.chooseSessionItem(view.getSelectedIndex());
    controller.next();
  }
 else   if (c.equals(CommCareListView.BACK)) {
    transitions.exitMenuTransition();
  }
}

Fixed version (ground truth):
public void _commandAction(Command c,Displayable d){
  if (c.equals(List.SELECT_COMMAND)) {
    controller.chooseSessionItem(view.getSelectedIndex());
    controller.next();
  }
 else   if (c.equals(BACK)) {
    transitions.exitMenuTransition();
  }
}
Program: 146941
Project: 146941
Buggy source:
private void completeDeleteAction(Object transactionKey){
synchronized (getAccessLock()) {
    if (this.transactionKey == null || deleteActionCache == null) {
      throw new RuntimeException("String_Node_Str");
    }
    if (!this.transactionKey.equals(transactionKey)) {
      return;
    }
    RMSStorageInfo info=(RMSStorageInfo)deleteActionCache[0];
    Hashtable idIndex=(Hashtable)deleteActionCache[1];
    commitIndex(info,idIndex);
    deleteActionCache=null;
    transactionKey=null;
    setClean();
    storageModified();
  }
}

Fixed version (ground truth):
private void completeDeleteAction(Object transactionKey){
synchronized (getAccessLock()) {
    if (this.transactionKey == null || deleteActionCache == null) {
      throw new RuntimeException("String_Node_Str");
    }
    if (!this.transactionKey.equals(transactionKey)) {
      return;
    }
    RMSStorageInfo info=(RMSStorageInfo)deleteActionCache[0];
    Hashtable idIndex=(Hashtable)deleteActionCache[1];
    commitIndex(info,idIndex);
    this.deleteActionCache=null;
    this.transactionKey=null;
    setClean();
    storageModified();
  }
}
Program: 146943
Project: 146943
Buggy source:
public Vector<Entry> getEntriesForCommand(String commandId){
  Hashtable<String,Entry> map=platform.getMenuMap();
  Menu menu=null;
  Entry entry=null;
  top:   for (  Suite s : platform.getInstalledSuites()) {
    for (    Menu m : s.getMenus()) {
      if (currentCmd.equals(m.getId())) {
        menu=m;
        break top;
      }
      if (s.getEntries().containsKey(currentCmd)) {
        entry=s.getEntries().get(currentCmd);
        break top;
      }
    }
  }
  Vector<Entry> entries=new Vector<Entry>();
  if (entry != null) {
    entries.addElement(entry);
  }
  if (menu != null) {
    for (    String cmd : menu.getCommandIds()) {
      Entry e=map.get(cmd);
      entries.addElement(e);
    }
  }
  return entries;
}

Fixed version (ground truth):
public Vector<Entry> getEntriesForCommand(String commandId){
  Hashtable<String,Entry> map=platform.getMenuMap();
  Menu menu=null;
  Entry entry=null;
  top:   for (  Suite s : platform.getInstalledSuites()) {
    for (    Menu m : s.getMenus()) {
      if (commandId.equals(m.getId())) {
        menu=m;
        break top;
      }
      if (s.getEntries().containsKey(commandId)) {
        entry=s.getEntries().get(commandId);
        break top;
      }
    }
  }
  Vector<Entry> entries=new Vector<Entry>();
  if (entry != null) {
    entries.addElement(entry);
  }
  if (menu != null) {
    for (    String cmd : menu.getCommandIds()) {
      Entry e=map.get(cmd);
      entries.addElement(e);
    }
  }
  return entries;
}
Program: 146944
Project: 146944
Buggy source:
private boolean handled(Object a,Object b,Object sentinal,Vector<Object> pivots) throws UnpivotableExpressionException {
  if (sentinal == a) {
    if (b == null) {
      throw new UnpivotableExpressionException();
    }
 else     if (sentinal == b) {
      throw new UnpivotableExpressionException();
    }
 else {
      pivots.addElement(new CmpPivot(((Double)b).doubleValue(),op));
      return true;
    }
  }
  return false;
}

Fixed version (ground truth):
private boolean handled(Object a,Object b,Object sentinal,Vector<Object> pivots) throws UnpivotableExpressionException {
  if (sentinal == a) {
    if (b == null) {
      throw new UnpivotableExpressionException();
    }
 else     if (sentinal == b) {
      throw new UnpivotableExpressionException();
    }
 else {
      Double val=null;
      if (b instanceof Double) {
        val=(Double)b;
      }
 else {
        if (b instanceof Integer) {
          val=new Double(((Integer)b).doubleValue());
        }
        if (b instanceof Long) {
          val=new Double(((Long)b).doubleValue());
        }
        if (b instanceof Float) {
          val=new Double(((Float)b).doubleValue());
        }
        if (b instanceof Short) {
          val=new Double(((Short)b).shortValue());
        }
        if (b instanceof Byte) {
          val=new Double(((Byte)b).byteValue());
        }
 else {
          throw new UnpivotableExpressionException("String_Node_Str" + b);
        }
      }
      pivots.addElement(new CmpPivot(val.doubleValue(),op));
      return true;
    }
  }
  return false;
}
Program: 146945
Project: 146945
Buggy source:
public void loggedIn(User u,String password){
  CommCareContext._().setUser(u,password == null ? null : new DefaultHttpCredentialProvider(u.getUsername(),password));
  Logger.log("String_Node_Str",PropertyUtils.trim(u.getUniqueId(),8) + "String_Node_Str" + u.getUsername());
  CommCareContext._().toggleDemoMode(User.DEMO_USER.equals(u.getUserType()));
  J2MEDisplay.startStateWithLoadingScreen(new DeviceReportState(){
    public String getDestURL(){
      String url=PropertyManager._().getSingularProperty(LogPropertyRules.LOG_SUBMIT_URL);
      if (url == null) {
        url=CommCareContext._().getSubmitURL();
      }
      return url;
    }
    public void done(){
      J2MEDisplay.startStateWithLoadingScreen(new PeriodicWrapperState(CommCareContext._().getEventDescriptors()){
        public void done(){
          J2MEDisplay.startStateWithLoadingScreen(new CommCareHomeState());
        }
      }
);
    }
  }
);
}

Fixed version (ground truth):
public void loggedIn(User u,String password){
  CommCareContext._().setUser(u,password == null ? null : new DefaultHttpCredentialProvider(u.getUsername(),password));
  Logger.log("String_Node_Str",PropertyUtils.trim(u.getUniqueId(),8) + "String_Node_Str" + u.getUsername());
  CommCareContext._().toggleDemoMode(User.DEMO_USER.equals(u.getUserType()));
  CommCareUtil.launchHomeWithSchedulers();
}
Program: 146946
Project: 146946
Buggy source:
public static void launchFirstState(){
  if (!CommCareContext._().getManager().getCurrentProfile().isFeatureActive("String_Node_Str")) {
    CommCareUtil.launchHomeState();
    return;
  }
  if (CommCareProperties.FIRST_RUN_YES.equals(PropertyManager._().getSingularProperty(CommCareProperties.IS_FIRST_RUN))) {
    J2MEDisplay.startStateWithLoadingScreen(new CommCareFirstStartState());
  }
 else {
    J2MEDisplay.startStateWithLoadingScreen(new CommCareLoginState());
  }
}

Fixed version (ground truth):
public static void launchFirstState(){
  if (!CommCareContext._().getManager().getCurrentProfile().isFeatureActive("String_Node_Str")) {
    CommCareUtil.launchHomeWithSchedulers();
    return;
  }
  if (CommCareProperties.FIRST_RUN_YES.equals(PropertyManager._().getSingularProperty(CommCareProperties.IS_FIRST_RUN))) {
    J2MEDisplay.startStateWithLoadingScreen(new CommCareFirstStartState());
  }
 else {
    J2MEDisplay.startStateWithLoadingScreen(new CommCareLoginState());
  }
}
Program: 146947
Project: 146947
Buggy source:
/** 
 * Process the response to the current message (may have side effects).
 * @param message A completed transport message with an available response.
 * @return A string with the user facing messages which were parsed out from that response. 
 * @throws InvalidStructureException If the response is present, but incorrectly structured
 * @throws IOException 
 * @throws UnfullfilledRequirementsException If the isn't capable of processing the provided messagefor well recognized reasons (Like the API version of the response being above that currently understood) 
 * @throws XmlPullParserException
 */
public String processResponse(SimpleHttpTransportMessage message) throws InvalidStructureException, IOException, UnfullfilledRequirementsException, XmlPullParserException {
  if (message.getResponseProperties() != null && message.getResponseProperties().getORApiVersion().equals(ONE_OH)) {
    byte[] response=message.getResponseBody();
    CommCareTransactionParserFactory factory=new CommCareTransactionParserFactory(true);
    DataModelPullParser parser=new DataModelPullParser(new ByteArrayInputStream(response),factory);
    boolean success=parser.parse();
    if (factory.getResponseMessage() != null) {
      return factory.getResponseMessage();
    }
 else {
      return null;
    }
  }
  throw new UnfullfilledRequirementsException("String_Node_Str",UnfullfilledRequirementsException.SEVERITY_ENVIRONMENT);
}

Fixed version (ground truth):
/** 
 * Process the response to the current message (may have side effects).
 * @param message A completed transport message with an available response.
 * @return A string with the user facing messages which were parsed out from that response. 
 * @throws InvalidStructureException If the response is present, but incorrectly structured
 * @throws IOException 
 * @throws UnfullfilledRequirementsException If the isn't capable of processing the provided messagefor well recognized reasons (Like the API version of the response being above that currently understood) 
 * @throws XmlPullParserException
 */
public String processResponse(SimpleHttpTransportMessage message) throws InvalidStructureException, IOException, UnfullfilledRequirementsException, XmlPullParserException {
  if (message.getResponseProperties() != null && ONE_OH.equals(message.getResponseProperties().getORApiVersion())) {
    byte[] response=message.getResponseBody();
    CommCareTransactionParserFactory factory=new CommCareTransactionParserFactory(true);
    DataModelPullParser parser=new DataModelPullParser(new ByteArrayInputStream(response),factory);
    boolean success=parser.parse();
    if (factory.getResponseMessage() != null) {
      return factory.getResponseMessage();
    }
 else {
      return null;
    }
  }
  throw new UnfullfilledRequirementsException("String_Node_Str",UnfullfilledRequirementsException.SEVERITY_ENVIRONMENT);
}
Program: 146948
Project: 146948
Buggy source:
/** 
 * Whether the processor knows that it is capable of processing the response to the current message.
 * @param message A completed transport message with an available response.
 * @return true if the processor should be able to handle the response. false otherwise.
 */
public boolean handlesResponse(SimpleHttpTransportMessage message){
  if (message.getResponseProperties() != null && message.getResponseProperties().getORApiVersion().equals(ONE_OH)) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
/** 
 * Whether the processor knows that it is capable of processing the response to the current message.
 * @param message A completed transport message with an available response.
 * @return true if the processor should be able to handle the response. false otherwise.
 */
public boolean handlesResponse(SimpleHttpTransportMessage message){
  if (message.getResponseProperties() != null && ONE_OH.equals(message.getResponseProperties().getORApiVersion())) {
    return true;
  }
  return false;
}
Program: 146950
Project: 146950
Buggy source:
/** 
 * Creates a new entry model for the form with the appropriate repeat structure
 * @param form
 * @param repeatStructure The structure of repeats (the repeat signals which shouldbe sent during form entry)
 * @throws IllegalArgumentException If repeatStructure is not valid
 */
public FormEntryModel(FormDef form,int repeatStructure){
  this.form=form;
  if (repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR) {
    throw new IllegalArgumentException(repeatStructure + "String_Node_Str");
  }
  this.repeatStructure=repeatStructure;
  this.currentFormIndex=FormIndex.createBeginningOfFormIndex();
}

Fixed version (ground truth):
/** 
 * Creates a new entry model for the form with the appropriate repeat structure
 * @param form
 * @param repeatStructure The structure of repeats (the repeat signals which shouldbe sent during form entry)
 * @throws IllegalArgumentException If repeatStructure is not valid
 */
public FormEntryModel(FormDef form,int repeatStructure){
  this.form=form;
  if (repeatStructure != REPEAT_STRUCTURE_LINEAR && repeatStructure != REPEAT_STRUCTURE_NON_LINEAR) {
    throw new IllegalArgumentException(repeatStructure + "String_Node_Str");
  }
  if (repeatStructure == REPEAT_STRUCTURE_NON_LINEAR && containsRepeatGuesses(form)) {
    repeatStructure=REPEAT_STRUCTURE_LINEAR;
  }
  this.repeatStructure=repeatStructure;
  this.currentFormIndex=FormIndex.createBeginningOfFormIndex();
}
Program: 146952
Project: 146952
Buggy source:
/** 
 * convert a value to a date. note that xpath has no intrinsic representation of dates, so this is off-spec. dates convert to strings as 'yyyy-mm-dd', convert to numbers as # of days since the unix epoch, and convert to booleans always as 'true' string and int conversions are reversable, however: * cannot convert bool to date * empty string and NaN (xpath's 'null values') go unchanged, instead of being converted into a date (which would cause an error, since Date has no null value (other than java null, which the xpath engine can't handle)) * note, however, than non-empty strings that aren't valid dates _will_ cause an error during conversion
 * @param o
 * @return
 */
public static Object toDate(Object o){
  o=unpack(o);
  if (o instanceof Double) {
    Double n=toInt(o);
    if (n.isNaN()) {
      return n;
    }
    if (n.isInfinite() || n.doubleValue() > Integer.MAX_VALUE || n.doubleValue() < Integer.MIN_VALUE) {
      throw new XPathTypeMismatchException("String_Node_Str");
    }
    return DateUtils.dateAdd(DateUtils.getDate(1970,1,1),n.intValue());
  }
 else   if (o instanceof String) {
    String s=(String)o;
    if (s.length() == 0) {
      return s;
    }
    Date d=DateUtils.parseDate(s);
    if (d == null) {
      throw new XPathTypeMismatchException("String_Node_Str");
    }
 else {
      return d;
    }
  }
 else   if (o instanceof Date) {
    return DateUtils.roundDate((Date)o);
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * convert a value to a date. note that xpath has no intrinsic representation of dates, so this is off-spec. dates convert to strings as 'yyyy-mm-dd', convert to numbers as # of days since the unix epoch, and convert to booleans always as 'true' string and int conversions are reversable, however: * cannot convert bool to date * empty string and NaN (xpath's 'null values') go unchanged, instead of being converted into a date (which would cause an error, since Date has no null value (other than java null, which the xpath engine can't handle)) * note, however, than non-empty strings that aren't valid dates _will_ cause an error during conversion
 * @param o
 * @return
 */
public static Object toDate(Object o){
  o=unpack(o);
  if (o instanceof Double) {
    Double n=toInt(o);
    if (n.isNaN()) {
      return n;
    }
    if (n.isInfinite() || n.doubleValue() > Integer.MAX_VALUE || n.doubleValue() < Integer.MIN_VALUE) {
      throw new XPathTypeMismatchException("String_Node_Str");
    }
    return DateUtils.dateAdd(DateUtils.getDate(1970,1,1),n.intValue());
  }
 else   if (o instanceof String) {
    String s=(String)o;
    if (s.length() == 0) {
      return s;
    }
    Date d=DateUtils.parseDateTime(s);
    if (d == null) {
      throw new XPathTypeMismatchException("String_Node_Str");
    }
 else {
      return d;
    }
  }
 else   if (o instanceof Date) {
    return DateUtils.roundDate((Date)o);
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str");
  }
}
Program: 146953
Project: 146953
Buggy source:
public void _commandAction(Command c,Displayable d){
  if (c.equals(CommCareOTACredentialEntry.DOWNLOAD)) {
    if (userExists(entry.getUsername())) {
      entry.sendMessage(Localization.get("String_Node_Str"));
      return;
    }
    tryDownload(getClientMessage());
  }
 else   if (d == entry && c.equals(CommCareOTACredentialEntry.CANCEL)) {
    transitions.cancel();
  }
 else   if (c.equals(view.FINISHED)) {
    transitions.done(errorsOccurred);
  }
}

Fixed version (ground truth):
public void _commandAction(Command c,Displayable d){
  if (c.equals(CommCareOTACredentialEntry.DOWNLOAD)) {
    if (userExists(entry.getUsername()) && !isSync) {
      entry.sendMessage(Localization.get("String_Node_Str"));
      return;
    }
    tryDownload(getClientMessage());
  }
 else   if (d == entry && c.equals(CommCareOTACredentialEntry.CANCEL)) {
    transitions.cancel();
  }
 else   if (c.equals(view.FINISHED)) {
    transitions.done(errorsOccurred);
  }
}
Program: 146954
Project: 146954
Buggy source:
/** 
 * @param stream
 * @throws IOException If there was a problem which resulted in the cachedfile being corrupted or unavailable _and_ the input stream becoming invalidated such that a retry is necessary.
 */
private void downloadRemoteData(InputStream stream) throws IOException {
  J2MEDisplay.setView(view);
  Reference ref;
  try {
    ref=ReferenceManager._().DeriveReference(getCacheRef());
    if (ref.isReadOnly()) {
      view.addToMessage(Localization.get("String_Node_Str"));
    }
 else {
      OutputStream output;
      try {
        if (ref.doesBinaryExist()) {
          ref.remove();
        }
        output=ref.getOutputStream();
      }
 catch (      Exception e) {
        noCache(stream);
        return;
      }
      StreamsUtil.writeFromInputToOutput(stream,output);
      view.addToMessage(Localization.get("String_Node_Str"));
      startRestore(ref.getStream());
    }
  }
 catch (  InvalidReferenceException e) {
    noCache(stream);
  }
}

Fixed version (ground truth):
/** 
 * @param stream
 * @throws IOException If there was a problem which resulted in the cachedfile being corrupted or unavailable _and_ the input stream becoming invalidated such that a retry is necessary.
 */
private void downloadRemoteData(InputStream stream) throws IOException {
  J2MEDisplay.setView(view);
  Reference ref;
  try {
    ref=ReferenceManager._().DeriveReference(getCacheRef());
    if (ref.isReadOnly()) {
      view.addToMessage(Localization.get("String_Node_Str"));
    }
 else {
      OutputStream output;
      try {
        if (ref.doesBinaryExist()) {
          ref.remove();
        }
        output=ref.getOutputStream();
      }
 catch (      Exception e) {
        noCache(stream);
        return;
      }
      StreamsUtil.writeFromInputToOutput(stream,output);
      output.close();
      view.addToMessage(Localization.get("String_Node_Str"));
      startRestore(ref.getStream());
    }
  }
 catch (  InvalidReferenceException e) {
    noCache(stream);
  }
}
Program: 146955
Project: 146955
Buggy source:
public void requestConstraintHint(ConstraintHint hint) throws UnpivotableExpressionException {
  hint.init(new EvaluationContext(new EvaluationContext(),mTreeElement.getRef()),mTreeElement.getConstraint().constraint,this.form.getInstance());
}

Fixed version (ground truth):
public void requestConstraintHint(ConstraintHint hint) throws UnpivotableExpressionException {
  Constraint c=mTreeElement.getConstraint();
  if (c != null) {
    hint.init(new EvaluationContext(new EvaluationContext(),mTreeElement.getRef()),c.constraint,this.form.getInstance());
  }
 else {
    throw new UnpivotableExpressionException();
  }
}
Program: 146956
Project: 146956
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  return eval(model,evalContext);
}

Fixed version (ground truth):
/** 
 * Pivot this expression, returning values if appropriate, and adding any pivots to the list. 
 * @param model The model to evaluate the current expression against
 * @param evalContext The evaluation context to evaluate against
 * @param pivots The list of pivot points in the xpath being evaluated. Pivots should be added to this list.
 * @param sentinal The value which is being pivoted around.
 * @return null - If a pivot was identified in this expression sentinal - If the current expression represents the sentinal being pivoted any other value - The result of the expression if no pivots are detected
 * @throws UnpivotableExpressionException If the expression is too complex to pivot
 */
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  return eval(model,evalContext);
}
Program: 146958
Project: 146958
Buggy source:
public void done(boolean errorsOccurred){
  done();
}

Fixed version (ground truth):
public abstract void done();
Program: 146959
Project: 146959
Buggy source:
public CommCareAddUserState(){
  super(PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_NAMESPACE),CommCareContext._().getPreloaders(),CommCareContext._().getFuncHandlers());
}

Fixed version (ground truth):
public CommCareAddUserState(){
  super(PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_NAMESPACE),filterPreloaders(CommCareContext._().getPreloaders()),CommCareContext._().getFuncHandlers());
}
Program: 146960
Project: 146960
Buggy source:
public CommCareEditUserState(User u){
  super(u,PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_NAMESPACE),CommCareContext._().getPreloaders(),CommCareContext._().getFuncHandlers());
}

Fixed version (ground truth):
public CommCareEditUserState(User u){
  super(u,PropertyManager._().getSingularProperty(CommCareProperties.USER_REG_NAMESPACE),CommCareAddUserState.filterPreloaders(CommCareContext._().getPreloaders()),CommCareContext._().getFuncHandlers());
}
Program: 146961
Project: 146961
Buggy source:
/** 
 * This method is generally used to retrieve special forms for a  (select or 1select) item, e.g. "audio", "video", etc.
 * @param sel - The Item whose text you're trying to retrieve.
 * @param form - Special text form of Item you're trying to retrieve. 
 * @return Special Form Text. <code>null</code> if no text for this element exists (with the specified special form).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if <code>sel == null</code>
 */
public String getSpecialFormSelectItemText(Selection sel,String form){
  if (sel == null)   throw new IllegalArgumentException("String_Node_Str");
  String textID=sel.choice.getTextID();
  if (textID == null || textID.equals("String_Node_Str"))   return null;
  String returnText=getIText(textID,form);
  return substituteStringArgs(returnText);
}

Fixed version (ground truth):
/** 
 * This method is generally used to retrieve special forms for a  (select or 1select) item, e.g. "audio", "video", etc.
 * @param sel - The Item whose text you're trying to retrieve.
 * @param form - Special text form of Item you're trying to retrieve. 
 * @return Special Form Text. <code>null</code> if no text for this element exists (with the specified special form).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if <code>sel == null</code>
 */
public String getSpecialFormSelectItemText(Selection sel,String form){
  if (sel == null)   throw new IllegalArgumentException("String_Node_Str");
  if (sel.index == -1) {
    sel.attachChoice(this.getQuestion());
  }
  String textID=sel.choice.getTextID();
  if (textID == null || textID.equals("String_Node_Str"))   return null;
  String returnText=getIText(textID,form);
  return substituteStringArgs(returnText);
}
Program: 146962
Project: 146962
Buggy source:
/** 
 * Attempts to return the specified Item (from a select or 1select) text. Will check for text in the following order:<br/> Localized Text (long form) -> Localized Text (no special form) <br /> If no textID is available, method will return this item's labelInnerText.
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel){
  if (!(getFormElement() instanceof QuestionDef))   throw new RuntimeException("String_Node_Str");
  if (sel == null)   throw new IllegalArgumentException("String_Node_Str");
  String tid=sel.choice.getTextID();
  if (tid == null || tid == "String_Node_Str")   return substituteStringArgs(sel.choice.getLabelInnerText());
  String returnText;
  returnText=getIText(tid,"String_Node_Str");
  if (returnText == null)   returnText=getIText(tid,null);
  return substituteStringArgs(returnText);
}

Fixed version (ground truth):
/** 
 * Attempts to return the specified Item (from a select or 1select) text. Will check for text in the following order:<br/> Localized Text (long form) -> Localized Text (no special form) <br /> If no textID is available, method will return this item's labelInnerText.
 * @param sel the selection (item), if <code>null</code> will throw a IllegalArgumentException
 * @return Question Text.  <code>null</code> if no text for this element exists (after all fallbacks).
 * @throws RunTimeException if this method is called on an element that is NOT a QuestionDef
 * @throws IllegalArgumentException if Selection is <code>null</code>
 */
public String getSelectItemText(Selection sel){
  if (!(getFormElement() instanceof QuestionDef))   throw new RuntimeException("String_Node_Str");
  if (sel == null)   throw new IllegalArgumentException("String_Node_Str");
  if (sel.index == -1) {
    sel.attachChoice(this.getQuestion());
  }
  String tid=sel.choice.getTextID();
  if (tid == null || tid == "String_Node_Str")   return substituteStringArgs(sel.choice.getLabelInnerText());
  String returnText;
  returnText=getIText(tid,"String_Node_Str");
  if (returnText == null)   returnText=getIText(tid,null);
  return substituteStringArgs(returnText);
}
Program: 146963
Project: 146963
Buggy source:
public CommCareOTARestoreState(boolean isSync,HttpAuthenticator authenticator){
  this.isSync=isSync;
  this.authenticator=authenticator;
  this.noPartial=getPartialRestoreSetting();
  controller=getController();
}

Fixed version (ground truth):
public CommCareOTARestoreState(boolean isSync,HttpAuthenticator authenticator){
  this.isSync=isSync;
  this.authenticator=authenticator;
  this.partial=getPartialRestoreSetting();
  controller=getController();
}
Program: 146964
Project: 146964
Buggy source:
protected CommCareOTARestoreController getController(){
  return new CommCareOTARestoreController(this,CommCareContext._().getOTAURL(),authenticator,isSync,noPartial);
}

Fixed version (ground truth):
protected CommCareOTARestoreController getController(){
  return new CommCareOTARestoreController(this,CommCareContext._().getOTAURL(),authenticator,isSync,!partial);
}