nus-yam/ex-repair huggingface dataset:
Program: 145079
Project: 145079
Buggy source:
public void questionAnswered(){
  ChatterboxWidget frame=activeFrame();
  if (activeQuestionIndex != this.model.getFormIndex()) {
    System.out.println("String_Node_Str");
    return;
  }
  if (activeIsInterstitial) {
    String answer=((Selection)frame.getData().getValue()).getValue();
    if (answer.equals("String_Node_Str")) {
      controller.newRepeat(this.model.getFormIndex());
      createHeaderForElement(this.model.getFormIndex());
    }
    step(controller.stepToNextEvent());
  }
 else {
    int status=controller.answerQuestion(this.model.getFormIndex(),frame.getData());
    if (status == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {
      this.queueError(null,PROMPT_REQUIRED_QUESTION);
    }
 else     if (status == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
      String msg=frame.getPrompt().getConstraintText();
      this.queueError(null,msg != null ? msg : PROMPT_DEFAULT_CONSTRAINT_VIOL);
    }
 else {
      step(controller.stepToNextEvent());
    }
  }
}

Fixed version (ground truth):
public void questionAnswered(){
  ChatterboxWidget frame=activeFrame();
  if (activeQuestionIndex != this.model.getFormIndex()) {
    System.out.println("String_Node_Str");
    return;
  }
  if (activeIsInterstitial) {
    String answer=((Selection)frame.getData().getValue()).getValue();
    if (answer.equals("String_Node_Str")) {
      controller.newRepeat(this.model.getFormIndex());
      createHeaderForElement(this.model.getFormIndex(),true);
    }
    step(controller.stepToNextEvent());
  }
 else {
    int status=controller.answerQuestion(this.model.getFormIndex(),frame.getData());
    if (status == FormEntryController.ANSWER_REQUIRED_BUT_EMPTY) {
      this.queueError(null,PROMPT_REQUIRED_QUESTION);
    }
 else     if (status == FormEntryController.ANSWER_CONSTRAINT_VIOLATED) {
      String msg=frame.getPrompt().getConstraintText();
      this.queueError(null,msg != null ? msg : PROMPT_DEFAULT_CONSTRAINT_VIOL);
    }
 else {
      step(controller.stepToNextEvent());
    }
  }
}
Program: 145081
Project: 145081
Buggy source:
/** 
 * Attempts to save the answer at the specified FormIndex into the datamodel.
 * @param index
 * @param data
 * @return OK if save was successful, error if a constraint was violated.
 */
public int answerQuestion(FormIndex index,IAnswerData data){
  QuestionDef q=model.getQuestionPrompt(index).getQuestion();
  if (model.getEvent() != FormEntryController.EVENT_QUESTION) {
    throw new RuntimeException("String_Node_Str");
  }
  TreeElement element=model.getTreeElement(index);
  boolean complexQuestion=q.isComplex();
  boolean hasConstraints=false;
  if (element.required && data == null) {
    return ANSWER_REQUIRED_BUT_EMPTY;
  }
 else   if (!complexQuestion && !model.getForm().evaluateConstraint(index.getReference(),data)) {
    return ANSWER_CONSTRAINT_VIOLATED;
  }
 else   if (!complexQuestion) {
    commitAnswer(element,index,data);
    return ANSWER_OK;
  }
 else   if (complexQuestion && hasConstraints) {
    throw new RuntimeException("String_Node_Str");
  }
 else {
    try {
      model.getForm().copyItemsetAnswer(q,element,data);
    }
 catch (    InvalidReferenceException ire) {
      ire.printStackTrace();
      throw new RuntimeException("String_Node_Str" + ire.getMessage());
    }
    return ANSWER_OK;
  }
}

Fixed version (ground truth):
/** 
 * Attempts to save the answer at the specified FormIndex into the datamodel.
 * @param index
 * @param data
 * @return OK if save was successful, error if a constraint was violated.
 */
public int answerQuestion(FormIndex index,IAnswerData data){
  QuestionDef q=model.getQuestionPrompt(index).getQuestion();
  if (model.getEvent(index) != FormEntryController.EVENT_QUESTION) {
    throw new RuntimeException("String_Node_Str");
  }
  TreeElement element=model.getTreeElement(index);
  boolean complexQuestion=q.isComplex();
  boolean hasConstraints=false;
  if (element.required && data == null) {
    return ANSWER_REQUIRED_BUT_EMPTY;
  }
 else   if (!complexQuestion && !model.getForm().evaluateConstraint(index.getReference(),data)) {
    return ANSWER_CONSTRAINT_VIOLATED;
  }
 else   if (!complexQuestion) {
    commitAnswer(element,index,data);
    return ANSWER_OK;
  }
 else   if (complexQuestion && hasConstraints) {
    throw new RuntimeException("String_Node_Str");
  }
 else {
    try {
      model.getForm().copyItemsetAnswer(q,element,data);
    }
 catch (    InvalidReferenceException ire) {
      ire.printStackTrace();
      throw new RuntimeException("String_Node_Str" + ire.getMessage());
    }
    return ANSWER_OK;
  }
}
Program: 145082
Project: 145082
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 (!(getFormElement() instanceof QuestionDef))   throw new RuntimeException("String_Node_Str");
  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");
  String textID=sel.choice.getTextID();
  if (textID == null || textID.equals("String_Node_Str"))   return null;
  String returnText=getIText(textID,form);
  return substituteStringArgs(returnText);
}
Program: 145083
Project: 145083
Buggy source:
private void createHeaderForElement(FormIndex questionIndex){
  FormEntryCaption prompt=model.getCaptionPrompt(questionIndex);
  String headerText;
  headerText=prompt.getLongText();
  if (headerText.equals(null)) {
    headerText=prompt.getShortText();
  }
  if (headerText != null) {
    ChatterboxWidget headerWidget=widgetFactory.getNewLabelWidget(questionIndex,headerText);
    this.append(headerWidget);
    this.questionIndexes.add(questionIndex);
    headerWidget.setPinned(true);
  }
}

