nus-yam/ex-repair huggingface dataset:
Program: 144918
Project: 144918
Buggy source:
public void registerModule(){
  GraphElementHandler graphHandler=new GraphElementHandler();
  graphHandler.registerGraphType(WHOWeightTemplate.WHO_WEIGHT_TEMPLATE_NAME);
  XFormParser.registerHandler("String_Node_Str",graphHandler);
  XFormParser.addDataType("String_Node_Str",GraphDataGroup.GRAPH_DATA_ID);
  XFormParser.addModelPrototype(GraphDataGroup.GRAPH_DATA_ID,new GraphDataGroup());
  XFormParser.registerControlType("String_Node_Str",ImmunizationWidget.CONTROL_IMMUNIZATION);
  String[] classes={"String_Node_Str"};
  PrototypeManager.registerPrototypes(classes);
  ByteArrayOutputStream bis=new ByteArrayOutputStream();
  DataOutputStream out=new DataOutputStream(bis);
  try {
    ExtUtil.write(out,new ExtWrapTagged(new GraphDataGroup()));
    byte[] test=bis.toByteArray();
    DataInputStream in=new DataInputStream(new ByteArrayInputStream(test));
    ExtUtil.read(in,new ExtWrapTagged());
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str");
  }
catch (  DeserializationException e) {
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str");
  }
}

