nus-yam/ex-repair huggingface dataset:
Program: 144964
Project: 144964
Buggy source:
protected JrFormEntryController getController(){
  FormDefFetcher fetcher=new FormDefFetcher(new NamespaceRetrievalMethod(formName),preloaders,funcHandlers,iif);
  JrFormEntryController controller=CommCareUtil.createFormEntryController(fetcher);
  controller.setView(loadView(title,controller));
  return controller;
}

Fixed version (ground truth):
protected JrFormEntryController getController(){
  FormDefFetcher fetcher=new FormDefFetcher(new NamespaceRetrievalMethod(formName),preloaders,funcHandlers,iif);
  boolean supportsNewRepeats=false;
  String viewType=PropertyManager._().getSingularProperty(FormManagerProperties.VIEW_TYPE_PROPERTY);
  if (FormManagerProperties.VIEW_CHATTERBOX.equals(viewType)) {
    supportsNewRepeats=true;
  }
  JrFormEntryController controller=CommCareUtil.createFormEntryController(fetcher,supportsNewRepeats);
  controller.setView(loadView(title,controller));
  return controller;
}
Program: 144965
Project: 144965
Buggy source:
public int indexOfKey(Object key){
  return orderedKeys.indexOf(key);
}

Fixed version (ground truth):
public int indexOfKey(K key){
  return orderedKeys.indexOf(key);
}
Program: 144966
Project: 144966
Buggy source:
public OrderedHashtable(int initialCapacity){
  super(initialCapacity);
  orderedKeys=new Vector(initialCapacity);
}

Fixed version (ground truth):
public OrderedHashtable(int initialCapacity){
  super(initialCapacity);
  orderedKeys=new Vector<K>(initialCapacity);
}
Program: 144967
Project: 144967
Buggy source:
public Object put(Object key,Object value){
  if (key == null) {
    throw new NullPointerException();
  }
  int i=orderedKeys.indexOf(key);
  if (i == -1) {
    orderedKeys.addElement(key);
  }
 else {
    orderedKeys.setElementAt(key,i);
  }
  return super.put(key,value);
}

Fixed version (ground truth):
public V put(K key,V value){
  if (key == null) {
    throw new NullPointerException();
  }
  int i=orderedKeys.indexOf(key);
  if (i == -1) {
    orderedKeys.addElement(key);
  }
 else {
    orderedKeys.setElementAt(key,i);
  }
  return super.put(key,value);
}
Program: 144968
Project: 144968
Buggy source:
public Object remove(Object key){
  orderedKeys.removeElement(key);
  return super.remove(key);
}

Fixed version (ground truth):
public V remove(Object key){
  orderedKeys.removeElement((K)key);
  return super.remove(key);
}
Program: 144970
Project: 144970
Buggy source:
/** 
 * convert a value to a number using xpath's type conversion rules (note that xpath itself makes no distinction between integer and floating point numbers)
 * @param o
 * @return
 */
public static Double toNumeric(Object o){
  Double val=null;
  o=unpack(o);
  if (o instanceof Boolean) {
    val=new Double(((Boolean)o).booleanValue() ? 1 : 0);
  }
 else   if (o instanceof Double) {
    val=(Double)o;
  }
 else   if (o instanceof String) {
    String s=(String)o;
    double d;
    try {
      s=s.trim();
      for (int i=0; i < s.length(); i++) {
        char c=s.charAt(i);
        if (c != '-' && c != '.' && (c < '0' || c > '9'))         throw new NumberFormatException();
      }
      d=Double.parseDouble(s);
      val=new Double(d);
    }
 catch (    NumberFormatException nfe) {
      val=new Double(Double.NaN);
    }
  }
 else   if (o instanceof Date) {
    val=new Double(DateUtils.daysSinceEpoch((Date)o));
  }
 else   if (o instanceof IExprDataType) {
    val=((IExprDataType)o).toNumeric();
  }
  if (val != null) {
    return val;
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str");
  }
}

Fixed version (ground truth):
/** 
 * convert a value to a number using xpath's type conversion rules (note that xpath itself makes no distinction between integer and floating point numbers)
 * @param o
 * @return
 */