Fixed version (ground truth):
private void createHeaderForElement(FormIndex questionIndex){
  FormEntryCaption prompt=model.getCaptionPrompt(questionIndex);
  String headerText;
  headerText=prompt.getLongText();
  if (headerText == null) {
    headerText=prompt.getShortText();
  }
  if (headerText != null) {
    ChatterboxWidget headerWidget=widgetFactory.getNewLabelWidget(questionIndex,headerText);
    this.append(headerWidget);
    this.questionIndexes.add(questionIndex);
    headerWidget.setPinned(true);
  }
}
Program: 145084
Project: 145084
Buggy source:
protected void updateWidget(FormEntryPrompt prompt){
  for (int i=0; i < choiceGroup().size(); i++) {
    SelectChoice sc=prompt.getSelectChoices().elementAt(i);
    Selection s=sc.selection();
    Image im=this.getImage(prompt.getSpecialFormSelectChoiceText(sc,FormEntryCaption.TEXT_FORM_IMAGE));
    choiceGroup().getItem(i).setText(prompt.getSelectChoiceText(sc));
    if (im != null) {
      choiceGroup().getItem(i).setImage(im);
    }
  }
}

Fixed version (ground truth):
protected void updateWidget(FormEntryPrompt prompt){
  for (int i=0; i < choiceGroup().size(); i++) {
    SelectChoice sc=prompt.getSelectChoices().elementAt(i);
    Image im=this.getImage(prompt.getSpecialFormSelectChoiceText(sc,FormEntryCaption.TEXT_FORM_IMAGE));
    choiceGroup().getItem(i).setText(prompt.getSelectChoiceText(sc));
    if (im != null) {
      choiceGroup().getItem(i).setImage(im);
    }
  }
}
Program: 145085
Project: 145085
Buggy source:
public void visit(FormInstance tree){
  theXmlDoc=new Document();
  TreeElement root=tree.resolveReference(rootRef);
  for (int i=0; i < root.getNumChildren(); i++) {
    TreeElement childAt=root.getChildAt(i);
  }
  if (root != null) {
    theXmlDoc.addChild(Node.ELEMENT,serializeNode(root));
  }
  Element top=theXmlDoc.getElement(0);
  String[] prefixes=tree.getNamespacePrefixes();
  for (int i=0; i < prefixes.length; ++i) {
    top.setPrefix(prefixes[i],tree.getNamespaceURI(prefixes[i]));
  }
  if (tree.schema != null) {
    top.setNamespace(tree.schema);
    top.setPrefix("String_Node_Str",tree.schema);
  }
}

Fixed version (ground truth):
public void visit(FormInstance tree){
  theXmlDoc=new Document();
  TreeElement root=tree.resolveReference(rootRef);
  if (root == null) {
    root=tree.getRoot();
  }
  for (int i=0; i < root.getNumChildren(); i++) {
    TreeElement childAt=root.getChildAt(i);
  }
  if (root != null) {
    theXmlDoc.addChild(Node.ELEMENT,serializeNode(root));
  }
  Element top=theXmlDoc.getElement(0);
  String[] prefixes=tree.getNamespacePrefixes();
  for (int i=0; i < prefixes.length; ++i) {
    top.setPrefix(prefixes[i],tree.getNamespaceURI(prefixes[i]));
  }
  if (tree.schema != null) {
    top.setNamespace(tree.schema);
    top.setPrefix("String_Node_Str",tree.schema);
  }
}
Program: 145086
Project: 145086
Buggy source:
public TransportMessage buildMessage(FormInstance tree,SubmissionProfile profile){
  if (profile == null) {
    try {
      IDataPayload payload=new XFormSerializingVisitor().createSerializedPayload(tree);
      return new SimpleHttpTransportMessage(payload.getPayloadStream(),PropertyManager._().getSingularProperty(DemoAppProperties.POST_URL_PROPERTY));
    }
 catch (    IOException e) {
      e.printStackTrace();
      throw new RuntimeException("String_Node_Str");
    }
  }
  if (profile.getMethod().toLowerCase().equals("String_Node_Str")) {
    String url=profile.getAction();
    try {
      IDataPayload payload=new XFormSerializingVisitor().createSerializedPayload(tree,profile.getRef());
      return new SimpleHttpTransportMessage(payload.getPayloadStream(),url);
    }
 catch (    IOException e) {
      e.printStackTrace();
      throw new RuntimeException("String_Node_Str");
    }
  }
 else   if (profile.getMethod().toLowerCase().equals("String_Node_Str")) {
    String phoneUri=profile.getAction();
    try {
      String payload=new String(new SMSSerializingVisitor().serializeInstance(tree,profile.getRef()));
      return new SMSTransportMessage(payload,phoneUri);
    }
 catch (    IOException e) {
      e.printStackTrace();
      throw new RuntimeException("String_Node_Str");
    }
  }
  return null;
}

Fixed version (ground truth):
public TransportMessage buildMessage(FormInstance tree,SubmissionProfile profile){
  if (profile == null) {
    profile=SubmissionTransportHelper.defaultPostSubmission(PropertyManager._().getSingularProperty(DemoAppProperties.POST_URL_PROPERTY));
  }
  return SubmissionTransportHelper.createMessage(tree,profile);
}
Program: 145087
Project: 145087
Buggy source:
public void start(){
  J2MEDisplay.setView(view);
}