Fixed version (ground truth):
public void registerModule(){
  XFormParser.addDataType("String_Node_Str",GraphDataGroup.GRAPH_DATA_ID);
  XFormParser.addModelPrototype(GraphDataGroup.GRAPH_DATA_ID,new GraphDataGroup());
  XFormParser.registerControlType("String_Node_Str",ImmunizationWidget.CONTROL_IMMUNIZATION);
  String[] classes={"String_Node_Str"};
  PrototypeManager.registerPrototypes(classes);
  ByteArrayOutputStream bis=new ByteArrayOutputStream();
  DataOutputStream out=new DataOutputStream(bis);
  try {
    ExtUtil.write(out,new ExtWrapTagged(new GraphDataGroup()));
    byte[] test=bis.toByteArray();
    DataInputStream in=new DataInputStream(new ByteArrayInputStream(test));
    ExtUtil.read(in,new ExtWrapTagged());
  }
 catch (  IOException e) {
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str");
  }
catch (  DeserializationException e) {
    e.printStackTrace();
    throw new RuntimeException("String_Node_Str");
  }
}
Program: 144919
Project: 144919
Buggy source:
public void send(){
  try {
    HttpConnection connection=getConnection();
    int response=connection.getResponseCode();
    if (response == HttpConnection.HTTP_UNAUTHORIZED) {
      String challenge=getChallenge(connection);
      if (this.issueChallenge(connection,challenge)) {
        connection.close();
        connection=getConnection();
        handleResponse(connection);
      }
 else {
        handleResponse(connection);
      }
    }
 else {
      handleResponse(connection);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    this.setStatus(TransportMessageStatus.FAILED);
    this.setFailureReason(WrappedException.printException(e));
  }
}

Fixed version (ground truth):
public void send(){
  HttpConnection connection=null;
  try {
    connection=getConnection();
    int response=connection.getResponseCode();
    if (response == HttpConnection.HTTP_UNAUTHORIZED) {
      String challenge=getChallenge(connection);
      if (this.issueChallenge(connection,challenge)) {
        connection.close();
        connection=getConnection();
        handleResponse(connection);
      }
 else {
        handleResponse(connection);
      }
    }
 else {
      handleResponse(connection);
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    this.setStatus(TransportMessageStatus.FAILED);
    this.setFailureReason(WrappedException.printException(e));
  }
 finally {
    if (connection != null) {
      try {
        connection.close();
      }
 catch (      IOException e) {
      }
    }
  }
}
Program: 144920
Project: 144920
Buggy source:
private void syncMeta(){
  meta.clear();
  for (Enumeration en=data.keys(); en.hasMoreElements(); ) {
    Integer i=(Integer)en.nextElement();
    Externalizable e=(Externalizable)data.get(i);
    if (e instanceof IMetaData) {
      IMetaData m=(IMetaData)e;
      for (      String key : m.getMetaDataFields()) {
        if (!meta.containsKey(key)) {
          meta.put(key,new Hashtable<Object,Vector<Integer>>());
        }
      }
      for (      String key : dynamicIndices) {
        if (!meta.containsKey(key)) {
          meta.put(key,new Hashtable<Object,Vector<Integer>>());
        }
      }
      for (Enumeration keys=meta.keys(); en.hasMoreElements(); ) {
        String key=(String)keys.nextElement();
        Object value=m.getMetaData(key);
        Hashtable<Object,Vector<Integer>> records=meta.get(key);
        if (!records.containsKey(value)) {
          records.put(value,new Vector<Integer>());
        }
        Vector<Integer> indices=records.get(value);
        if (!indices.contains(i)) {
          records.get(value).addElement(i);
        }
      }
    }
  }
}

Fixed version (ground truth):
private void syncMeta(){
  meta.clear();
  for (Enumeration en=data.keys(); en.hasMoreElements(); ) {
    Integer i=(Integer)en.nextElement();
    Externalizable e=(Externalizable)data.get(i);
    if (e instanceof IMetaData) {
      IMetaData m=(IMetaData)e;
      for (      String key : m.getMetaDataFields()) {
        if (!meta.containsKey(key)) {
          meta.put(key,new Hashtable<Object,Vector<Integer>>());
        }
      }
      for (      String key : dynamicIndices) {
        if (!meta.containsKey(key)) {
          meta.put(key,new Hashtable<Object,Vector<Integer>>());
        }
      }
      for (Enumeration keys=meta.keys(); keys.hasMoreElements(); ) {
        String key=(String)keys.nextElement();
        Object value=m.getMetaData(key);
        Hashtable<Object,Vector<Integer>> records=meta.get(key);
        if (!records.containsKey(value)) {
          records.put(value,new Vector<Integer>());
        }
        Vector<Integer> indices=records.get(value);
        if (!indices.contains(i)) {
          records.get(value).addElement(i);
        }
      }
    }
  }
}
Program: 144921
Project: 144921
Buggy source:
public void registerIndex(String index){
synchronized (metadataAccessLock) {
    if (dynamicIndices == null) {
      dynamicIndices=new Vector<String>();
    }
    dynamicIndices.addElement(index);
    buildIndex();
  }
}

Fixed version (ground truth):
public void registerIndex(String index){
  if (index == null) {
    throw new NullPointerException("String_Node_Str");
  }
synchronized (metadataAccessLock) {
    if (dynamicIndices == null) {
      dynamicIndices=new Vector<String>();
    }
    dynamicIndices.addElement(index);
    buildIndex();
  }
}
Program: 144922
Project: 144922
Buggy source:
private IMetaData getMetaDataForRecord(int record){
  Hashtable<String,Object> data=null;
synchronized (metadataAccessLock) {
    if (hasMetaData) {
      if (exists(record)) {
        data=new Hashtable<String,Object>();
        Integer recordId=DataUtil.integer(record);
        for (        String s : proto.getMetaDataFields()) {
          Hashtable<Object,Vector<Integer>> values=metaDataIndex.get(s);
          for (Enumeration en=values.keys(); en.hasMoreElements(); ) {
            Object o=en.nextElement();
            Vector<Integer> ids=values.get(o);
            if (ids.contains(recordId)) {
              data.put(s,o);
              break;
            }
          }
        }
      }
    }
  }
  return new MetaDataWrapper(data);
}

Fixed version (ground truth):
private IMetaData getMetaDataForRecord(int record){
  Hashtable<String,Object> data=null;
synchronized (metadataAccessLock) {
    if (hasMetaData) {
      if (exists(record)) {
        data=new Hashtable<String,Object>();
        Integer recordId=DataUtil.integer(record);
        for (        String s : getFields()) {
          Hashtable<Object,Vector<Integer>> values=metaDataIndex.get(s);
          for (Enumeration en=values.keys(); en.hasMoreElements(); ) {
            Object o=en.nextElement();
            Vector<Integer> ids=values.get(o);
            if (ids.contains(recordId)) {
              data.put(s,o);
              break;
            }
          }
        }
      }
    }
  }
  return new MetaDataWrapper(data);
}
Program: 144923
Project: 144923
Buggy source:
private Hashtable<String,Object> getMetaData(IMetaData m,String[] index){
  Hashtable<String,Object> h=new Hashtable<String,Object>();
  for (  String s : index) {
    h.put(s,m.getMetaData(s));
  }
  return h;
}

Fixed version (ground truth):
private Hashtable<String,Object> getMetaData(IMetaData m,String[] index){
  Hashtable<String,Object> h=new Hashtable<String,Object>();
  for (  String s : index) {
    Object o=m.getMetaData(s);
    if (o == null || s == null) {
      "String_Node_Str".charAt(0);
    }
    h.put(s,o);
  }
  return h;
}
Program: 144924
Project: 144924
Buggy source:
public boolean isReadOnly(){
  try {
    FileConnection c=connector();
    if (c.exists()) {
      return c.canWrite();
    }
 else {
      try {
        String local=this.getLocalURI();
        if (local.indexOf("String_Node_Str") == -1) {
          return false;
        }
 else {
          String parent=local.substring(0,local.lastIndexOf('/'));
          FileConnection parentConnector=this.connector(parent,false);
          if (parentConnector.exists() && parentConnector.isDirectory()) {
            boolean result=parentConnector.canWrite();
            parentConnector.close();
            return result;
          }
          return false;
        }
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    return true;
  }
catch (  SecurityException se) {
    return true;
  }
}

Fixed version (ground truth):
public boolean isReadOnly(){
  try {
    FileConnection c=connector();
    if (c.exists()) {
      return !c.canWrite();
    }
 else {
      try {
        String local=this.getLocalURI();
        if (local.indexOf("String_Node_Str") == -1) {
          return false;
        }
 else {
          String parent=local.substring(0,local.lastIndexOf('/'));
          FileConnection parentConnector=this.connector(parent,false);
          if (parentConnector.exists() && parentConnector.isDirectory()) {
            boolean result=parentConnector.canWrite();
            parentConnector.close();
            return !result;
          }
          return false;
        }
      }
 catch (      Exception e) {
        return false;
      }
    }
  }
 catch (  IOException e) {
    e.printStackTrace();
    return true;
  }
catch (  SecurityException se) {
    return true;
  }
}
Program: 144925
Project: 144925
Buggy source:
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.writeString(out,ExtUtil.emptyIfNull(name));
  ExtUtil.writeNumeric(out,multiplicity);
  ExtUtil.write(out,new ExtWrapList(ExtUtil.emptyIfNull(predicates)));
}

Fixed version (ground truth):
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.writeString(out,ExtUtil.emptyIfNull(name));
  ExtUtil.writeNumeric(out,multiplicity);
  ExtUtil.write(out,new ExtWrapListPoly(ExtUtil.emptyIfNull(predicates)));
}
Program: 144926
Project: 144926
Buggy source:
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  name=ExtUtil.nullIfEmpty(ExtUtil.readString(in));
  multiplicity=ExtUtil.readInt(in);
  predicates=ExtUtil.nullIfEmpty((Vector<XPathExpression>)ExtUtil.read(in,new ExtWrapList(new ExtWrapTagged())));
}

Fixed version (ground truth):
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  name=ExtUtil.nullIfEmpty(ExtUtil.readString(in));
  multiplicity=ExtUtil.readInt(in);
  predicates=ExtUtil.nullIfEmpty((Vector<XPathExpression>)ExtUtil.read(in,new ExtWrapListPoly()));
}
Program: 144927
Project: 144927
Buggy source:
/** 
 * Get text for locale and exact text ID only, not using any fallbacks. NOTE: This call will only return the full compliment of available strings if and  only if the requested locale is current. Otherwise it will only retrieve strings declared at runtime.
 * @param locale Locale. Must be defined and not null.
 * @param textID Text handle (text ID appended with optional text form). Must not be null.
 * @return Localized text. Return null if none found.
 * @throws UnregisteredLocaleException If the locale is not defined or null.
 * @throws NullPointerException if textID is null
 */