public static Double toNumeric(Object o){
  Double val=null;
  o=unpack(o);
  if (o instanceof Boolean) {
    val=new Double(((Boolean)o).booleanValue() ? 1 : 0);
  }
 else   if (o instanceof Double) {
    val=(Double)o;
  }
 else   if (o instanceof String) {
    String s=(String)o;
    double d;
    try {
      s=s.trim();
      for (int i=0; i < s.length(); i++) {
        char c=s.charAt(i);
        if (c != '-' && c != '.' && (c < '0' || c > '9'))         throw new NumberFormatException();
      }
      d=Double.parseDouble(s);
      val=new Double(d);
    }
 catch (    NumberFormatException nfe) {
      val=new Double(Double.NaN);
    }
  }
 else   if (o instanceof Date) {
    val=new Double(DateUtils.daysSinceEpoch((Date)o));
  }
 else   if (o instanceof IExprDataType) {
    val=((IExprDataType)o).toNumeric();
  }
  if (val != null) {
    return val;
  }
 else {
    throw new XPathTypeMismatchException("String_Node_Str" + (o == null ? "String_Node_Str" : o.toString()) + "String_Node_Str");
  }
}
Program: 144971
Project: 144971
Buggy source:
public XPathNodeset eval(DataInstance m,EvaluationContext ec){
  TreeReference genericRef=getReference();
  TreeReference ref=genericRef.contextualize(ec.getContextRef());
  if (ref.getInstanceName() != null && ref.isAbsolute()) {
    DataInstance nonMain=ec.getInstance(ref.getInstanceName());
    if (nonMain != null) {
      m=nonMain;
    }
 else {
      throw new XPathTypeMismatchException("String_Node_Str" + ref.toString(true) + "String_Node_Str");
    }
  }
  if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
    throw new XPathTypeMismatchException("String_Node_Str" + genericRef.toString() + "String_Node_Str");
  }
  Vector<TreeReference> nodesetRefs=ec.expandReference(ref);
  for (int i=0; i < nodesetRefs.size(); i++) {
    if (!m.resolveReference((TreeReference)nodesetRefs.elementAt(i)).isRelevant()) {
      nodesetRefs.removeElementAt(i);
      i--;
    }
  }
  return new XPathNodeset(nodesetRefs,m,ec);
}

Fixed version (ground truth):
public XPathNodeset eval(DataInstance m,EvaluationContext ec){
  TreeReference genericRef=getReference();
  TreeReference ref=genericRef.contextualize(ec.getContextRef());
  if (ref.getInstanceName() != null && ref.isAbsolute()) {
    DataInstance nonMain=ec.getInstance(ref.getInstanceName());
    if (nonMain != null) {
      m=nonMain;
    }
 else {
      throw new XPathTypeMismatchException("String_Node_Str" + ref.toString(true) + "String_Node_Str");
    }
  }
 else {
    m=ec.getMainInstance();
  }
  if (ref.isAbsolute() && m.getTemplatePath(ref) == null) {
    throw new XPathTypeMismatchException("String_Node_Str" + genericRef.toString() + "String_Node_Str");
  }
  Vector<TreeReference> nodesetRefs=ec.expandReference(ref);
  for (int i=0; i < nodesetRefs.size(); i++) {
    if (!m.resolveReference((TreeReference)nodesetRefs.elementAt(i)).isRelevant()) {
      nodesetRefs.removeElementAt(i);
      i--;
    }
  }
  return new XPathNodeset(nodesetRefs,m,ec);
}
Program: 144974
Project: 144974
Buggy source:
public Object getValue(){
  return new Integer(n);
}

Fixed version (ground truth):
public Object getValue(){
  return DataUtil.integer(n);
}
Program: 144975
Project: 144975
Buggy source:
public UncastData uncast(){
  return new UncastData(new Integer(n).toString());
}

Fixed version (ground truth):
public UncastData uncast(){
  return new UncastData(DataUtil.integer(n).toString());
}
Program: 144976
Project: 144976
Buggy source:
public Vector<XPathExpression> getPredicate(int key){
  return predicates.get(new Integer(key));
}

Fixed version (ground truth):
public Vector<XPathExpression> getPredicate(int key){
  return predicates.get(DataUtil.integer(key));
}
Program: 144977
Project: 144977
Buggy source:
public int hashCode(){
  int hash=(new Integer(refLevel)).hashCode();
  for (int i=0; i < size(); i++) {
    Integer mult=new Integer(getMultiplicity(i));
    if (i == 0 && mult.intValue() == INDEX_UNBOUND)     mult=new Integer(0);
    hash^=getName(i).hashCode();
    hash^=mult.hashCode();
  }
  return hash;
}

Fixed version (ground truth):
public int hashCode(){
  int hash=(new Integer(refLevel)).hashCode();
  for (int i=0; i < size(); i++) {
    Integer mult=DataUtil.integer(getMultiplicity(i));
    if (i == 0 && mult.intValue() == INDEX_UNBOUND)     mult=DataUtil.integer(0);
    hash^=getName(i).hashCode();
    hash^=mult.hashCode();
  }
  return hash;
}
Program: 144978
Project: 144978
Buggy source:
public void add(String name,int index){
  names.addElement(name);
  multiplicity.addElement(new Integer(index));
}