Fixed version (ground truth):
public void start(){
  view=new CommCareSuiteView(m.getName().evaluate());
  view.setCommandListener(this);
  configView();
  J2MEDisplay.setView(view);
}
Program: 145088
Project: 145088
Buggy source:
public Text parse() throws InvalidStructureException, IOException, XmlPullParserException {
  Vector<Text> texts=new Vector<Text>();
  checkNode("String_Node_Str");
  int entryLevel=parser.getDepth();
  try {
    parser.next();
  }
 catch (  XmlPullParserException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  while (parser.getDepth() > entryLevel) {
    Text t=parseBody();
    if (t != null) {
      texts.addElement(t);
    }
  }
  if (texts.size() == 1) {
    return texts.elementAt(0);
  }
 else {
    Text c=Text.CompositeText(texts);
    return c;
  }
}

Fixed version (ground truth):
public Text parse() throws InvalidStructureException, IOException, XmlPullParserException {
  Vector<Text> texts=new Vector<Text>();
  checkNode("String_Node_Str");
  int entryLevel=parser.getDepth();
  try {
    parser.next();
  }
 catch (  XmlPullParserException e) {
    e.printStackTrace();
  }
catch (  IOException e) {
    e.printStackTrace();
  }
  while (parser.getDepth() > entryLevel || parser.getEventType() == KXmlParser.TEXT) {
    Text t=parseBody();
    if (t != null) {
      texts.addElement(t);
    }
  }
  if (texts.size() == 1) {
    return texts.elementAt(0);
  }
 else {
    Text c=Text.CompositeText(texts);
    return c;
  }
}
Program: 145089
Project: 145089
Buggy source:
public CommCareConfigEngine(OutputStream output){
  this.output=output;
  this.print=new PrintStream(output);
  suites=new Vector<Suite>();
  this.instance=new CommCareInstance(){
    public void registerSuite(    Suite s){
      CommCareConfigEngine.this.suites.add(s);
    }
    public void setProfile(    Profile p){
      CommCareConfigEngine.this.profile=p;
    }
    public int getMajorVersion(){
      return 1;
    }
    public int getMinorVersion(){
      return 1;
    }
  }
;
  setRoots();
  table=ResourceTable.RetrieveTable(new DummyIndexedStorageUtility());
  StorageManager.setStorageFactory(new IStorageFactory(){
    public IStorageUtility newStorage(    String name,    Class type){
      return new DummyIndexedStorageUtility();
    }
  }
);
  StorageManager.registerStorage(Profile.STORAGE_KEY,Profile.class);
  StorageManager.registerStorage(Suite.STORAGE_KEY,Suite.class);
  StorageManager.registerStorage(FormDef.STORAGE_KEY,Suite.class);
}

Fixed version (ground truth):
public CommCareConfigEngine(OutputStream output){
  this.output=output;
  this.print=new PrintStream(output);
  suites=new Vector<Suite>();
  this.instance=new CommCareInstance(){
    public void registerSuite(    Suite s){
      CommCareConfigEngine.this.suites.add(s);
    }
    public void setProfile(    Profile p){
      CommCareConfigEngine.this.profile=p;
    }
    public int getMajorVersion(){
      return 1;
    }
    public int getMinorVersion(){
      return 1;
    }
    public int getMajorVersion(){
      return 1;
    }
    public int getMinorVersion(){
      return 0;
    }
  }
;
  setRoots();
  table=ResourceTable.RetrieveTable(new DummyIndexedStorageUtility());
  StorageManager.setStorageFactory(new IStorageFactory(){
    public IStorageUtility newStorage(    String name,    Class type){
      return new DummyIndexedStorageUtility();
    }
  }
);
  StorageManager.registerStorage(Profile.STORAGE_KEY,Profile.class);
  StorageManager.registerStorage(Suite.STORAGE_KEY,Suite.class);
  StorageManager.registerStorage(FormDef.STORAGE_KEY,Suite.class);
}
Program: 145090
Project: 145090
Buggy source:
public int getMinorVersion(){
  return 1;
}

Fixed version (ground truth):
public int getMinorVersion(){
  return 0;
}
Program: 145091
Project: 145091
Buggy source:
/** 
 * @param args
 */
public static void main(String[] args){
  if (args.length < 1) {
    printformat();
    System.exit(-1);
  }
  if (args[0].equals("String_Node_Str")) {
    if (args.length < 2) {
      printvalidateformat();
      System.exit(-1);
    }
    CommCareConfigEngine engine=new CommCareConfigEngine(System.out);
    engine.addLocalFileResource(args[1]);
    engine.resolveTable();
    engine.validateResources();
    engine.describeApplication();
    System.exit(0);
  }
}

Fixed version (ground truth):
/** 
 * @param args
 */
public static void main(String[] args){
  if (args.length < 1) {
    printformat();
    System.exit(-1);
  }
  if (args[0].equals("String_Node_Str")) {
    if (args.length < 2) {
      printvalidateformat();
      System.exit(-1);
    }
    CommCareConfigEngine engine=new CommCareConfigEngine(System.out);
    engine.addLocalFileResource(args[1]);
    if (args.length > 2) {
      if (args[2].equals("String_Node_Str")) {
      }
 else {
        engine.addJarResources(args[2]);
      }
    }
 else {
      engine.addJarResources("String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str");
      engine.addJarResources("String_Node_Str" + File.separator + "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str"+ File.separator+ "String_Node_Str");
    }
    engine.resolveTable();
    engine.validateResources();
    engine.describeApplication();
    System.exit(0);
  }
}
Program: 145092
Project: 145092
Buggy source:
public JavaFileReference(String localPart,String uri){
  this.localPart=localPart;
  this.uri=uri;
}

Fixed version (ground truth):
public JavaFileReference(String localPart,String uri,String authority){
  this.localPart=localPart;
  this.uri=uri;
  this.authority=authority;
}
Program: 145093
Project: 145093
Buggy source:
public String getURI(){
  return "String_Node_Str" + uri;
}

Fixed version (ground truth):
public String getURI(){
  return "String_Node_Str" + authority + "String_Node_Str"+ uri;
}
Program: 145094
Project: 145094
Buggy source:
protected Reference factory(String terminal,String URI){
  return new JavaFileReference(localRoot,terminal);
}

Fixed version (ground truth):
protected Reference factory(String terminal,String URI){
  if (authority != null) {
    return new JavaFileReference(localRoot,terminal,authority);
  }
 else {
    return new JavaFileReference(localRoot,terminal);
  }
}
Program: 145095
Project: 145095
Buggy source:
public JavaFileRoot(String localRoot){
  super(new String[]{"String_Node_Str"});
  this.localRoot=localRoot;
}

Fixed version (ground truth):
public JavaFileRoot(String[] uriRoots,String localRoot){
  super(uriRoots);
  if (uriRoots.length == 1) {
    authority=uriRoots[0];
  }
  this.localRoot=localRoot;
}
Program: 145096
Project: 145096
Buggy source:
/** 
 * Convenience method Get longText form of text for THIS element (if available)  !!Falls back to default form if 'long' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.
 * @return longText form 
 */
public String getLongText(){
  String returnText=getSpecialFormQuestionText(getTextID(),TEXT_FORM_LONG);
  if (returnText == null)   returnText=getQuestionText(getTextID());
  return returnText;
}

Fixed version (ground truth):
/** 
 * Convenience method Get longText form of text for THIS element (if available)  !!Falls back to default form if 'long' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.
 * @return longText form 
 */
public String getLongText(){
  return getQuestionText(getTextID());
}
Program: 145097
Project: 145097
Buggy source:
/** 
 * Same as getSpecialFormQuestionText(String textID,String form) except that the textID defaults to the textID of the current element.
 * @param form - special text form of textID you're trying to retrieve. 
 * @return Special Form Question 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
 */
public String getSpecialFormQuestionText(String form){
  if (!(getFormElement() instanceof QuestionDef))   throw new RuntimeException("String_Node_Str");
  return getSpecialFormQuestionText(getTextID(),form);
}

Fixed version (ground truth):
/** 
 * Same as getSpecialFormQuestionText(String textID,String form) except that the textID defaults to the textID of the current element.
 * @param form - special text form of textID you're trying to retrieve. 
 * @return Special Form Question 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
 */
public String getSpecialFormQuestionText(String form){
  return getSpecialFormQuestionText(getTextID(),form);
}
Program: 145098
Project: 145098
Buggy source:
/** 
 * Convenience method Get shortText form of text for THIS element (if available)  !!Falls back to default form if 'short' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.
 * @return shortText form 
 */
public String getShortText(){
  String returnText=getSpecialFormQuestionText(getTextID(),TEXT_FORM_SHORT);
  if (returnText == null)   returnText=getQuestionText(getTextID());
  return returnText;
}

Fixed version (ground truth):
/** 
 * Convenience method Get shortText form of text for THIS element (if available)  !!Falls back to default form if 'short' form does not exist.!! Use getSpecialFormQuestionText() if you want short form only.
 * @return shortText form 
 */
public String getShortText(){
  String returnText=getSpecialFormQuestionText(getTextID(),TEXT_FORM_SHORT);
  if (returnText == null)   returnText=getSpecialFormQuestionText(null);
  return returnText;
}
Program: 145100
Project: 145100
Buggy source:
/** 
 * Remove a message from the send queue
 * @param success
 * @throws IOException
 */
public void decache(TransportMessage message) throws TransportException {
  storage(Q_STORENAME).remove(message);
  message.setID(-1);
  if (message.isSuccess()) {
    IStorageUtilityIndexed recent=storage(RECENTLY_SENT_STORENAME);
    if (recent.getNumRecords() == RECENTLY_SENT_STORE_MAXSIZE) {
      int first=recent.iterate().nextID();
      recent.remove(first);
    }
    try {
      recent.write(message);
    }
 catch (    StorageFullException e) {
      throw new TransportException(e);
    }
  }
  updateCachedCounts();
}

Fixed version (ground truth):
/** 
 * Remove a message from the send queue
 * @param success
 * @throws IOException
 */
public void decache(TransportMessage message) throws TransportException {
  try {
    storage(Q_STORENAME).remove(message);
  }
 catch (  IllegalArgumentException iae) {
    Logger._().log("String_Node_Str","String_Node_Str",new Date());
    return;
  }
  message.setID(-1);
  if (message.isSuccess()) {
    IStorageUtilityIndexed recent=storage(RECENTLY_SENT_STORENAME);
    boolean entered=false;
    int attempts=0;
    while (attempts < 5 && !entered) {
      attempts++;
      if (recent.getNumRecords() == RECENTLY_SENT_STORE_MAXSIZE) {
        try {
          int first=recent.iterate().nextID();
          recent.remove(first);
        }
 catch (        StorageModifiedException sme) {
          Logger._().log("String_Node_Str","String_Node_Str",new Date());
        }
catch (        IllegalArgumentException iae) {
        }
      }
      try {
        recent.write(message);
        entered=true;
      }
 catch (      StorageFullException e) {
        throw new TransportException(e);
      }
    }
  }
  updateCachedCounts();
}
Program: 145101
Project: 145101
Buggy source:
/** 
 * @param message
 * @return
 * @throws TransportException
 */
public static TransportMessage sendBlocking(TransportMessage message) throws TransportException {
  if (message.isCacheable()) {
    CACHE.cache(message);
  }
  Transporter transporter=message.createTransporter();
  transporter.setMessage(message);
  transporter.send();
  if (message.isCacheable()) {
    if (message.getStatus() == TransportMessageStatus.SENT) {
      CACHE.decache(message);
    }
 else {
      message.setStatus(TransportMessageStatus.CACHED);
      CACHE.updateMessage(message);
    }
  }
  return message;
}

Fixed version (ground truth):
/** 
 * @param message
 * @return
 * @throws TransportException
 */
public static TransportMessage sendBlocking(TransportMessage message) throws TransportException {
  if (message.isCacheable()) {
    CACHE().cache(message);
  }
  Transporter transporter=message.createTransporter();
  transporter.setMessage(message);
  transporter.send();
  if (message.isCacheable()) {
    if (message.getStatus() == TransportMessageStatus.SENT) {
      CACHE().decache(message);
    }
 else {
      message.setStatus(TransportMessageStatus.CACHED);
      CACHE().updateMessage(message);
    }
  }
  return message;
}
Program: 145102
Project: 145102
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 {
  Vector messages=getCachedMessages();
  if (messages.size() > 0) {
    TransportMessage m=(TransportMessage)messages.elementAt(0);
    Transporter transporter=m.createTransporter();
    TransporterSharingSender sender=new TransporterSharingSender(transporter,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 {
  Vector messages=getCachedMessages();
  if (messages.size() > 0) {
    TransportMessage m=(TransportMessage)messages.elementAt(0);
    Transporter transporter=m.createTransporter();
    TransporterSharingSender sender=new TransporterSharingSender(transporter,messages,CACHE(),listener);
    sender.send();
  }
}
Program: 145103
Project: 145103
Buggy source:
/** 
 * @return
 */
public static Vector getCachedMessages(){
  return CACHE.getCachedMessages();
}

Fixed version (ground truth):
/** 
 * @return
 */
public static Vector getCachedMessages(){
  return CACHE().getCachedMessages();
}
Program: 145104
Project: 145104
Buggy source:
/** 
 * @return
 */
public static int getCachedMessagesSize(){
  return CACHE.getCachedMessagesCount();
}

Fixed version (ground truth):
/** 
 * @return
 */
public static int getCachedMessagesSize(){
  return CACHE().getCachedMessagesCount();
}
Program: 145105
Project: 145105
Buggy source:
/** 
 * A TransportMessage is assigned a uniqueId when persisted. Applications can access the message again via this method
 * @param id The unique id assigned to the TransportMessage when it was queued for sending
 * @return The TransportMessage identified by the id (or null if no suchmessage was found)
 */
public static TransportMessage retrieve(String id){
  return CACHE.findMessage(id);
}

Fixed version (ground truth):
/** 
 * A TransportMessage is assigned a uniqueId when persisted. Applications can access the message again via this method
 * @param id The unique id assigned to the TransportMessage when it was queued for sending
 * @return The TransportMessage identified by the id (or null if no suchmessage was found)
 */
public static TransportMessage retrieve(String id){
  return CACHE().findMessage(id);
}
Program: 145106
Project: 145106
Buggy source:
/** 
 * Send a message, specifying a number of tries and the pause between the tries (in seconds)
 * @param message
 * @param tries
 * @param delay
 * @return
 * @throws IOException
 */
public static SenderThread send(TransportMessage message,int tries,int delay) throws TransportException {
  Transporter transporter=message.createTransporter();
  SenderThread thread=new SimpleSenderThread(transporter,CACHE,tries,delay);
  if (message.isCacheable()) {
    message.setSendingThreadDeadline(getSendingThreadDeadline(thread.getTries(),thread.getDelay()));
synchronized (CACHE) {
      CACHE.cache(message);
    }
  }
 else {
    message.setStatus(TransportMessageStatus.QUEUED);
  }
  thread.start();
  return thread;
}

Fixed version (ground truth):
/** 
 * Send a message, specifying a number of tries and the pause between the tries (in seconds)
 * @param message
 * @param tries
 * @param delay
 * @return
 * @throws IOException
 */
public static SenderThread send(TransportMessage message,int tries,int delay) throws TransportException {
  Transporter transporter=message.createTransporter();
  SenderThread thread=new SimpleSenderThread(transporter,CACHE(),tries,delay);
  if (message.isCacheable()) {
    message.setSendingThreadDeadline(getSendingThreadDeadline(thread.getTries(),thread.getDelay()));
synchronized (CACHE()) {
      CACHE().cache(message);
    }
  }
 else {
    message.setStatus(TransportMessageStatus.QUEUED);
  }
  thread.start();
  return thread;
}
Program: 145107
Project: 145107
Buggy source:
/** 
 * @param testing
 */
public TransportMessageStore(){
  updateCachedCounts();
}

Fixed version (ground truth):
/** 
 * @param testing
 */
public TransportMessageStore(){
  cachedCounts=new Hashtable();
  storage(Q_STORENAME).repair();
  storage(RECENTLY_SENT_STORENAME).repair();
  updateCachedCounts();
}
Program: 145108
Project: 145108
Buggy source:
public void clearLogs(){
  Vector ids=new Vector();
  IStorageIterator li=logStorage.iterate();
  while (li.hasMore()) {
    ids.addElement(new Integer(li.nextID()));
  }
  for (int i=0; i < ids.size(); i++) {
    int id=((Integer)ids.elementAt(i)).intValue();
    logStorage.remove(id);
  }
}

Fixed version (ground truth):
public void clearLogs(){
synchronized (logStorage) {
    if (!checkStorage()) {
      return;
    }
    Vector ids=new Vector();
    IStorageIterator li=logStorage.iterate();
    while (li.hasMore()) {
      ids.addElement(new Integer(li.nextID()));
    }
    for (int i=0; i < ids.size(); i++) {
      int id=((Integer)ids.elementAt(i)).intValue();
      logStorage.remove(id);
    }
  }
}
Program: 145109
Project: 145109
Buggy source:
public void log(String type,String message,Date logDate){
  LogEntry log=new LogEntry(type,message,logDate);
  try {
    logStorage.add(log);
  }
 catch (  StorageFullException e) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void log(String type,String message,Date logDate){
synchronized (logStorage) {
    LogEntry log=new LogEntry(type,message,logDate);
    try {
      logStorage.add(log);
    }
 catch (    StorageFullException e) {
      throw new RuntimeException("String_Node_Str");
    }
  }
}
Program: 145110
Project: 145110
Buggy source:
public boolean serializeLogs(IAtomicLogSerializer serializer){
  IStorageIterator li=logStorage.iterate();
  while (li.hasMore()) {
    if (!serializer.serializeLog((LogEntry)li.nextRecord()))     ;
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean serializeLogs(IAtomicLogSerializer serializer){
synchronized (logStorage) {
    if (!checkStorage()) {
      return false;
    }
    IStorageIterator li=logStorage.iterate();
    while (li.hasMore()) {
      if (!serializer.serializeLog((LogEntry)li.nextRecord()))       ;
      return false;
    }
    return true;
  }
}
Program: 145111
Project: 145111
Buggy source:
public int logSize(){
  return logStorage.getNumRecords();
}

Fixed version (ground truth):
public int logSize(){
synchronized (logStorage) {
    if (!checkStorage()) {
      return -1;
    }
    return logStorage.getNumRecords();
  }
}
Program: 145112
Project: 145112
Buggy source:
private void dumpLogFallback(){
  try {
    String dumpRef="String_Node_Str" + DateUtils.formatDateTime(new Date(),DateUtils.FORMAT_TIMESTAMP_SUFFIX) + "String_Node_Str";
    Reference ref=ReferenceManager._().DeriveReference(dumpRef);
    if (!ref.isReadOnly()) {
      if (Logger._().serializeLogs(new StreamLogSerializer(ref.getOutputStream()))) {
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  Logger._().clearLogs();
}

Fixed version (ground truth):
private void dumpLogFallback(){
  try {
    String dumpRef="String_Node_Str" + DateUtils.formatDateTime(new Date(),DateUtils.FORMAT_TIMESTAMP_SUFFIX) + "String_Node_Str";
    Reference ref=ReferenceManager._().DeriveReference(dumpRef);
    if (!ref.isReadOnly()) {
      if (Logger._().serializeLogs(new StreamLogSerializer(ref.getOutputStream()))) {
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    if (Logger._() == null) {
      System.out.println("String_Node_Str");
    }
    Logger._().clearLogs();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 145113
Project: 145113
Buggy source:
/** 
 * @param message
 * @return
 * @throws TransportException
 */
public static TransportMessage sendBlocking(TransportMessage message) throws TransportException {
  if (message.isCacheable()) {
    CACHE.cache(message);
  }
  Transporter transporter=message.createTransporter();
  transporter.setMessage(message);
  transporter.send();
  if (message.isCacheable()) {
    if (message.getStatus() == TransportMessageStatus.SENT) {
      CACHE.decache(message);
    }
 else {
      message.setStatus(TransportMessageStatus.CACHED);
      CACHE.updateMessage(message);
    }
  }
  return message;
}

Fixed version (ground truth):
/** 
 * @param message
 * @return
 * @throws TransportException
 */
public static TransportMessage sendBlocking(TransportMessage message) throws TransportException {
  if (message.isCacheable()) {
    CACHE().cache(message);
  }
  Transporter transporter=message.createTransporter();
  transporter.setMessage(message);
  transporter.send();
  if (message.isCacheable()) {
    if (message.getStatus() == TransportMessageStatus.SENT) {
      CACHE().decache(message);
    }
 else {
      message.setStatus(TransportMessageStatus.CACHED);
      CACHE().updateMessage(message);
    }
  }
  return message;
}
Program: 145114
Project: 145114
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 {
  Vector messages=getCachedMessages();
  if (messages.size() > 0) {
    TransportMessage m=(TransportMessage)messages.elementAt(0);
    Transporter transporter=m.createTransporter();
    TransporterSharingSender sender=new TransporterSharingSender(transporter,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 {
  Vector messages=getCachedMessages();
  if (messages.size() > 0) {
    TransportMessage m=(TransportMessage)messages.elementAt(0);
    Transporter transporter=m.createTransporter();
    TransporterSharingSender sender=new TransporterSharingSender(transporter,messages,CACHE(),listener);
    sender.send();
  }
}
Program: 145115
Project: 145115
Buggy source:
/** 
 * @return
 */
public static Vector getCachedMessages(){
  return CACHE.getCachedMessages();
}

Fixed version (ground truth):
/** 
 * @return
 */
public static Vector getCachedMessages(){
  return CACHE().getCachedMessages();
}
Program: 145116
Project: 145116
Buggy source:
/** 
 * @return
 */
public static int getCachedMessagesSize(){
  return CACHE.getCachedMessagesCount();
}

Fixed version (ground truth):
/** 
 * @return
 */
public static int getCachedMessagesSize(){
  return CACHE().getCachedMessagesCount();
}
Program: 145117
Project: 145117
Buggy source:
/** 
 * A TransportMessage is assigned a uniqueId when persisted. Applications can access the message again via this method
 * @param id The unique id assigned to the TransportMessage when it was queued for sending
 * @return The TransportMessage identified by the id (or null if no suchmessage was found)
 */
public static TransportMessage retrieve(String id){
  return CACHE.findMessage(id);
}

Fixed version (ground truth):
/** 
 * A TransportMessage is assigned a uniqueId when persisted. Applications can access the message again via this method
 * @param id The unique id assigned to the TransportMessage when it was queued for sending
 * @return The TransportMessage identified by the id (or null if no suchmessage was found)
 */
public static TransportMessage retrieve(String id){
  return CACHE().findMessage(id);
}
Program: 145118
Project: 145118
Buggy source:
/** 
 * Send a message, specifying a number of tries and the pause between the tries (in seconds)
 * @param message
 * @param tries
 * @param delay
 * @return
 * @throws IOException
 */
public static SenderThread send(TransportMessage message,int tries,int delay) throws TransportException {
  Transporter transporter=message.createTransporter();
  SenderThread thread=new SimpleSenderThread(transporter,CACHE,tries,delay);
  if (message.isCacheable()) {
    message.setSendingThreadDeadline(getSendingThreadDeadline(thread.getTries(),thread.getDelay()));
synchronized (CACHE) {
      CACHE.cache(message);
    }
  }
 else {
    message.setStatus(TransportMessageStatus.QUEUED);
  }
  thread.start();
  return thread;
}

Fixed version (ground truth):
/** 
 * Send a message, specifying a number of tries and the pause between the tries (in seconds)
 * @param message
 * @param tries
 * @param delay
 * @return
 * @throws IOException
 */
public static SenderThread send(TransportMessage message,int tries,int delay) throws TransportException {
  Transporter transporter=message.createTransporter();
  SenderThread thread=new SimpleSenderThread(transporter,CACHE(),tries,delay);
  if (message.isCacheable()) {
    message.setSendingThreadDeadline(getSendingThreadDeadline(thread.getTries(),thread.getDelay()));
synchronized (CACHE()) {
      CACHE().cache(message);
    }
  }
 else {
    message.setStatus(TransportMessageStatus.QUEUED);
  }
  thread.start();
  return thread;
}
Program: 145119
Project: 145119
Buggy source:
/** 
 * @param testing
 */
public TransportMessageStore(){
  updateCachedCounts();
}

Fixed version (ground truth):
/** 
 * @param testing
 */
public TransportMessageStore(){
  cachedCounts=new Hashtable();
  storage(Q_STORENAME).repair();
  storage(RECENTLY_SENT_STORENAME).repair();
  updateCachedCounts();
}
Program: 145120
Project: 145120
Buggy source:
public void clearLogs(){
  Vector ids=new Vector();
  IStorageIterator li=logStorage.iterate();
  while (li.hasMore()) {
    ids.addElement(new Integer(li.nextID()));
  }
  for (int i=0; i < ids.size(); i++) {
    int id=((Integer)ids.elementAt(i)).intValue();
    logStorage.remove(id);
  }
}

Fixed version (ground truth):
public void clearLogs(){
synchronized (logStorage) {
    if (!checkStorage()) {
      return;
    }
    Vector ids=new Vector();
    IStorageIterator li=logStorage.iterate();
    while (li.hasMore()) {
      ids.addElement(new Integer(li.nextID()));
    }
    for (int i=0; i < ids.size(); i++) {
      int id=((Integer)ids.elementAt(i)).intValue();
      logStorage.remove(id);
    }
  }
}
Program: 145121
Project: 145121
Buggy source:
public void log(String type,String message,Date logDate){
  LogEntry log=new LogEntry(type,message,logDate);
  try {
    logStorage.add(log);
  }
 catch (  StorageFullException e) {
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void log(String type,String message,Date logDate){
synchronized (logStorage) {
    LogEntry log=new LogEntry(type,message,logDate);
    try {
      logStorage.add(log);
    }
 catch (    StorageFullException e) {
      throw new RuntimeException("String_Node_Str");
    }
  }
}
Program: 145122
Project: 145122
Buggy source:
public boolean serializeLogs(IAtomicLogSerializer serializer){
  IStorageIterator li=logStorage.iterate();
  while (li.hasMore()) {
    if (!serializer.serializeLog((LogEntry)li.nextRecord()))     ;
    return false;
  }
  return true;
}

Fixed version (ground truth):
public boolean serializeLogs(IAtomicLogSerializer serializer){
synchronized (logStorage) {
    if (!checkStorage()) {
      return false;
    }
    IStorageIterator li=logStorage.iterate();
    while (li.hasMore()) {
      if (!serializer.serializeLog((LogEntry)li.nextRecord()))       ;
      return false;
    }
    return true;
  }
}
Program: 145123
Project: 145123
Buggy source:
public int logSize(){
  return logStorage.getNumRecords();
}

Fixed version (ground truth):
public int logSize(){
synchronized (logStorage) {
    if (!checkStorage()) {
      return -1;
    }
    return logStorage.getNumRecords();
  }
}
Program: 145124
Project: 145124
Buggy source:
private void dumpLogFallback(){
  try {
    String dumpRef="String_Node_Str" + DateUtils.formatDateTime(new Date(),DateUtils.FORMAT_TIMESTAMP_SUFFIX) + "String_Node_Str";
    Reference ref=ReferenceManager._().DeriveReference(dumpRef);
    if (!ref.isReadOnly()) {
      if (Logger._().serializeLogs(new StreamLogSerializer(ref.getOutputStream()))) {
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  Logger._().clearLogs();
}

Fixed version (ground truth):
private void dumpLogFallback(){
  try {
    String dumpRef="String_Node_Str" + DateUtils.formatDateTime(new Date(),DateUtils.FORMAT_TIMESTAMP_SUFFIX) + "String_Node_Str";
    Reference ref=ReferenceManager._().DeriveReference(dumpRef);
    if (!ref.isReadOnly()) {
      if (Logger._().serializeLogs(new StreamLogSerializer(ref.getOutputStream()))) {
      }
 else {
      }
    }
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
  try {
    if (Logger._() == null) {
      System.out.println("String_Node_Str");
    }
    Logger._().clearLogs();
  }
 catch (  Exception e) {
    e.printStackTrace();
  }
}
Program: 145125
Project: 145125
Buggy source:
/** 
 * Remove a message from the send queue
 * @param success
 * @throws IOException
 */
public void decache(TransportMessage message) throws TransportException {
  storage(Q_STORENAME).remove(message);
  message.setID(-1);
  if (message.isSuccess()) {
    IStorageUtilityIndexed recent=storage(RECENTLY_SENT_STORENAME);
    if (recent.getNumRecords() == RECENTLY_SENT_STORE_MAXSIZE) {
      int first=recent.iterate().nextID();
      recent.remove(first);
    }
    try {
      recent.write(message);
    }
 catch (    StorageFullException e) {
      throw new TransportException(e);
    }
  }
  updateCachedCounts();
}

Fixed version (ground truth):
/** 
 * Remove a message from the send queue
 * @param success
 * @throws IOException
 */
public void decache(TransportMessage message) throws TransportException {
  try {
    storage(Q_STORENAME).remove(message);
  }
 catch (  IllegalArgumentException iae) {
    Logger._().log("String_Node_Str","String_Node_Str",new Date());
    return;
  }
  message.setID(-1);
  if (message.isSuccess()) {
    IStorageUtilityIndexed recent=storage(RECENTLY_SENT_STORENAME);
    boolean entered=false;
    int attempts=0;
    while (attempts < 5 && !entered) {
      attempts++;
      if (recent.getNumRecords() == RECENTLY_SENT_STORE_MAXSIZE) {
        try {
          int first=recent.iterate().nextID();
          recent.remove(first);
        }
 catch (        StorageModifiedException sme) {
          Logger._().log("String_Node_Str","String_Node_Str",new Date());
        }
catch (        IllegalArgumentException iae) {
        }
      }
      try {
        recent.write(message);
        entered=true;
      }
 catch (      StorageFullException e) {
        throw new TransportException(e);
      }
    }
  }
  updateCachedCounts();
}
Program: 145126
Project: 145126
Buggy source:
private void parseRegistration(TreeElement head) throws MalformedUserModelException, StorageFullException {
  String username=getString(getChild(head,"String_Node_Str"),head);
  String password=getString(getChild(head,"String_Node_Str"),head);
  String uuid=getString(getChild(head,"String_Node_Str"),head);
  User u=getUserFromStorage(uuid);
  if (u == null) {
    u=new User(username,password,uuid);
  }
  TreeElement data=getChild(head,"String_Node_Str");
  for (int i=0; i < data.getNumChildren(); ++i) {
    TreeElement datum=data.getChildAt(i);
    if (!datum.isRelevant()) {
      continue;
    }
    String keyName=datum.getAttributeValue(null,"String_Node_Str");
    if (keyName == null) {
      throw new MalformedUserModelException("String_Node_Str" + username + "String_Node_Str");
    }
    u.setProperty(keyName,getString(datum,data));
  }
  storage().write(u);
  user=u;
}

Fixed version (ground truth):
private void parseRegistration(TreeElement head) throws MalformedUserModelException, StorageFullException {
  String username=getString(getChild(head,"String_Node_Str"),head);
  String password=getString(getChild(head,"String_Node_Str"),head);
  String uuid=getString(getChild(head,"String_Node_Str"),head);
  User u=getUserFromStorage(uuid);
  if (!u.getPassword().equals(password)) {
    u.setPassword(password);
  }
  if (u == null) {
    u=new User(username,password,uuid);
  }
  TreeElement data=getChild(head,"String_Node_Str");
  for (int i=0; i < data.getNumChildren(); ++i) {
    TreeElement datum=data.getChildAt(i);
    if (!datum.isRelevant()) {
      continue;
    }
    String keyName=datum.getAttributeValue(null,"String_Node_Str");
    if (keyName == null) {
      throw new MalformedUserModelException("String_Node_Str" + username + "String_Node_Str");
    }
    u.setProperty(keyName,getString(datum,data));
  }
  storage().write(u);
  user=u;
}
Program: 145127
Project: 145127
Buggy source:
public Object getSortKey(String fieldKey){
  if (fieldKey.equals("String_Node_Str")) {
    return new Integer(this.getRecordID());
  }
 else {
    try {
      return getShortFields()[Integer.valueOf(fieldKey).intValue()];
    }
 catch (    NumberFormatException nfe) {
      nfe.printStackTrace();
      throw new RuntimeException("String_Node_Str" + fieldKey);
    }
  }
}

Fixed version (ground truth):
public Object getSortKey(String fieldKey){
  if (fieldKey.equals("String_Node_Str")) {
    return new Integer(this.getRecordID());
  }
 else {
    try {
      return getShortFields()[Integer.valueOf(fieldKey).intValue() - 1];
    }
 catch (    NumberFormatException nfe) {
      nfe.printStackTrace();
      throw new RuntimeException("String_Node_Str" + fieldKey);
    }
  }
}
Program: 145128
Project: 145128
Buggy source:
/** 
 * @return
 */
private String getCurrentDisplay(){
  return Localization.get("String_Node_Str",new String[]{String.valueOf(currentid),String.valueOf(ids.size()),String.valueOf(currentid + 1),String.valueOf(ids.size())});
}

Fixed version (ground truth):
/** 
 * @return
 */
private String getCurrentDisplay(){
  return Localization.get("String_Node_Str",new String[]{String.valueOf(currentid + 1),String.valueOf(ids.size()),String.valueOf(currentid),String.valueOf(ids.size())});
}