public String getRawText(String locale,String textID){
  if (locale == null) {
    throw new UnregisteredLocaleException("String_Node_Str" + textID);
  }
  if (locale.equals(currentLocale)) {
    return currentLocaleData.get(textID).render();
  }
 else {
    return (String)getLocaleMap(locale).get(textID);
  }
}

Fixed version (ground truth):
/** 
 * Get text for locale and exact text ID only, not using any fallbacks. NOTE: This call will only return the full compliment of available strings if and  only if the requested locale is current. Otherwise it will only retrieve strings declared at runtime.
 * @param locale Locale. Must be defined and not null.
 * @param textID Text handle (text ID appended with optional text form). Must not be null.
 * @return Localized text. Return null if none found.
 * @throws UnregisteredLocaleException If the locale is not defined or null.
 * @throws NullPointerException if textID is null
 */
public String getRawText(String locale,String textID){
  if (locale == null) {
    throw new UnregisteredLocaleException("String_Node_Str" + textID);
  }
  if (locale.equals(currentLocale)) {
    PrefixTreeNode data=currentLocaleData.get(textID);
    return data == null ? null : data.render();
  }
 else {
    return (String)getLocaleMap(locale).get(textID);
  }
}
Program: 144929
Project: 144929
Buggy source:
public void triggerTriggerables(TreeReference ref){
  TreeReference genericRef=ref.genericize();
  Vector triggered=(Vector)triggerIndex.get(genericRef);
  if (triggered == null)   return;
  Vector triggeredCopy=new Vector();
  for (int i=0; i < triggered.size(); i++)   triggeredCopy.addElement(triggered.elementAt(i));
  evaluateTriggerables(triggeredCopy,ref);
}

Fixed version (ground truth):
public void triggerTriggerables(TreeReference ref){
  TreeReference genericRef=ref.genericize();
  Vector triggered=(Vector)triggerIndex.get(genericRef);
  if (triggered == null) {
    return;
  }
  Vector triggeredCopy=new Vector();
  for (int i=0; i < triggered.size(); i++) {
    triggeredCopy.addElement(triggered.elementAt(i));
  }
  evaluateTriggerables(triggeredCopy,ref);
}
Program: 144931
Project: 144931
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) {
    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;
  }
}

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.clone(),new Vector());
      }
      Vector triggered=(Vector)triggerIndex.get(trigger);
      if (!triggered.contains(t)) {
        triggered.addElement(t);
      }
    }
    return t;
  }
}
Program: 144932
Project: 144932
Buggy source:
private void evaluateTriggerable(Triggerable t,TreeReference anchorRef){
  TreeReference contextRef=t.contextRef.contextualize(anchorRef);
  Vector v=exprEvalContext.expandReference(contextRef);
  for (int i=0; i < v.size(); i++) {
    EvaluationContext ec=new EvaluationContext(exprEvalContext,(TreeReference)v.elementAt(i));
    try {
      t.apply(mainInstance,ec,this);
    }
 catch (    RuntimeException e) {
      throw e;
    }
  }
}

Fixed version (ground truth):
private void evaluateTriggerable(Triggerable t,TreeReference anchorRef){
  TreeReference contextRef=t.contextRef.contextualize(anchorRef);
  Vector<TreeReference> v=exprEvalContext.expandReference(contextRef);
  for (int i=0; i < v.size(); i++) {
    try {
      t.apply(mainInstance,exprEvalContext,v.elementAt(i),this);
    }
 catch (    RuntimeException e) {
      throw e;
    }
  }
}
Program: 144933
Project: 144933
Buggy source:
Vector getTriggers();

Fixed version (ground truth):
Vector<TreeReference> getTriggers();
Program: 144934
Project: 144934
Buggy source:
Vector evalNodeset(DataInstance model,EvaluationContext evalContext);

Fixed version (ground truth):
Vector<TreeReference> evalNodeset(DataInstance model,EvaluationContext evalContext);
Program: 144935
Project: 144935
Buggy source:
public Vector getTargets(){
  return targets;
}

Fixed version (ground truth):
public Vector<TreeReference> getTargets(){
  return targets;
}
Program: 144936
Project: 144936
Buggy source:
public Vector getTriggers(){
  Vector relTriggers=expr.getTriggers();
  Vector absTriggers=new Vector();
  for (int i=0; i < relTriggers.size(); i++) {
    absTriggers.addElement(((TreeReference)relTriggers.elementAt(i)).anchor(contextRef));
  }
  return absTriggers;
}