Fixed version (ground truth):
public void add(String name,int index){
  names.addElement(name);
  multiplicity.addElement(DataUtil.integer(index));
}
Program: 144979
Project: 144979
Buggy source:
public TreeReference(){
  names=new Vector(0);
  multiplicity=new Vector(0);
  predicates=new Hashtable<Integer,Vector<XPathExpression>>();
  instanceName=null;
}

Fixed version (ground truth):
public TreeReference(){
  names=new Vector(0);
  multiplicity=new Vector(0);
  predicates=new Hashtable<Integer,Vector<XPathExpression>>(0);
  instanceName=null;
}
Program: 144980
Project: 144980
Buggy source:
public void setMultiplicity(int i,int mult){
  multiplicity.setElementAt(new Integer(mult),i);
}

Fixed version (ground truth):
public void setMultiplicity(int i,int mult){
  multiplicity.setElementAt(DataUtil.integer(mult),i);
}
Program: 144981
Project: 144981
Buggy source:
public void addPredicate(int key,Vector<XPathExpression> xpe){
  predicates.put(new Integer(key),xpe);
}

Fixed version (ground truth):
public void addPredicate(int key,Vector<XPathExpression> xpe){
  predicates.put(DataUtil.integer(key),xpe);
}
Program: 144983
Project: 144983
Buggy source:
private static void loadInstanceData(Element node,TreeElement cur,FormDef f){
  int numChildren=node.getChildCount();
  boolean hasElements=false;
  for (int i=0; i < numChildren; i++) {
    if (node.getType(i) == Node.ELEMENT) {
      hasElements=true;
      break;
    }
  }
  if (hasElements) {
    Hashtable<String,Integer> multiplicities=new Hashtable<String,Integer>();
    for (int i=0; i < numChildren; i++) {
      if (node.getType(i) == Node.ELEMENT) {
        Element child=node.getElement(i);
        String name=child.getName();
        int index;
        boolean isTemplate=(child.getAttributeValue(NAMESPACE_JAVAROSA,"String_Node_Str") != null);
        if (isTemplate) {
          index=TreeReference.INDEX_TEMPLATE;
        }
 else {
          Integer mult=multiplicities.get(name);
          index=(mult == null ? 0 : mult.intValue() + 1);
          multiplicities.put(name,new Integer(index));
        }
        loadInstanceData(child,cur.getChild(name,index),f);
      }
    }
  }
 else {
    String text=getXMLText(node,false);
    if (text != null && text.trim().length() > 0) {
      cur.setValue(XFormAnswerDataParser.getAnswerData(text,cur.getDataType(),ghettoGetQuestionDef(cur.getDataType(),f,cur.getRef())));
    }
  }
}

Fixed version (ground truth):
private static void loadInstanceData(Element node,TreeElement cur,FormDef f){
  int numChildren=node.getChildCount();
  boolean hasElements=false;
  for (int i=0; i < numChildren; i++) {
    if (node.getType(i) == Node.ELEMENT) {
      hasElements=true;
      break;
    }
  }
  if (hasElements) {
    Hashtable<String,Integer> multiplicities=new Hashtable<String,Integer>();
    for (int i=0; i < numChildren; i++) {
      if (node.getType(i) == Node.ELEMENT) {
        Element child=node.getElement(i);
        String name=child.getName();
        int index;
        boolean isTemplate=(child.getAttributeValue(NAMESPACE_JAVAROSA,"String_Node_Str") != null);
        if (isTemplate) {
          index=TreeReference.INDEX_TEMPLATE;
        }
 else {
          Integer mult=multiplicities.get(name);
          index=(mult == null ? 0 : mult.intValue() + 1);
          multiplicities.put(name,DataUtil.integer(index));
        }
        loadInstanceData(child,cur.getChild(name,index),f);
      }
    }
  }
 else {
    String text=getXMLText(node,false);
    if (text != null && text.trim().length() > 0) {
      cur.setValue(XFormAnswerDataParser.getAnswerData(text,cur.getDataType(),ghettoGetQuestionDef(cur.getDataType(),f,cur.getRef())));
    }
  }
}
Program: 144984
Project: 144984
Buggy source:
public static void addDataType(String type,int dataType){
  typeMappings.put(type,new Integer(dataType));
}

Fixed version (ground truth):
public static void addDataType(String type,int dataType){
  typeMappings.put(type,DataUtil.integer(dataType));
}
Program: 144985
Project: 144985
Buggy source:
/** 
 * Any messages which aren't successfully sent in SendingThreads are then "Cached". Applications can activate new attempts to send the CachedMessages via this sendCached method
 */
public static void sendCached(TransportListener listener) throws TransportException {
  if (SENDER == null) {
    SENDER=new TransporterSharingSender();
  }
synchronized (SENDER) {
    Vector messages=getCachedMessages();
    Logger.log("String_Node_Str","String_Node_Str" + messages.size() + "String_Node_Str");
    if (messages.size() > 0) {
      SENDER.init(messages,CACHE(),listener);
      SENDER.send();
    }
  }
}