Fixed version (ground truth):
public Vector<TreeReference> getTriggers(){
  Vector<TreeReference> relTriggers=expr.getTriggers();
  Vector<TreeReference> absTriggers=new Vector<TreeReference>();
  for (int i=0; i < relTriggers.size(); i++) {
    absTriggers.addElement(((TreeReference)relTriggers.elementAt(i)).anchor(originalContextRef));
  }
  return absTriggers;
}
Program: 144937
Project: 144937
Buggy source:
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.write(out,new ExtWrapTagged(expr));
  ExtUtil.write(out,contextRef);
  ExtUtil.write(out,new ExtWrapList(targets));
}

Fixed version (ground truth):
public void writeExternal(DataOutputStream out) throws IOException {
  ExtUtil.write(out,new ExtWrapTagged(expr));
  ExtUtil.write(out,contextRef);
  ExtUtil.write(out,originalContextRef);
  ExtUtil.write(out,new ExtWrapList(targets));
}
Program: 144938
Project: 144938
Buggy source:
public void apply(FormInstance instance,EvaluationContext evalContext,FormDef f){
  Object result=eval(instance,evalContext);
  for (int i=0; i < targets.size(); i++) {
    TreeReference targetRef=((TreeReference)targets.elementAt(i)).contextualize(evalContext.getContextRef());
    Vector v=evalContext.expandReference(targetRef);
    for (int j=0; j < v.size(); j++) {
      TreeReference affectedRef=(TreeReference)v.elementAt(j);
      apply(affectedRef,result,instance,f);
    }
  }
}

Fixed version (ground truth):
/** 
 * Not for re-implementation, dispatches all of the evaluation 
 * @param instance
 * @param evalContext
 * @param f
 */
public final void apply(FormInstance instance,EvaluationContext parentContext,TreeReference context,FormDef f){
  TreeReference ungenericised=originalContextRef.contextualize(context);
  EvaluationContext ec=new EvaluationContext(parentContext,ungenericised);
  Object result=eval(instance,ec);
  for (int i=0; i < targets.size(); i++) {
    TreeReference targetRef=((TreeReference)targets.elementAt(i)).contextualize(ec.getContextRef());
    Vector v=ec.expandReference(targetRef);
    for (int j=0; j < v.size(); j++) {
      TreeReference affectedRef=(TreeReference)v.elementAt(j);
      apply(affectedRef,result,instance,f);
    }
  }
}
Program: 144939
Project: 144939
Buggy source:
public boolean equals(Object o){
  if (o instanceof Triggerable) {
    Triggerable t=(Triggerable)o;
    if (this == t)     return true;
    if (this.expr.equals(t.expr)) {
      Vector Atriggers=this.getTriggers();
      Vector Btriggers=t.getTriggers();
      for (int k=0; k < 2; k++) {
        Vector v1=(k == 0 ? Atriggers : Btriggers);
        Vector v2=(k == 0 ? Btriggers : Atriggers);
        for (int i=0; i < v1.size(); i++) {
          if (v2.indexOf(v1.elementAt(i)) == -1) {
            return false;
          }
        }
      }
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}

Fixed version (ground truth):
public boolean equals(Object o){
  if (o instanceof Triggerable) {
    Triggerable t=(Triggerable)o;
    if (this == t)     return true;
    if (this.expr.equals(t.expr)) {
      Vector<TreeReference> Atriggers=this.getTriggers();
      Vector<TreeReference> Btriggers=t.getTriggers();
      for (int k=0; k < 2; k++) {
        Vector<TreeReference> v1=(k == 0 ? Atriggers : Btriggers);
        Vector<TreeReference> v2=(k == 0 ? Btriggers : Atriggers);
        for (int i=0; i < v1.size(); i++) {
          if (!v1.elementAt(i).isAbsolute() || v2.indexOf(v1.elementAt(i)) == -1) {
            return false;
          }
        }
      }
      return true;
    }
 else {
      return false;
    }
  }
 else {
    return false;
  }
}
Program: 144940
Project: 144940
Buggy source:
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  expr=(IConditionExpr)ExtUtil.read(in,new ExtWrapTagged(),pf);
  contextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  targets=(Vector)ExtUtil.read(in,new ExtWrapList(TreeReference.class),pf);
}

Fixed version (ground truth):
public void readExternal(DataInputStream in,PrototypeFactory pf) throws IOException, DeserializationException {
  expr=(IConditionExpr)ExtUtil.read(in,new ExtWrapTagged(),pf);
  contextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  originalContextRef=(TreeReference)ExtUtil.read(in,TreeReference.class,pf);
  targets=(Vector<TreeReference>)ExtUtil.read(in,new ExtWrapList(TreeReference.class),pf);
}
Program: 144941
Project: 144941
Buggy source:
public Triggerable(IConditionExpr expr,TreeReference contextRef){
  this.expr=expr;
  this.contextRef=contextRef;
  this.targets=new Vector();
}

Fixed version (ground truth):
public Triggerable(IConditionExpr expr,TreeReference contextRef){
  this.expr=expr;
  this.contextRef=contextRef;
  this.originalContextRef=contextRef;
  this.targets=new Vector();
}
Program: 144942
Project: 144942
Buggy source:
private static void getTriggers(XPathExpression x,Vector v,TreeReference contextRef){
  if (x instanceof XPathPathExpr) {
    TreeReference ref=((XPathPathExpr)x).getReference();
    TreeReference contextualized=ref;
    if (contextRef != null) {
      contextualized=ref.contextualize(contextRef);
    }
    if (!v.contains(contextualized)) {
      v.addElement(contextualized);
    }
    for (int i=0; i < ref.size(); i++) {
      Vector<XPathExpression> predicates=ref.getPredicate(i);
      if (predicates == null) {
        continue;
      }
      if (!ref.isAbsolute()) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      TreeReference predicateContext=ref.getSubReference(i);
      for (      XPathExpression predicate : predicates) {
        getTriggers(predicate,v,predicateContext);
      }
    }
  }
 else   if (x instanceof XPathBinaryOpExpr) {
    getTriggers(((XPathBinaryOpExpr)x).a,v,contextRef);
    getTriggers(((XPathBinaryOpExpr)x).b,v,contextRef);
  }
 else   if (x instanceof XPathUnaryOpExpr) {
    getTriggers(((XPathUnaryOpExpr)x).a,v,contextRef);
  }
 else   if (x instanceof XPathFuncExpr) {
    XPathFuncExpr fx=(XPathFuncExpr)x;
    for (int i=0; i < fx.args.length; i++)     getTriggers(fx.args[i],v,contextRef);
  }
}

Fixed version (ground truth):
private static void getTriggers(XPathExpression x,Vector<TreeReference> v,TreeReference contextRef){
  if (x instanceof XPathPathExpr) {
    TreeReference ref=((XPathPathExpr)x).getReference();
    TreeReference contextualized=ref;
    if (contextRef != null) {
      contextualized=ref.contextualize(contextRef);
    }
    if (!v.contains(contextualized)) {
      v.addElement(contextualized);
    }
    for (int i=0; i < ref.size(); i++) {
      Vector<XPathExpression> predicates=ref.getPredicate(i);
      if (predicates == null) {
        continue;
      }
      if (!ref.isAbsolute()) {
        throw new IllegalArgumentException("String_Node_Str");
      }
      TreeReference predicateContext=ref.getSubReference(i);
      for (      XPathExpression predicate : predicates) {
        getTriggers(predicate,v,predicateContext);
      }
    }
  }
 else   if (x instanceof XPathBinaryOpExpr) {
    getTriggers(((XPathBinaryOpExpr)x).a,v,contextRef);
    getTriggers(((XPathBinaryOpExpr)x).b,v,contextRef);
  }
 else   if (x instanceof XPathUnaryOpExpr) {
    getTriggers(((XPathUnaryOpExpr)x).a,v,contextRef);
  }
 else   if (x instanceof XPathFuncExpr) {
    XPathFuncExpr fx=(XPathFuncExpr)x;
    for (int i=0; i < fx.args.length; i++)     getTriggers(fx.args[i],v,contextRef);
  }
}
Program: 144943
Project: 144943
Buggy source:
public void contextualization(){
  TreeReference abc=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference ab=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference floatc=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference floatc2=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference testabc=floatc.contextualize(ab);
  TreeReference testabc2=floatc2.contextualize(ab);
  TreeReference invalid=floatc.contextualize(floatc2);
  if (!abc.equals(testabc)) {
    fail("String_Node_Str" + abc.toString(true) + "String_Node_Str"+ testabc.toString(true));
  }
  if (!abc.equals(testabc2)) {
    fail("String_Node_Str" + abc.toString(true) + "String_Node_Str"+ testabc2.toString(true));
  }
  if (invalid != null) {
    fail("String_Node_Str" + invalid.toString(true));
  }
}

Fixed version (ground truth):
public void contextualization(){
  TreeReference abc=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference ab=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference ac=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference floatc=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference floatc2=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference backc=XPathReference.getPathExpr("String_Node_Str").getReference();
  TreeReference testabc=floatc.contextualize(ab);
  TreeReference testabc2=floatc2.contextualize(ab);
  TreeReference testac=backc.contextualize(ab);
  TreeReference invalid=floatc.contextualize(floatc2);
  if (!abc.equals(testabc)) {
    fail("String_Node_Str" + abc.toString(true) + "String_Node_Str"+ testabc.toString(true));
  }
  if (!abc.equals(testabc2)) {
    fail("String_Node_Str" + abc.toString(true) + "String_Node_Str"+ testabc2.toString(true));
  }
  if (!ac.equals(testac)) {
    fail("String_Node_Str" + ac.toString(true) + "String_Node_Str"+ testac.toString(true));
  }
  if (invalid != null) {
    fail("String_Node_Str" + invalid.toString(true));
  }
}
Program: 144944
Project: 144944
Buggy source:
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault() - 1;
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault();
  if (sortField != -1) {
    sortField--;
  }
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}
Program: 144946
Project: 144946
Buggy source:
public void refreshView(){
  if (model.getEvent() == FormEntryController.EVENT_QUESTION) {
    FormEntryPrompt prompt=model.getQuestionPrompt();
    SingleQuestionScreen last=currentQuestionScreen;
    SingleQuestionScreen view=getView(prompt,this.goingForward);
    if (last != null && last != currentQuestionScreen) {
      last.releaseMedia();
    }
    J2MEDisplay.setView(view);
  }
 else   if (model.getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {
    FormEntryCaption[] hierachy=model.getCaptionHierarchy(model.getFormIndex());
    repeatScreen=new NewRepeatScreen("String_Node_Str" + (model.getFormIndex().getElementMultiplicity() == 0 ? "String_Node_Str" : "String_Node_Str") + hierachy[hierachy.length - 1].getLongText()+ "String_Node_Str");
    repeatScreen.setCommandListener(this);
    if (currentQuestionScreen != null) {
      currentQuestionScreen.releaseMedia();
    }
    J2MEDisplay.setView(repeatScreen);
  }
}

Fixed version (ground truth):
public void refreshView(){
  if (model.getEvent() == FormEntryController.EVENT_QUESTION) {
    FormEntryPrompt prompt=model.getQuestionPrompt();
    SingleQuestionScreen last=currentQuestionScreen;
    SingleQuestionScreen view=getView(prompt,this.goingForward);
    if (last != null && last != currentQuestionScreen) {
      last.releaseMedia();
    }
    J2MEDisplay.setView(view);
    view.showNotify();
  }
 else   if (model.getEvent() == FormEntryController.EVENT_PROMPT_NEW_REPEAT) {
    FormEntryCaption[] hierachy=model.getCaptionHierarchy(model.getFormIndex());
    repeatScreen=new NewRepeatScreen("String_Node_Str" + (model.getFormIndex().getElementMultiplicity() == 0 ? "String_Node_Str" : "String_Node_Str") + hierachy[hierachy.length - 1].getLongText()+ "String_Node_Str");
    repeatScreen.setCommandListener(this);
    if (currentQuestionScreen != null) {
      currentQuestionScreen.releaseMedia();
    }
    J2MEDisplay.setView(repeatScreen);
  }
}
Program: 144949
Project: 144949
Buggy source:
public TreeElementCache(int capacity){
  cache=new Hashtable<Integer,TreeElement>();
  this.capacityDesired=capacity;
  this.currentCapacity=capacityDesired;
  random=new Random();
  cacheList=new Vector<Integer>();
  totalMem=Runtime.getRuntime().freeMemory();
}

Fixed version (ground truth):
public TreeElementCache(int capacity){
  cache=new Hashtable<Integer,TreeElement>();
  this.capacityDesired=capacity;
  this.currentCapacity=capacityDesired;
  random=new Random();
  cacheList=new Vector<Integer>();
  Runtime.getRuntime().gc();
  totalMem=Runtime.getRuntime().freeMemory();
}
Program: 144950
Project: 144950
Buggy source:
public void register(int recordId,TreeElement item){
  long freeMemory=Runtime.getRuntime().freeMemory();
  double memory=freeMemory * 1.0 / totalMem;
  if (memory < .2) {
    Runtime.getRuntime().gc();
    freeMemory=Runtime.getRuntime().freeMemory();
    memory=freeMemory * 1.0 / totalMem;
  }
  if (memory < .2) {
    currentCapacity=Math.max(10,(int)(currentCapacity * .6));
    System.out.println("String_Node_Str" + currentCapacity);
    while (cache.size() > currentCapacity - 1) {
      randomPop();
    }
  }
  if (cache.size() == currentCapacity) {
    if (currentCapacity < capacityDesired && memory > .3) {
      currentCapacity+=(capacityDesired - currentCapacity) * .3;
      System.out.println("String_Node_Str" + currentCapacity);
    }
 else {
      for (int i=0; i < 3; ++i) {
        randomPop();
      }
    }
  }
  cache.put(new Integer(recordId),item);
  cacheList.addElement(new Integer(recordId));
}

Fixed version (ground truth):
public void register(int recordId,TreeElement item){
  long freeMemory=Runtime.getRuntime().freeMemory();
  double memory=freeMemory * 1.0 / totalMem;
  if (memory < .2) {
    Runtime.getRuntime().gc();
    freeMemory=Runtime.getRuntime().freeMemory();
    memory=freeMemory * 1.0 / totalMem;
  }
  if (memory < .2) {
    currentCapacity=Math.max(10,(int)(currentCapacity * .6));
    System.out.println("String_Node_Str" + currentCapacity);
    while (cache.size() > currentCapacity - 1) {
      randomPop();
    }
  }
  if (cache.size() == currentCapacity) {
    if (currentCapacity < capacityDesired && memory > .3) {
      currentCapacity++;
      System.out.println("String_Node_Str" + currentCapacity);
    }
 else {
      for (int i=0; i < 3; ++i) {
        randomPop();
      }
    }
  }
  cache.put(new Integer(recordId),item);
  cacheList.addElement(new Integer(recordId));
}
Program: 144951
Project: 144951
Buggy source:
/** 
 * meant to be called after deserialization and initialization of handlers
 * @param newInstance true if the form is to be used for a new entry interaction, false if it is using an existing IDataModel
 */
public void initialize(boolean newInstance,InstanceInitializationFactory factory){
  for (Enumeration en=formInstances.keys(); en.hasMoreElements(); ) {
    String instanceId=(String)en.nextElement();
    DataInstance instance=formInstances.get(instanceId);
    instance.initialize(factory,instanceId);
  }
  if (newInstance) {
    preloadInstance(mainInstance.getRoot());
  }
  if (getLocalizer() != null && getLocalizer().getLocale() == null) {
    getLocalizer().setToDefault();
  }
  initializeTriggerables();
  dispatchFormEvent(Action.EVENT_XFORMS_READY);
}

Fixed version (ground truth):
/** 
 * meant to be called after deserialization and initialization of handlers
 * @param newInstance true if the form is to be used for a new entry interaction, false if it is using an existing IDataModel
 */
public void initialize(boolean newInstance,InstanceInitializationFactory factory){
  for (Enumeration en=formInstances.keys(); en.hasMoreElements(); ) {
    String instanceId=(String)en.nextElement();
    DataInstance instance=formInstances.get(instanceId);
    instance.initialize(factory,instanceId);
  }
  if (newInstance) {
    preloadInstance(mainInstance.getRoot());
  }
  if (getLocalizer() != null && getLocalizer().getLocale() == null) {
    getLocalizer().setToDefault();
  }
  dispatchFormEvent(Action.EVENT_XFORMS_READY);
  initializeTriggerables();
}
Program: 144953
Project: 144953
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (aval == sentinal || bval == sentinal) {
    throw new UnpivotableExpressionException();
  }
  if (aval == null || bval == null) {
    return null;
  }
  return this.eval(model,evalContext);
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (aval == sentinal || bval == sentinal) {
    throw new UnpivotableExpressionException();
  }
  if (aval == null || bval == null) {
    return null;
  }
  return this.eval(model,evalContext);
}
Program: 144954
Project: 144954
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (handled(aval,bval,sentinal,pivots) || handled(bval,aval,sentinal,pivots)) {
    return null;
  }
  return this.eval(model,evalContext);
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  Object aval=a.pivot(model,evalContext,pivots,sentinal);
  Object bval=b.pivot(model,evalContext,pivots,sentinal);
  if (handled(aval,bval,sentinal,pivots) || handled(bval,aval,sentinal,pivots)) {
    return null;
  }
  return this.eval(model,evalContext);
}
Program: 144955
Project: 144955
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  throw new UnpivotableExpressionException();
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  throw new UnpivotableExpressionException();
}
Program: 144956
Project: 144956
Buggy source:
/** 
 */
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  String name=id.toString();
  Object[] argVals=new Object[args.length];
  String[] identities=new String[]{"String_Node_Str"};
  boolean id=false;
  for (  String identity : identities) {
    if (identity.equals(name)) {
      id=true;
    }
  }
  for (int i=0; i < args.length; i++) {
    argVals[i]=args[i].pivot(model,evalContext,pivots,sentinal);
  }
  boolean pivoted=false;
  for (int i=0; i < argVals.length; ++i) {
    if (argVals[i] == null) {
      pivoted=true;
    }
 else     if (sentinal.equals(argVals[i])) {
      if (id) {
        return sentinal;
      }
 else {
        throw new UnpivotableExpressionException();
      }
    }
  }
  if (pivoted) {
    if (id) {
      return null;
    }
 else {
      throw new UnpivotableExpressionException();
    }
  }
  return eval(model,evalContext);
}