Fixed version (ground truth):
/** 
 * Any messages which aren't successfully sent in SendingThreads are then "Cached". Applications can activate new attempts to send the CachedMessages via this sendCached method
 */
public static void sendCached(TransportListener listener) throws TransportException {
  if (SENDER == null) {
    SENDER=new TransporterSharingSender();
  }
synchronized (SENDER) {
    Vector messages=getCachedMessages();
    Logger.log("String_Node_Str","String_Node_Str" + messages.size() + "String_Node_Str");
    if (messages.size() > 0) {
      try {
        SENDER.init(messages,CACHE(),listener);
        SENDER.send();
      }
  finally {
        SENDER.uninit();
      }
    }
  }
}
Program: 144986
Project: 144986
Buggy source:
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    return (Triggerable)triggerables.elementAt(existingIx);
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger,new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}

Fixed version (ground truth):
/** 
 * Add a Condition to the form's Collection.
 * @param condition the condition to be set
 */
public Triggerable addTriggerable(Triggerable t){
  int existingIx=triggerables.indexOf(t);
  if (existingIx >= 0) {
    Triggerable existingTriggerable=(Triggerable)triggerables.elementAt(existingIx);
    existingTriggerable.contextRef=existingTriggerable.contextRef.intersect(t.contextRef);
    return existingTriggerable;
  }
 else {
    triggerables.addElement(t);
    triggerablesInOrder=false;
    Vector triggers=t.getTriggers();
    for (int i=0; i < triggers.size(); i++) {
      TreeReference trigger=(TreeReference)triggers.elementAt(i);
      if (!triggerIndex.containsKey(trigger)) {
        triggerIndex.put(trigger,new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}
Program: 144988
Project: 144988
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: 144989
Project: 144989
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: 144990
Project: 144990
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: 144991
Project: 144991
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: 144992
Project: 144992
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: 144993
Project: 144993
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: 144994
Project: 144994
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: 144996
Project: 144996
Buggy source:
protected void setMessage(String message){
  interaction.setMessage(message);
}

Fixed version (ground truth):
protected void setMessage(String message){
  interaction.setMessage(message,true);
}
Program: 144997
Project: 144997
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: 144998
Project: 144998
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: 144999
Project: 144999
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: 145000
Project: 145000
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: 145001
Project: 145001
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: 145002
Project: 145002
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: 145006
Project: 145006
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: 145007
Project: 145007
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: 145008
Project: 145008
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: 145009
Project: 145009
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: 145011
Project: 145011
Buggy source:
public ResourceParser(KXmlParser parser){
  super(parser);
}

Fixed version (ground truth):
public ResourceParser(KXmlParser parser,int maximumAuthority){
  super(parser);
  this.maximumAuthority=maximumAuthority;
}
Program: 145012
Project: 145012
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: 145014
Project: 145014
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: 145015
Project: 145015
Buggy source:
public JRDemoFormListController(){
  formInfo=JRDemoUtil.getFormList();
  Vector formNames=new Vector();
  for (Enumeration e=formInfo.elements(); e.hasMoreElements(); )   formNames.addElement(e.nextElement());
  view=new JRDemoFormListView(Localization.get("String_Node_Str"),formNames,JRDemoContext._().getUser().isAdminUser());
  view.setCommandListener(this);
}

Fixed version (ground truth):
public JRDemoFormListController(){
  formInfo=JRDemoUtil.getFormList();
  Vector formNames=new Vector();
  for (Enumeration e=formInfo.elements(); e.hasMoreElements(); ) {
    formNames.addElement(e.nextElement());
  }
  view=new JRDemoFormListView(Localization.get("String_Node_Str"),formNames,JRDemoContext._().getUser().isAdminUser());
  view.setCommandListener(this);
}
Program: 145016
Project: 145016
Buggy source:
public void init(MIDlet m){
  DumpRMS.RMSRecoveryHook(m);
  loadModules();
  setMidlet(m);
  addCustomLanguages();
  setProperties();
  UserUtility.populateAdminUser(m);
  loadRootTranslator();
  try {
    StorageManager.getStorage(FormDef.STORAGE_KEY).write(XFormUtils.getFormFromResource("String_Node_Str"));
  }
 catch (  StorageFullException e) {
    e.printStackTrace();
  }
}

Fixed version (ground truth):
public void init(MIDlet m){
  DumpRMS.RMSRecoveryHook(m);
  loadModules();
  setMidlet(m);
  addCustomLanguages();
  setProperties();
  UserUtility.populateAdminUser(m);
  loadRootTranslator();
}
Program: 145018
Project: 145018
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: 145020
Project: 145020
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: 145022
Project: 145022
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: 145024
Project: 145024
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);
  }
}