Fixed version (ground truth):
/** 
 */
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  String name=id.toString();
  Object[] argVals=new Object[args.length];
  String[] identities=new String[]{"String_Node_Str"};
  boolean id=false;
  for (  String identity : identities) {
    if (identity.equals(name)) {
      id=true;
    }
  }
  for (int i=0; i < args.length; i++) {
    argVals[i]=args[i].pivot(model,evalContext,pivots,sentinal);
  }
  boolean pivoted=false;
  for (int i=0; i < argVals.length; ++i) {
    if (argVals[i] == null) {
      pivoted=true;
    }
 else     if (sentinal.equals(argVals[i])) {
      if (id) {
        return sentinal;
      }
 else {
        throw new UnpivotableExpressionException();
      }
    }
  }
  if (pivoted) {
    if (id) {
      return null;
    }
 else {
      throw new UnpivotableExpressionException();
    }
  }
  return eval(model,evalContext);
}
Program: 144957
Project: 144957
Buggy source:
public Object pivot(FormInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  TreeReference ref=this.getReference();
  if (ref.equals(sentinal) || (ref.getRefLevel() == 0)) {
    return sentinal;
  }
 else {
    return this.eval(model,evalContext);
  }
}

Fixed version (ground truth):
public Object pivot(DataInstance model,EvaluationContext evalContext,Vector<Object> pivots,Object sentinal) throws UnpivotableExpressionException {
  TreeReference ref=this.getReference();
  if (ref.equals(sentinal) || (ref.getRefLevel() == 0)) {
    return sentinal;
  }
 else {
    return this.eval(model,evalContext);
  }
}
Program: 144958
Project: 144958
Buggy source:
private Vector<String> roots(){
  if (fileroots == null) {
    fileroots=new Vector<String>();
    try {
      for (Enumeration en=FileSystemRegistry.listRoots(); en.hasMoreElements(); ) {
        String root=(String)en.nextElement();
        if (root.endsWith("String_Node_Str")) {
          root=root.substring(0,root.length() - 1);
          fileroots.addElement(root);
        }
      }
    }
 catch (    SecurityException e) {
      this.securityException(e);
      if (fileroots.size() > 0) {
        return fileroots;
      }
 else {
        fileroots=null;
        return new Vector<String>();
      }
    }
  }
  return fileroots;
}

Fixed version (ground truth):
private Vector<String> roots(){
  if (fileroots == null) {
    fileroots=new Vector<String>();
    try {
      for (Enumeration en=FileSystemRegistry.listRoots(); en.hasMoreElements(); ) {
        String root=(String)en.nextElement();
        if (root.endsWith("String_Node_Str")) {
          root=root.substring(0,root.length() - 1);
          fileroots.addElement(root);
        }
      }
    }
 catch (    SecurityException e) {
      this.securityException(e);
      if (fileroots.size() > 0) {
        return fileroots;
      }
 else {
        fileroots=null;
        return new Vector<String>();
      }
    }
catch (    NullPointerException npe) {
      return new Vector<String>();
    }
  }
  return fileroots;
}
Program: 144959
Project: 144959
Buggy source:
public static Alert showError(String title,String message,Image image,Displayable next,CommandListener customListener){
  final Alert alert=new Alert(title,message,image,AlertType.ERROR){
    int latches=0;
{
      getKeyStates();
    }
    protected boolean handleKeyPressed(    int keyCode,    int gameAction){
      return super.handleKeyPressed(keyCode,gameAction);
    }
    protected boolean handleKeyReleased(    int keyCode,    int gameAction){
      if (this.getKeyStates() > 0) {
        return super.handleKeyReleased(keyCode,gameAction);
      }
      return true;
    }
  }
;
  alert.setTimeout(Alert.FOREVER);
  if (customListener != null) {
    if (next != null) {
      System.err.println("String_Node_Str");
    }
    alert.setCommandListener(customListener);
  }
  if (next == null) {
    setView(alert);
  }
 else {
    loading.cancelLoading();
  }
  return alert;
}

Fixed version (ground truth):
public static Alert showError(String title,String message,Image image,Displayable next,CommandListener customListener){
  final Alert alert=new Alert(title,message,image,AlertType.ERROR){
    int latches=0;
{
      getKeyStates();
    }
    protected boolean handleKeyPressed(    int keyCode,    int gameAction){
      return super.handleKeyPressed(keyCode,gameAction);
    }
    protected boolean handleKeyReleased(    int keyCode,    int gameAction){
      if (this.getKeyStates() > 0) {
        return super.handleKeyReleased(keyCode,gameAction);
      }
      return true;
    }
  }
;
  alert.setTimeout(Alert.FOREVER);
  if (customListener != null) {
    if (next != null) {
      System.err.println("String_Node_Str");
    }
    alert.setCommandListener(customListener);
  }
  if (next == null) {
    setView(alert,true);
  }
 else {
    loading.cancelLoading();
  }
  return alert;
}
Program: 144960
Project: 144960
Buggy source:
public static void setView(Displayable d){
  loading.cancelLoading();
  Displayable old=display.getCurrent();
  display.setCurrent(d);
  if (old instanceof Screen) {
    try {
      old.addCommand(new Command("String_Node_Str",2,2));
      UiAccess.releaseResources((Screen)old);
    }
 catch (    Exception e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
/** 
 * Sets the current displayable with the option to either clear or not clear the heavy resources from the current view 
 * @param d The new displayable to be viewed
 * @param savePreviousView false if resources should freed from thecurrent screen. True if those resources should be maintained. NOTE: if the current screen has major resources and True is set, those resources might need to be freed manually if any hanging references depend on them.
 */
public static void setView(Displayable d,boolean savePreviousView){
  loading.cancelLoading();
  Displayable old=display.getCurrent();
  display.setCurrent(d);
  if (!savePreviousView) {
    if (old instanceof Screen) {
      try {
        Command placeholder=new Command("String_Node_Str",2,2);
        old.addCommand(placeholder);
        UiAccess.releaseResources((Screen)old);
        old.removeCommand(placeholder);
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
    }
  }
}
Program: 144961
Project: 144961
Buggy source:
public String[] getSortFields(){
  String[] names=getSortFieldNames();
  String[] ret=new String[names.length];
  int defaultSort=getSortFieldDefault();
  if (defaultSort != -1) {
    ret[0]=String.valueOf(defaultSort);
    ret[1]="String_Node_Str";
  }
 else {
    ret[0]="String_Node_Str";
  }
  for (int i=1; i < ret.length; ++i) {
    if (defaultSort != i) {
      ret[i]=String.valueOf(i);
    }
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFields(){
  String[] names=getSortFieldNames();
  String[] ret=new String[names.length];
  int defaultSort=getSortFieldDefault();
  if (defaultSort != -1) {
    ret[0]=String.valueOf(defaultSort);
    ret[1]="String_Node_Str";
  }
 else {
    ret[0]="String_Node_Str";
  }
  int position=defaultSort == -1 ? 1 : 2;
  for (int i=1; i < ret.length; ++i) {
    if (defaultSort != i) {
      ret[position]=String.valueOf(i);
      position++;
    }
  }
  return ret;
}
Program: 144962
Project: 144962
Buggy source:
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  for (  String s : getHeaders(false)) {
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}

Fixed version (ground truth):
public String[] getSortFieldNames(){
  Vector<String> fields=new Vector<String>();
  int sortField=this.getSortFieldDefault() - 1;
  String[] headers=getHeaders(false);
  if (sortField == -1) {
    fields.addElement(Localization.get("String_Node_Str"));
  }
 else {
    fields.addElement(headers[sortField]);
    fields.addElement(Localization.get("String_Node_Str"));
  }
  for (int i=0; i < headers.length; ++i) {
    if (i == sortField) {
      continue;
    }
    String s=headers[i];
    if (s == null || "String_Node_Str".equals(s)) {
      continue;
    }
    fields.addElement(s);
  }
  String[] ret=new String[fields.size()];
  for (int i=0; i < ret.length; ++i) {
    ret[i]=fields.elementAt(i);
  }
  return ret;
}
Program: 144963
Project: 144963
Buggy source:
private int getSortFieldDefault(){
  int topIndex=shortDetail.getDefaultSort();
  if (topIndex == -1) {
    return -1;
  }
  int index=-1;
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  String[] headers=getHeaders(false);
  for (int i=0; i < headers.length; ++i) {
    if (i == topIndex) {
      return fields.size();
    }
  }
  return -1;
}

Fixed version (ground truth):
private int getSortFieldDefault(){
  int topIndex=shortDetail.getDefaultSort();
  if (topIndex == -1) {
    return -1;
  }
  int index=-1;
  Vector<String> fields=new Vector<String>();
  fields.addElement(Localization.get("String_Node_Str"));
  String[] headers=getHeaders(false);
  for (int i=0; i < headers.length; ++i) {
    fields.addElement(headers[i]);
    if (i == topIndex) {
      return fields.size() - 1;
    }
  }
  return -1;
}