nus-yam/ex-repair huggingface dataset:
Program: 24764
Project: 24764
Buggy source:
/** 
 * Does the work of creating the guts of a keyword query.
 */
private Query createMultiFieldQuery(EasyNode parent,String[] fields,SpanQuery[] spanQueries,int slop,int maxMetaSnippets,int maxTextSnippets){
  BooleanQuery mainQuery=new BooleanQuery();
  RefieldingQueryRewriter refielder=new RefieldingQueryRewriter();
  if (parent.name().equals("String_Node_Str")) {
    for (int i=0; i < spanQueries.length; i++) {
      BooleanQuery termOrQuery=new BooleanQuery();
      for (int j=0; j < fields.length; j++) {
        Query tq=refielder.refield(spanQueries[i],fields[j]);
        termOrQuery.add(deChunk(tq),false,false);
      }
      termOrQuery.setBoost(0.0f);
      mainQuery.add(termOrQuery,true,false);
    }
  }
  for (int i=0; i < fields.length; i++) {
    SpanQuery[] termQueries=new SpanQuery[spanQueries.length];
    for (int j=0; j < spanQueries.length; j++)     termQueries[j]=(SpanQuery)refielder.refield(spanQueries[j],fields[i]);
    SpanQuery fieldOrQuery=(SpanQuery)deChunk(new SpanOrNearQuery(termQueries,slop,true));
    int maxSnippets=(fields[i].equals("String_Node_Str")) ? maxTextSnippets : maxMetaSnippets;
    fieldOrQuery.setSpanRecording(maxSnippets);
    mainQuery.add(fieldOrQuery,false,false);
  }
  return simplifyBooleanQuery(mainQuery);
}

Fixed version (ground truth):
/** 
 * Does the work of creating the guts of a keyword query.
 */
private Query createMultiFieldQuery(EasyNode parent,String[] fields,SpanQuery[] spanQueries,int slop,int maxMetaSnippets,int maxTextSnippets){
  BooleanQuery mainQuery=new BooleanQuery();
  RefieldingQueryRewriter refielder=new RefieldingQueryRewriter();
  if (parent.name().equals("String_Node_Str")) {
    for (int i=0; i < spanQueries.length; i++) {
      BooleanQuery termOrQuery=new BooleanQuery();
      for (int j=0; j < fields.length; j++) {
        Query tq=refielder.refield(spanQueries[i],fields[j]);
        tq=deChunk(tq);
        if (tq instanceof SpanQuery)         ((SpanQuery)tq).setSpanRecording(0);
        termOrQuery.add(tq,false,false);
      }
      termOrQuery.setBoost(0.0f);
      mainQuery.add(termOrQuery,true,false);
    }
  }
  for (int i=0; i < fields.length; i++) {
    SpanQuery[] termQueries=new SpanQuery[spanQueries.length];
    for (int j=0; j < spanQueries.length; j++)     termQueries[j]=(SpanQuery)refielder.refield(spanQueries[j],fields[i]);
    SpanQuery fieldOrQuery=(SpanQuery)deChunk(new SpanOrNearQuery(termQueries,slop,true));
    int maxSnippets=(fields[i].equals("String_Node_Str")) ? maxTextSnippets : maxMetaSnippets;
    fieldOrQuery.setSpanRecording(maxSnippets);
    mainQuery.add(fieldOrQuery,false,false);
  }
  return simplifyBooleanQuery(mainQuery);
}
Program: 24767
Project: 24767
Buggy source:
private boolean nextCell(){
  if ((matchEndCell + 1) == cells.size())   return false;
  SpansCell prevCell=(SpansCell)cells.get(matchEndCell);
  SpansCell curCell=(SpansCell)cells.get(matchEndCell + 1);
  if (curCell.doc() != prevCell.doc())   return false;
  if (penalizeOutOfOrder && curCell.index < prevCell.index + 1)   matchDist+=curCell.end() - prevCell.start();
 else   matchDist+=curCell.start() - prevCell.end();
  if (matchDist > slop)   return false;
  matchTotalScore+=curCell.score();
  ++matchEndCell;
  return true;
}

Fixed version (ground truth):
private boolean nextCell(){
}
Program: 24768
Project: 24768
Buggy source:
private boolean advance(int skipTo) throws IOException {
  SpansCell cell=(SpansCell)cells.get(0);
  boolean cellMore=(skipTo >= 0) ? cell.skipTo(skipTo) : cell.next();
  if (cellMore) {
    int i;
    for (i=0; i < cells.size() - 1; i++) {
      SpansCell next=(SpansCell)cells.get(i + 1);
      if (cell.compareTo(next) < 0)       break;
      cells.set(i,next);
    }
    cells.set(i,cell);
  }
 else {
    cells.remove(0);
    if (cells.isEmpty())     return false;
  }
  matchEndCell=0;
  matchTotalScore=((SpansCell)cells.get(0)).score();
  matchDist=0;
  return true;
}

Fixed version (ground truth):
private boolean advance(int skipTo) throws IOException {
  SpansCell cell=(SpansCell)cells.get(0);
  boolean cellMore=(skipTo >= 0) ? cell.skipTo(skipTo) : cell.next();
  if (cellMore) {
    int i;
    for (i=0; i < cells.size() - 1; i++) {
      SpansCell next=(SpansCell)cells.get(i + 1);
      if (cell.compareTo(next) < 0)       break;
      cells.set(i,next);
    }
    cells.set(i,cell);
  }
 else {
    cells.remove(0);
    if (cells.isEmpty())     return false;
  }
  matchEndCell=0;
  matchNumCells=0;
  matchTotalScore=((SpansCell)cells.get(0)).score();
  matchDist=0;
  return true;
}
Program: 24769
Project: 24769
Buggy source:
public float score(){
  float coordFactor=(float)(matchEndCell + 1) / (nClauses + 1);
  float distFactor=similarity.sloppyFreq(matchDist) / (nClauses + 1);
  return matchTotalScore * (coordFactor + distFactor) * query.getBoost();
}

Fixed version (ground truth):
public float score(){
  float coordFactor=(float)(matchNumCells + 1) / (nClauses + 1);
  float distFactor=similarity.sloppyFreq(matchDist) / (nClauses + 1);
  return matchTotalScore * (coordFactor + distFactor) * query.getBoost();
}
Program: 24770
Project: 24770
Buggy source:
private boolean initCells(int skipTo) throws IOException {
  for (int i=0; i < cells.size(); i++) {
    SpansCell cell=(SpansCell)cells.get(i);
    boolean cellMore=(skipTo >= 0) ? cell.skipTo(skipTo) : cell.next();
    if (!cellMore) {
      cells.remove(i);
      --i;
    }
  }
  Collections.sort(cells,cellComparator);
  if (cells.isEmpty())   return false;
  matchEndCell=0;
  matchTotalScore=((SpansCell)cells.get(0)).score();
  matchDist=0;
  return true;
}

Fixed version (ground truth):
private boolean initCells(int skipTo) throws IOException {
  for (int i=0; i < cells.size(); i++) {
    SpansCell cell=(SpansCell)cells.get(i);
    boolean cellMore=(skipTo >= 0) ? cell.skipTo(skipTo) : cell.next();
    if (!cellMore) {
      cells.remove(i);
      --i;
    }
  }
  Collections.sort(cells,cellComparator);
  if (cells.isEmpty())   return false;
  matchEndCell=0;
  matchNumCells=0;
  matchTotalScore=((SpansCell)cells.get(0)).score();
  matchDist=0;
  return true;
}
Program: 24771
Project: 24771
Buggy source:
/** 
 * Ensures that there is space to insert 'n' items, expanding the queue if necessary.
 */
public final void ensureCapacity(int n){
  if (size + n <= maxSize)   return;
  int oldSize=size;
  Object[] oldHeap=heap;
  int newSize=Math.max(maxSize + 10,maxSize * 3 / 2);
  initialize(newSize);
  for (int i=0; i < oldSize; i++)   put(oldHeap[i]);
}

Fixed version (ground truth):
/** 
 * Ensures that there is space to insert 'n' items, expanding the queue if necessary.
 */
public final void ensureCapacity(int n){
  if (size + n <= maxSize)   return;
  int oldSize=size;
  Object[] oldHeap=heap;
  int newSize=Math.max(maxSize + 10,maxSize * 3 / 2);
  initialize(newSize);
  for (int i=0; i < oldSize; i++) {
    if (oldHeap[i] != null)     put(oldHeap[i]);
  }
}
Program: 24772
Project: 24772
Buggy source:
/** 
 * Search for a StructuredStore containing the "lazy" or persistent representation of a given document. Index parameters are specified, since often the lazy file is stored along with the index. This method is called first, and if it returns null, then   {@link #getInputSource(String,boolean)} will be called as a fall-back.
 * @param indexConfigPath Path to the index configuration file
 * @param indexName       Name of the index being searched
 * @param sourcePath      Path to the source document
 * @param preFilter       Prefilter stylesheet to run (or null for none)
 * @param removeDoctypeDecl Set to true to remove DOCTYPE declaration fromthe XML document.
 * @return                Store containing the tree, or null if nonecould be found.
 */
public StructuredStore getLazyStore(String indexConfigPath,String indexName,String sourcePath,Templates preFilter,boolean removeDoctypeDecl) throws IOException {
  boolean useLazy=true;
  if (indexConfigPath == null || indexName == null)   return null;
  if (sourcePath.startsWith("String_Node_Str"))   return null;
  if (sourcePath.startsWith("String_Node_Str"))   return null;
  File lazyFile=null;
  lazyFile=IndexUtil.calcLazyPath(new File(servlet.getRealPath("String_Node_Str")),new File(indexConfigPath),indexName,new File(sourcePath),false);
  if (!lazyFile.canRead())   buildLazyStore(lazyFile,sourcePath,preFilter,removeDoctypeDecl);
  return StructuredFile.open(lazyFile);
}

Fixed version (ground truth):
/** 
 * Search for a StructuredStore containing the "lazy" or persistent representation of a given document. Index parameters are specified, since often the lazy file is stored along with the index. This method is called first, and if it returns null, then   {@link #getInputSource(String,boolean)} will be called as a fall-back.
 * @param indexConfigPath Path to the index configuration file
 * @param indexName       Name of the index being searched
 * @param sourcePath      Path to the source document
 * @param preFilter       Prefilter stylesheet to run (or null for none)
 * @param removeDoctypeDecl Set to true to remove DOCTYPE declaration fromthe XML document.
 * @return                Store containing the tree, or null if nonecould be found.
 */
public StructuredStore getLazyStore(String indexConfigPath,String indexName,String sourcePath,Templates preFilter,boolean removeDoctypeDecl) throws IOException {
  boolean useLazy=true;
  if (indexConfigPath == null || indexName == null)   return null;
  if (sourcePath.startsWith("String_Node_Str"))   return null;
  if (sourcePath.startsWith("String_Node_Str"))   return null;
  File sourceFile=new File(sourcePath);
  if (!sourceFile.isFile())   return null;
  File lazyFile=IndexUtil.calcLazyPath(new File(servlet.getRealPath("String_Node_Str")),new File(indexConfigPath),indexName,new File(sourcePath),false);
  if (!lazyFile.canRead())   buildLazyStore(lazyFile,sourcePath,preFilter,removeDoctypeDecl);
  return StructuredFile.open(lazyFile);
}
Program: 24775
Project: 24775
Buggy source:
/** 
 * Construct the array of doc hits for the hit group. 
 */
private void buildDocHits(int group,ResultGroup resultGroup){
  PriorityQueue queue=hitQueue[group];
  int nFound=queue.size();
  DocHitImpl[] hitArray=new DocHitImpl[nFound];
  float maxDocScore=0.0f;
  for (int i=0; i < nFound; i++) {
    int index=nFound - i - 1;
    hitArray[index]=(DocHitImpl)queue.pop();
  }
  int start=startDoc[group];
  int max=maxDocs[group];
  int nHits=Math.min(nFound - start,max);
  resultGroup.docHits=new DocHit[nHits];
  resultGroup.totalDocs=count[group];
  resultGroup.startDoc=start;
  resultGroup.endDoc=start + nHits;
  for (int i=startDoc[group]; i < nFound; i++)   resultGroup.docHits[i - start]=hitArray[i];
}

Fixed version (ground truth):
/** 
 * Construct the array of doc hits for the hit group. 
 */
private void buildDocHits(int group,ResultGroup resultGroup){
  PriorityQueue queue=hitQueue[group];
  int nFound=queue.size();
  DocHitImpl[] hitArray=new DocHitImpl[nFound];
  float maxDocScore=0.0f;
  for (int i=0; i < nFound; i++) {
    int index=nFound - i - 1;
    hitArray[index]=(DocHitImpl)queue.pop();
  }
  int start=startDoc[group];
  int max=maxDocs[group];
  int nHits=Math.max(0,Math.min(nFound - start,max));
  resultGroup.docHits=new DocHit[nHits];
  resultGroup.totalDocs=count[group];
  resultGroup.startDoc=start;
  resultGroup.endDoc=start + nHits;
  for (int i=startDoc[group]; i < nFound; i++)   resultGroup.docHits[i - start]=hitArray[i];
}
Program: 24776
Project: 24776
Buggy source:
/** 
 * Generate a proximity query on a field. This uses the de-duplicating span system.
 * @param parent The element containing the field name and terms.
 */
Query makeProxQuery(EasyNode parent,int slop,String field,int maxSnippets) throws QueryGenException {
  Vector terms=new Vector();
  Vector notVec=new Vector();
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str")) {
      if (slop <= 0)       error("String_Node_Str");
      notVec.add(parseQuery(el,field,maxSnippets));
    }
 else {
      SpanQuery q;
      if (slop == 0) {
        Term t=parseTerm(el,field,"String_Node_Str");
        if (isWildcardTerm(t))         q=new XtfSpanWildcardQuery(t,req.termLimit);
 else         q=new SpanTermQuery(t);
        q.setSpanRecording(maxSnippets);
        terms.add(q);
      }
 else       terms.add(parseQuery(el,field,maxSnippets));
    }
  }
  if (terms.size() == 0)   error("String_Node_Str" + parent.name() + "String_Node_Str"+ "String_Node_Str");
  SpanQuery q;
  SpanQuery[] termQueries=(SpanQuery[])terms.toArray(new SpanQuery[terms.size()]);
  if (slop < 0)   q=new SpanExactQuery(termQueries);
 else   if (terms.size() == 1)   q=(SpanQuery)terms.elementAt(0);
 else   if (parent.name().equals("String_Node_Str"))   q=new SpanOrNearQuery(termQueries,slop,true);
 else   q=new SpanNearQuery(termQueries,slop,slop == 0);
  q.setSpanRecording(maxSnippets);
  return q;
}

Fixed version (ground truth):
/** 
 * Generate a proximity query on a field. This uses the de-duplicating span system.
 * @param parent The element containing the field name and terms.
 */
Query makeProxQuery(EasyNode parent,int slop,String field,int maxSnippets) throws QueryGenException {
  Vector terms=new Vector();
  Vector notVec=new Vector();
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str")) {
      if (parent.name().matches("String_Node_Str"))       error("String_Node_Str");
      notVec.add(parseQuery2(el,"String_Node_Str",field,maxSnippets));
    }
 else {
      SpanQuery q;
      if (slop == 0) {
        Term t=parseTerm(el,field,"String_Node_Str");
        if (isWildcardTerm(t))         q=new XtfSpanWildcardQuery(t,req.termLimit);
 else         q=new SpanTermQuery(t);
        q.setSpanRecording(maxSnippets);
        terms.add(q);
      }
 else       terms.add(parseQuery(el,field,maxSnippets));
    }
  }
  if (terms.size() == 0)   error("String_Node_Str" + parent.name() + "String_Node_Str"+ "String_Node_Str");
  SpanQuery q;
  SpanQuery[] termQueries=(SpanQuery[])terms.toArray(new SpanQuery[terms.size()]);
  if (slop < 0)   q=new SpanExactQuery(termQueries);
 else   if (terms.size() == 1)   q=(SpanQuery)terms.elementAt(0);
 else   if (parent.name().equals("String_Node_Str"))   q=new SpanOrNearQuery(termQueries,slop,true);
 else   q=new SpanNearQuery(termQueries,slop,slop == 0);
  q.setSpanRecording(maxSnippets);
  return processSpanNots(q,notVec,maxSnippets);
}
Program: 24777
Project: 24777
Buggy source:
protected boolean lessThan(Object a,Object b){
  QueryWord aa=(QueryWord)a;
  QueryWord bb=(QueryWord)b;
  return aa.score > bb.score;
}

Fixed version (ground truth):
protected boolean lessThan(Object a,Object b){
  QueryWord aa=(QueryWord)a;
  QueryWord bb=(QueryWord)b;
  return aa.score < bb.score;
}
Program: 24778
Project: 24778
Buggy source:
/** 
 * Create the More like query from a PriorityQueue
 */
private Query createQuery(PriorityQueue q){
  BooleanQuery query=new BooleanQuery();
  QueryWord qw;
  int qterms=0;
  float bestScore=0;
  while (((qw=(QueryWord)q.pop()) != null)) {
    TermQuery tq=new TermQuery(qw.term);
    if (boost) {
      if (qterms == 0)       bestScore=qw.score;
      tq.setBoost(qw.score / bestScore);
    }
    try {
      query.add(tq,false,false);
    }
 catch (    BooleanQuery.TooManyClauses ignore) {
      break;
    }
    qterms++;
  }
  return query;
}

Fixed version (ground truth):
/** 
 * Create the More like query from a PriorityQueue
 */
private Query createQuery(PriorityQueue q){
  QueryWord[] queryWords=new QueryWord[q.size()];
  for (int i=q.size() - 1; i >= 0; i--)   queryWords[i]=(QueryWord)q.pop();
  BooleanQuery query=new BooleanQuery();
  QueryWord qw;
  for (int i=0; i < queryWords.length; i++) {
    qw=queryWords[i];
    TermQuery tq=new TermQuery(qw.term);
    if (boost)     tq.setBoost(qw.score);
    try {
      query.add(tq,false,false);
    }
 catch (    BooleanQuery.TooManyClauses ignore) {
      break;
    }
  }
  return query;
}
Program: 24779
Project: 24779
Buggy source:
public void processingInstruction(String target,String data) throws SAXException {
  incrementNode();
  if (lazyHandler != null)   lazyHandler.processingInstruction(target,data);
}

Fixed version (ground truth):
public void processingInstruction(String target,String data) throws SAXException {
}
Program: 24783
Project: 24783
Buggy source:
/** 
 * Generate a proximity query on a field. This uses the de-duplicating span system.
 * @param parent The element containing the field name and terms.
 */
Query makeProxQuery(EasyNode parent,int slop,String field,int maxSnippets) throws QueryGenException {
  Vector terms=new Vector();
  Vector notVec=new Vector();
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str")) {
      if (slop <= 0)       error("String_Node_Str");
      notVec.add(parseQuery(el,field,maxSnippets));
    }
 else {
      SpanQuery q;
      if (slop == 0) {
        Term t=parseTerm(el,field,"String_Node_Str");
        if (isWildcardTerm(t))         q=new BigramSpanWildcardQuery(t,req.termLimit);
 else         q=new SpanTermQuery(t);
        q.setSpanRecording(maxSnippets);
        terms.add(q);
      }
 else       terms.add(parseQuery(el,field,maxSnippets));
    }
  }
  if (terms.size() == 0)   error("String_Node_Str" + parent.name() + "String_Node_Str"+ "String_Node_Str");
  SpanQuery q;
  SpanQuery[] termQueries=(SpanQuery[])terms.toArray(new SpanQuery[terms.size()]);
  if (slop < 0)   q=new SpanExactQuery(termQueries);
 else   if (terms.size() == 1)   q=(SpanQuery)terms.elementAt(0);
 else   q=new SpanNearQuery(termQueries,slop,slop == 0);
  q.setSpanRecording(maxSnippets);
  return q;
}

Fixed version (ground truth):
/** 
 * Generate a proximity query on a field. This uses the de-duplicating span system.
 * @param parent The element containing the field name and terms.
 */
Query makeProxQuery(EasyNode parent,int slop,String field,int maxSnippets) throws QueryGenException {
  Vector terms=new Vector();
  Vector notVec=new Vector();
  for (int i=0; i < parent.nChildren(); i++) {
    EasyNode el=parent.child(i);
    if (!el.isElement())     continue;
    if (el.name().equals("String_Node_Str")) {
      if (slop <= 0)       error("String_Node_Str");
      notVec.add(parseQuery(el,field,maxSnippets));
    }
 else {
      SpanQuery q;
      if (slop == 0) {
        Term t=parseTerm(el,field,"String_Node_Str");
        if (isWildcardTerm(t))         q=new XtfSpanWildcardQuery(t,req.termLimit);
 else         q=new SpanTermQuery(t);
        q.setSpanRecording(maxSnippets);
        terms.add(q);
      }
 else       terms.add(parseQuery(el,field,maxSnippets));
    }
  }
  if (terms.size() == 0)   error("String_Node_Str" + parent.name() + "String_Node_Str"+ "String_Node_Str");
  SpanQuery q;
  SpanQuery[] termQueries=(SpanQuery[])terms.toArray(new SpanQuery[terms.size()]);
  if (slop < 0)   q=new SpanExactQuery(termQueries);
 else   if (terms.size() == 1)   q=(SpanQuery)terms.elementAt(0);
 else   q=new SpanNearQuery(termQueries,slop,slop == 0);
  q.setSpanRecording(maxSnippets);
  return q;
}
Program: 24784
Project: 24784
Buggy source:
public String encodeUrl(String url){
}

Fixed version (ground truth):
public String encodeUrl(String url){
  return url;
}
Program: 24785
Project: 24785
Buggy source:
public String encodeURL(String url){
}

Fixed version (ground truth):
public String encodeURL(String url){
  return url;
}
Program: 24786
Project: 24786
Buggy source:
public String encodeRedirectUrl(String url){
}

Fixed version (ground truth):
public String encodeRedirectUrl(String url){
  return url;
}
Program: 24787
Project: 24787
Buggy source:
public String encodeRedirectURL(String url){
}

Fixed version (ground truth):
public String encodeRedirectURL(String url){
  return url;
}
Program: 24788
Project: 24788
Buggy source:
/** 
 * Makes a Saxon Receiver that will transparently add a session IDs to URLs if they match the servlet URL, or other patterns configured  in the conf file.
 * @param trans   The transformer that will do the work
 * @param req     The servlet request being processed
 * @param res     The servlet response to output to
 * @return        A Receiver suitable for the target of the transform
 */
public Receiver createFilteredReceiver(Transformer trans,HttpServletRequest req,HttpServletResponse res) throws XPathException, IOException {
  StreamResult stream=new StreamResult(res.getOutputStream());
  Receiver target=ResultWrapper.getReceiver(stream,((Controller)trans).makePipelineConfiguration(),trans.getOutputProperties());
  return new SessionURLRewriter(target,req,res);
}

Fixed version (ground truth):
/** 
 * Makes a Saxon Receiver that will transparently add a session IDs to URLs if they match the servlet URL, or other patterns configured  in the conf file.
 * @param trans   The transformer that will do the work
 * @param req     The servlet request being processed
 * @param res     The servlet response to output to
 * @return        A Receiver suitable for the target of the transform
 */
public Receiver createFilteredReceiver(Transformer trans,HttpServletRequest req,HttpServletResponse res) throws XPathException, IOException {
  StreamResult stream=new StreamResult(res.getOutputStream());
  Receiver target=ResultWrapper.getReceiver(stream,((Controller)trans).makePipelineConfiguration(),trans.getOutputProperties());
  if (getConfig().trackSessions)   return new SessionURLRewriter(target,req,res);
 else   return target;
}
Program: 24789
Project: 24789
Buggy source:
public boolean isRequestedSessionIdFromUrl(){
}

Fixed version (ground truth):
public boolean isRequestedSessionIdFromUrl(){
  return false;
}
Program: 24790
Project: 24790
Buggy source:
public boolean isRequestedSessionIdFromURL(){
}

Fixed version (ground truth):
public boolean isRequestedSessionIdFromURL(){
  return false;
}
Program: 24791
Project: 24791
Buggy source:
public boolean isRequestedSessionIdValid(){
}

Fixed version (ground truth):
public boolean isRequestedSessionIdValid(){
  return false;
}
Program: 24792
Project: 24792
Buggy source:
public boolean isRequestedSessionIdFromCookie(){
}

Fixed version (ground truth):
public boolean isRequestedSessionIdFromCookie(){
  return false;
}
Program: 24793
Project: 24793
Buggy source:
public HttpSession getSession(boolean create){
}

Fixed version (ground truth):
public HttpSession getSession(boolean create){
  if (create)   throw new RuntimeException("String_Node_Str");
  return null;
}
Program: 24794
Project: 24794
Buggy source:
public ParseException generateParseException(){
  jj_expentries.removeAllElements();
  boolean[] la1tokens=new boolean[18];
  for (int i=0; i < 18; i++) {
    la1tokens[i]=false;
  }
  if (jj_kind >= 0) {
    la1tokens[jj_kind]=true;
    jj_kind=-1;
  }
  for (int i=0; i < 1; i++) {
    if (jj_la1[i] == jj_gen) {
      for (int j=0; j < 32; j++) {
        if ((jj_la1_0[i] & (1 << j)) != 0) {
          la1tokens[j]=true;
        }
      }
    }
  }
  for (int i=0; i < 18; i++) {
    if (la1tokens[i]) {
      jj_expentry=new int[1];
      jj_expentry[0]=i;
      jj_expentries.addElement(jj_expentry);
    }
  }
  int[][] exptokseq=new int[jj_expentries.size()][];
  for (int i=0; i < jj_expentries.size(); i++) {
    exptokseq[i]=(int[])jj_expentries.elementAt(i);
  }
  return new ParseException(token,exptokseq,tokenImage);
}

Fixed version (ground truth):
public ParseException generateParseException(){
  jj_expentries.removeAllElements();
  boolean[] la1tokens=new boolean[19];
  for (int i=0; i < 19; i++) {
    la1tokens[i]=false;
  }
  if (jj_kind >= 0) {
    la1tokens[jj_kind]=true;
    jj_kind=-1;
  }
  for (int i=0; i < 1; i++) {
    if (jj_la1[i] == jj_gen) {
      for (int j=0; j < 32; j++) {
        if ((jj_la1_0[i] & (1 << j)) != 0) {
          la1tokens[j]=true;
        }
      }
    }
  }
  for (int i=0; i < 19; i++) {
    if (la1tokens[i]) {
      jj_expentry=new int[1];
      jj_expentry[0]=i;
      jj_expentries.addElement(jj_expentry);
    }
  }
  int[][] exptokseq=new int[jj_expentries.size()][];
  for (int i=0; i < jj_expentries.size(); i++) {
    exptokseq[i]=(int[])jj_expentries.elementAt(i);
  }
  return new ParseException(token,exptokseq,tokenImage);
}
Program: 24796
Project: 24796
Buggy source:
final public GroupSelector rangeFilter() throws ParseException {
  Token t;
  int from;
  int to=999999999;
  t=jj_consume_token(NUMBER);
  from=Integer.parseInt(t.toString());
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case DASH:
    jj_consume_token(DASH);
  t=jj_consume_token(NUMBER);
to=Integer.parseInt(t.toString());
break;
default :
jj_la1[8]=jj_gen;
;
}
{
if (true) return new RangeSelector(from - 1,to - from + 1);
}
throw new Error("String_Node_Str");
}

Fixed version (ground truth):
final public GroupSelector rangeFilter() throws ParseException {
  Token t;
  int from;
  int to;
  t=jj_consume_token(NUMBER);
  from=to=Integer.parseInt(t.toString());
switch ((jj_ntk == -1) ? jj_ntk() : jj_ntk) {
case DASH:
    jj_consume_token(DASH);
  t=jj_consume_token(NUMBER);
to=Integer.parseInt(t.toString());
break;
default :
jj_la1[8]=jj_gen;
;
}
{
if (true) return new RangeSelector(from - 1,to - from + 1);
}
throw new Error("String_Node_Str");
}
Program: 24797
Project: 24797
Buggy source:
public boolean skipTo(int target) throws IOException {
  if (firstTime || target > spans.doc()) {
    more=spans.skipTo(target);
    firstTime=false;
  }
  return advance();
}

Fixed version (ground truth):
public boolean skipTo(int target) throws IOException {
  if (firstTime || (more && target > spans.doc())) {
    more=spans.skipTo(target);
    firstTime=false;
  }
  return advance();
}
Program: 24799
Project: 24799
Buggy source:
/** 
 * Create the appropriate node(s) for text within a snippet, including elements for any marked &lt;term&gt;s.
 * @param text Text to process, with " &lt;term&gt;" stuff inside it.
 * @param prev Node to add to
 * @param addAsChild true to add to prev as a child, else as sibling.
 * @return Last node added.
 */
private NodeImpl breakupText(String text,NodeImpl prev,boolean addAsChild){
  int startPos=0;
  while (true) {
    int markerPos=text.indexOf("String_Node_Str",startPos);
    if (markerPos < 0)     markerPos=text.length();
    String beforeText=text.substring(startPos,markerPos);
    prev=addText(prev,beforeText,addAsChild);
    addAsChild=false;
    if (markerPos == text.length())     break;
    int termStart=text.indexOf('>',markerPos) + 1;
    int markEnd=text.indexOf("String_Node_Str",markerPos);
    String termText=text.substring(termStart,markEnd);
    prev=addElement(prev,termElementCode,0,false);
    addText(prev,termText,true);
    startPos=text.indexOf('>',markEnd) + 1;
  }
  return prev;
}

Fixed version (ground truth):
/** 
 * Create the appropriate node(s) for text within a snippet, including elements for any marked &lt;term&gt;s.
 * @param text Text to process, with " &lt;term&gt;" stuff inside it.
 * @param prev Node to add to
 * @param addAsChild true to add to prev as a child, else as sibling.
 * @return Last node added.
 */
private NodeImpl breakupText(String text,NodeImpl prev,boolean addAsChild){
  int startPos=0;
  while (true) {
    int markerPos=text.indexOf("String_Node_Str",startPos);
    if (markerPos < 0)     markerPos=text.length();
    String beforeText=text.substring(startPos,markerPos);
    beforeText=undoEntities(beforeText);
    prev=addText(prev,beforeText,addAsChild);
    addAsChild=false;
    if (markerPos == text.length())     break;
    int termStart=text.indexOf('>',markerPos) + 1;
    int markEnd=text.indexOf("String_Node_Str",markerPos);
    String termText=text.substring(termStart,markEnd);
    termText=undoEntities(termText);
    prev=addElement(prev,termElementCode,0,false);
    addText(prev,termText,true);
    startPos=text.indexOf('>',markEnd) + 1;
  }
  return prev;
}
Program: 24800
Project: 24800
Buggy source:
/** 
 * Translates any HTML-special characters (like quote, ampersand, etc.) into the corresponding code (like &amp;quot;)
 * @param s The string to transform
 */
public static String makeHtmlString(String s,boolean keepTags){
  if (s == null)   return "String_Node_Str";
  StringBuffer buf=new StringBuffer();
  boolean inTag=false;
  for (int i=0; i < s.length(); i++) {
    char c=s.charAt(i);
    if (keepTags && !inTag && c == '<') {
      inTag=true;
      buf.append(c);
      continue;
    }
    if (keepTags && inTag && c == '>') {
      inTag=false;
      buf.append(c);
      continue;
    }
    if (inTag) {
      buf.append(c);
      continue;
    }
switch (c) {
case '<':
      buf.append("String_Node_Str");
    break;
case '>':
  buf.append("String_Node_Str");
break;
case '&':
buf.append("String_Node_Str");
break;
case '\'':
buf.append("String_Node_Str");
break;
case '\"':
buf.append("String_Node_Str");
break;
case '\n':
buf.append("String_Node_Str");
break;
default :
buf.append(c);
break;
}
}
return buf.toString();
}

Fixed version (ground truth):
/** 
 * Translates any HTML-special characters (like quote, ampersand, etc.) into the corresponding code (like &amp;quot;)
 * @param s The string to transform
 */
public static String makeHtmlString(String s,boolean keepTags){
  if (s == null)   return "String_Node_Str";
  StringBuffer buf=new StringBuffer();
  boolean inTag=false;
  for (int i=0; i < s.length(); i++) {
    char c=s.charAt(i);
    if (keepTags && !inTag && c == '<') {
      inTag=true;
      buf.append(c);
      continue;
    }
    if (keepTags && inTag && c == '>') {
      inTag=false;
      buf.append(c);
      continue;
    }
    if (inTag) {
      buf.append(c);
      continue;
    }
    if (c == '&') {
      int j;
      for (j=i + 1; j < s.length(); j++) {
        if (!Character.isLetterOrDigit(s.charAt(j)))         break;
      }
      if (j < s.length() && s.charAt(j) == ';') {
        while (i <= j)         buf.append(s.charAt(i++));
        i--;
        continue;
      }
    }
switch (c) {
case '<':
      buf.append("String_Node_Str");
    break;
case '>':
  buf.append("String_Node_Str");
break;
case '&':
buf.append("String_Node_Str");
break;
case '\'':
buf.append("String_Node_Str");
break;
case '\"':
buf.append("String_Node_Str");
break;
case '\n':
buf.append("String_Node_Str");
break;
default :
buf.append(c);
break;
}
}
return buf.toString();
}
Program: 24801
Project: 24801
Buggy source:
/** 
 * Given a chunk number, return the corresponding document number that it is part of. Note that like all Lucene indexes, this is ephemeral and only applies to the given reader. If not found, returns -1; this can basically only happen if the chunk number is greater than all document numbers.
 * @param chunkNumber Chunk number to translate
 * @return Document index, or -1 if no match.
 */
public final int getDocNum(int chunkNumber){
  scan(chunkNumber);
  if (high == nDocs)   return -1;
  return docNums[high];
}

Fixed version (ground truth):
/** 
 * Given a chunk number, return the corresponding document number that it is part of. Note that like all Lucene indexes, this is ephemeral and only applies to the given reader. If not found, returns -1; this can basically only happen if the chunk number is greater than all document numbers.
 * @param chunkNumber Chunk number to translate
 * @return Document index, or -1 if no match.
 */
public final synchronized int getDocNum(int chunkNumber){
  scan(chunkNumber);
  if (high == nDocs)   return -1;
  return docNums[high];
}
Program: 24802
Project: 24802
Buggy source:
private void load(){
  if (docNums != null)   return;
  try {
    Term term=new Term("String_Node_Str","String_Node_Str");
    nDocs=reader.docFreq(term);
    docNums=new int[nDocs];
    TermDocs docHeaders=reader.termDocs(term);
    int i=0;
    while (docHeaders.next())     docNums[i++]=docHeaders.doc();
    nDocs=i;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
private synchronized void load(){
  if (docNums != null)   return;
  try {
    Term term=new Term("String_Node_Str","String_Node_Str");
    nDocs=reader.docFreq(term);
    docNums=new int[nDocs];
    TermDocs docHeaders=reader.termDocs(term);
    int i=0;
    while (docHeaders.next())     docNums[i++]=docHeaders.doc();
    nDocs=i;
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 24803
Project: 24803
Buggy source:
/** 
 * Given a document number, this method returns the number of its first chunk.
 */
public final int getFirstChunk(int docNum){
  scan(docNum);
  if (low < 0 || docNums[low] != docNum)   return -1;
  if (low == 0)   return 1;
 else   return docNums[low - 1] + 1;
}

Fixed version (ground truth):
/** 
 * Given a document number, this method returns the number of its first chunk.
 */
public final synchronized int getFirstChunk(int docNum){
  scan(docNum);
  if (low < 0 || docNums[low] != docNum)   return -1;
  if (low == 0)   return 1;
 else   return docNums[low - 1] + 1;
}
Program: 24804
Project: 24804
Buggy source:
/** 
 * This is main entry point. Takes a pre-parsed query request and handles  searching the index and forming the results.
 * @param req      The pre-parsed request to process
 * @return         Zero or more document hits
 */
public QueryResult processRequest(final QueryRequest req) throws IOException {
}

Fixed version (ground truth):
/** 
 * This is main entry point. Takes a pre-parsed query request and handles  searching the index and forming the results.<br> This method is synchronized because it uses two instance variables, so access by multiple threads would result in incorrect counting. For maximum efficiency, each thread should really use its own instance.
 * @param req      The pre-parsed request to process
 * @return         Zero or more document hits
 */
public synchronized QueryResult processRequest(final QueryRequest req) throws IOException {
}
Program: 24805
Project: 24805
Buggy source:
/** 
 * The last child of this Node, or null if none. 
 */
public NodeInfo getLastChild(){
  NodeInfo last=getFirstChild();
  while (true) {
    NodeInfo next=((NodeImpl)last).getNextSibling();
    if (next == null)     break;
    last=next;
  }
  return last;
}

Fixed version (ground truth):
/** 
 * The last child of this Node, or null if none. 
 */
public NodeInfo getLastChild(){
  NodeInfo last=getFirstChild();
  if (last != null) {
    while (true) {
      NodeInfo next=((NodeImpl)last).getNextSibling();
      if (next == null)       break;
      last=next;
    }
  }
  return last;
}
Program: 24806
Project: 24806
Buggy source:
public void recordSpans(int targetDoc,FieldSpans fieldSpans){
}

Fixed version (ground truth):
public void recordSpans(int targetDoc,FieldSpans fieldSpans){
  if (scoredDoc == targetDoc && totalDeduped > 0)   fieldSpans.recordSpans(field,totalDeduped,scoredSpans,terms);
}
Program: 24807
Project: 24807
Buggy source:
/** 
 * After index parameters are known, this method should be called to update the slop parameters of queries that need to know. Also informs wildcard and range queries of the stopword set.
 */
private void fixupSlop(Query query,DocNumMap docNumMap,Set stopSet){
  boolean isText=(query instanceof SpanQuery) ? ((SpanQuery)query).getField().equals("String_Node_Str") : false;
  if (query instanceof SpanNearQuery) {
    SpanNearQuery nq=(SpanNearQuery)query;
    int maxSlop=isText ? docNumMap.getChunkOverlap() : 1000000;
    nq.setSlop(Math.min(nq.getSlop(),maxSlop));
  }
 else   if (query instanceof SpanChunkedNotQuery) {
    SpanChunkedNotQuery nq=(SpanChunkedNotQuery)query;
    nq.setSlop(Math.min(nq.getSlop(),docNumMap.getChunkOverlap()),docNumMap.getChunkSize() - docNumMap.getChunkOverlap());
  }
 else   if (query instanceof SpanDechunkingQuery) {
    SpanDechunkingQuery dq=(SpanDechunkingQuery)query;
    dq.setDocNumMap(docNumMap);
  }
 else   if (query instanceof SpanWildcardQuery) {
    SpanWildcardQuery wq=(SpanWildcardQuery)query;
    wq.setStopWords(stopSet);
  }
 else   if (query instanceof SpanRangeQuery) {
    SpanRangeQuery rq=(SpanRangeQuery)query;
    rq.setStopWords(stopSet);
  }
  Query[] subQueries=query.getSubQueries();
  if (subQueries != null) {
    for (int i=0; i < subQueries.length; i++)     fixupSlop(subQueries[i],docNumMap,stopSet);
  }
}

Fixed version (ground truth):
/** 
 * After index parameters are known, this method should be called to update the slop parameters of queries that need to know. Also informs wildcard and range queries of the stopword set.
 */
private void fixupSlop(Query query,DocNumMap docNumMap,Set stopSet){
  boolean isText=(query instanceof SpanQuery) ? ((SpanQuery)query).getField().equals("String_Node_Str") : false;
  if (query instanceof SpanNearQuery) {
    SpanNearQuery nq=(SpanNearQuery)query;
    int maxSlop=isText ? docNumMap.getChunkOverlap() : (1000000 - 1);
    nq.setSlop(Math.min(nq.getSlop(),maxSlop));
  }
 else   if (query instanceof SpanChunkedNotQuery) {
    SpanChunkedNotQuery nq=(SpanChunkedNotQuery)query;
    nq.setSlop(Math.min(nq.getSlop(),docNumMap.getChunkOverlap()),docNumMap.getChunkSize() - docNumMap.getChunkOverlap());
  }
 else   if (query instanceof SpanDechunkingQuery) {
    SpanDechunkingQuery dq=(SpanDechunkingQuery)query;
    dq.setDocNumMap(docNumMap);
  }
 else   if (query instanceof SpanWildcardQuery) {
    SpanWildcardQuery wq=(SpanWildcardQuery)query;
    wq.setStopWords(stopSet);
  }
 else   if (query instanceof SpanRangeQuery) {
    SpanRangeQuery rq=(SpanRangeQuery)query;
    rq.setStopWords(stopSet);
  }
  Query[] subQueries=query.getSubQueries();
  if (subQueries != null) {
    for (int i=0; i < subQueries.length; i++)     fixupSlop(subQueries[i],docNumMap,stopSet);
  }
}
Program: 24809
Project: 24809
Buggy source:
public void beginSpan(MarkPos pos,Span span){
  copyUpTo(pos);
  buf.append("String_Node_Str");
  buf.append(Integer.toString(span.rank + 1));
  buf.append("String_Node_Str");
  buf.append(Integer.toString((int)(span.score * 100)));
  buf.append("String_Node_Str");
  inSpan=true;
}

Fixed version (ground truth):
public void beginSpan(MarkPos pos,Span span){
  copyUpTo(pos);
  buf.append("String_Node_Str");
  if (!inContext) {
    buf.append("String_Node_Str");
    buf.append(Integer.toString(span.rank + 1));
    buf.append("String_Node_Str");
    buf.append(Integer.toString((int)(span.score * 100)));
    buf.append("String_Node_Str");
  }
  buf.append("String_Node_Str");
  inSpan=true;
}
Program: 24810
Project: 24810
Buggy source:
/** 
 * Retrieve the total number of spans which matched the field 
 */
public int getSpanTotal(String field){
  Entry ent=(Entry)entries.get(field);
  return (ent == null) ? -1 : ent.total;
}

Fixed version (ground truth):
/** 
 * Retrieve the total number of spans which matched the field 
 */
public int getSpanTotal(String field){
  Entry ent=(Entry)entries.get(field);
  return (ent == null) ? 0 : ent.total;
}
Program: 24811
Project: 24811
Buggy source:
/** 
 * Retrieve the number of spans stored for a given field 
 */
public int getSpanCount(String field){
  Entry ent=(Entry)entries.get(field);
  return (ent == null) ? -1 : ent.spans.size();
}

Fixed version (ground truth):
/** 
 * Retrieve the number of spans stored for a given field 
 */
public int getSpanCount(String field){
  Entry ent=(Entry)entries.get(field);
  return (ent == null) ? 0 : ent.spans.size();
}
Program: 24812
Project: 24812
Buggy source:
/** 
 * Construct a term given its text and field name. This function is used instead of Term's constructor to add an extra check that the text is never a stop word.
 * @param text    Text for the new term
 * @param field   Field being queried
 * @return        A properly constructed Term, never a stop-word.
 */
protected Term newTerm(String text,String field){
}

Fixed version (ground truth):
/** 
 * Construct a term given its text and field name. This function is used instead of Term's constructor to add an extra check that the text is never a stop word.
 * @param text    Text for the new term
 * @param field   Field being queried
 * @return        A properly constructed Term, never a stop-word.
 */
protected Term newTerm(String field,String text){
}
Program: 24813
Project: 24813
Buggy source:
/** 
 * Creates either a standard score-sorting hit queue, or a field-sorting hit queue, depending on whether the query is to be sorted.
 * @param reader  will be used to read the field contents
 * @param req     contains the parameters (startDoc, maxDoc, sort fields)
 * @return        an appropriate hit queue
 */
private PriorityQueue createHitQueue(IndexReader reader,QueryRequest req) throws IOException {
  int nDocs=req.startDoc + req.maxDocs;
  if (req.sortMetaFields == null)   return new HitQueue(nDocs);
  Vector fieldNames=new Vector();
  StringTokenizer st=new StringTokenizer(req.sortMetaFields,"String_Node_Str");
  while (st.hasMoreTokens())   fieldNames.add(st.nextToken());
  if (fieldNames.size() == 0)   return new HitQueue(nDocs);
  SortField[] fields=new SortField[fieldNames.size() + 1];
  for (int i=0; i < fieldNames.size(); i++) {
    String name=(String)fieldNames.elementAt(i);
    boolean reverse=false;
    if (name.startsWith("String_Node_Str")) {
      reverse=true;
      name=name.substring(1);
    }
 else     if (name.startsWith("String_Node_Str")) {
      reverse=false;
      name=name.substring(1);
    }
    fields[i]=new SortField(name,sparseStringComparator,reverse);
  }
  fields[fieldNames.size()]=SortField.FIELD_SCORE;
  return new FieldSortedHitQueue(reader,fields,nDocs);
}

Fixed version (ground truth):
/** 
 * Creates either a standard score-sorting hit queue, or a field-sorting hit queue, depending on whether the query is to be sorted.
 * @param reader  will be used to read the field contents
 * @param req     contains the parameters (startDoc, maxDoc, sort fields)
 * @return        an appropriate hit queue
 */
private PriorityQueue createHitQueue(IndexReader reader,int startDoc,int maxDocs,String sortFields) throws IOException {
  int nDocs=startDoc + maxDocs;
  if (sortFields == null)   return new HitQueue(nDocs);
  Vector fieldNames=new Vector();
  StringTokenizer st=new StringTokenizer(sortFields,"String_Node_Str");
  while (st.hasMoreTokens())   fieldNames.add(st.nextToken());
  if (fieldNames.size() == 0)   return new HitQueue(nDocs);
  SortField[] fields=new SortField[fieldNames.size() + 1];
  for (int i=0; i < fieldNames.size(); i++) {
    String name=(String)fieldNames.elementAt(i);
    boolean reverse=false;
    if (name.startsWith("String_Node_Str")) {
      reverse=true;
      name=name.substring(1);
    }
 else     if (name.startsWith("String_Node_Str")) {
      reverse=false;
      name=name.substring(1);
    }
    fields[i]=new SortField(name,sparseStringComparator,reverse);
  }
  fields[fieldNames.size()]=SortField.FIELD_SCORE;
  return new FieldSortedHitQueue(reader,fields,nDocs);
}
Program: 24814
Project: 24814
Buggy source:
/** 
 * Add a document hit to the counts 
 */
public void addDoc(int doc,float score,FieldSpans spans){
  int link, group;
  for (link=data.firstLink(doc); link >= 0; link=data.nextLink(link)) {
    for (group=data.linkGroup(link); group >= 0; group=data.parent(group)) {
      counts[group]++;
      if (data.name(group) == hitGroupName) {
        hitQueue.insert(new DocHitImpl(doc,score,spans));
        hitTotalDocs++;
      }
    }
  }
}

Fixed version (ground truth):
/** 
 * Add a document hit to the counts 
 */
public void addDoc(int doc,float score,FieldSpans spans){
  int link, group;
  curMark++;
  for (link=data.firstLink(doc); link >= 0; link=data.nextLink(link)) {
    for (group=data.linkGroup(link); group >= 0; group=data.parent(group)) {
      if (marks[group] == curMark)       break;
      counts[group]++;
      marks[group]=curMark;
      if (data.name(group) == hitGroupName) {
        hitQueue.insert(new DocHitImpl(doc,score,spans));
        hitTotalDocs++;
      }
    }
  }
}
Program: 24815
Project: 24815
Buggy source:
/** 
 * Construct the array of doc hits for the hit group. 
 */
private void makeDocHits(ResultGroup group){
  int i;
  for (i=0; i < hitStartDoc; i++)   hitQueue.pop();
  int nHits=Math.min(hitQueue.size(),hitMaxDocs);
  group.docHits=new DocHit[nHits];
  group.totalDocs=hitTotalDocs;
  group.startDoc=hitStartDoc;
  group.endDoc=hitStartDoc + nHits;
  for (i=0; i < nHits; i++)   group.docHits[i]=(DocHit)hitQueue.pop();
}

Fixed version (ground truth):
/** 
 * Construct the array of doc hits for the hit group. 
 */
private void makeDocHits(ResultGroup group){
  int nFound=hitQueue.size();
  DocHitImpl[] hitArray=new DocHitImpl[nFound];
  float maxDocScore=0.0f;
  for (int i=0; i < nFound; i++) {
    int index=nFound - i - 1;
    hitArray[index]=(DocHitImpl)hitQueue.pop();
  }
  int nHits=Math.min(nFound,hitMaxDocs);
  group.docHits=new DocHit[nHits];
  group.totalDocs=hitTotalDocs;
  group.startDoc=hitStartDoc;
  group.endDoc=hitStartDoc + nHits;
  for (int i=hitStartDoc; i < nFound; i++)   group.docHits[i - hitStartDoc]=hitArray[i];
}
Program: 24816
Project: 24816
Buggy source:
/** 
 * Construct an object with all counts at zero 
 */
public GroupCounts(GroupData groupData){
  this.data=groupData;
  counts=new int[data.nGroups()];
}

Fixed version (ground truth):
/** 
 * Construct an object with all counts at zero 
 */
public GroupCounts(GroupData groupData){
  this.data=groupData;
  counts=new int[data.nGroups()];
  marks=new int[data.nGroups()];
}
Program: 24817
Project: 24817
Buggy source:
public void close() throws IOException {
  realStore().close();
  realStore=null;
}

Fixed version (ground truth):
public void close() throws IOException {
  if (realStore != null)   realStore.close();
  realStore=null;
}
Program: 24818
Project: 24818
Buggy source:
public void delete() throws IOException {
  realStore().delete();
  realStore=null;
}

Fixed version (ground truth):
public void delete() throws IOException {
  if (realStore != null)   realStore.delete();
  realStore=null;
}
Program: 24819
Project: 24819
Buggy source:
/** 
 * If the given element has a 'field' attribute, return its value; otherwise return 'parentField'. Also checks that field cannot be specified if parentField has already been.
 */
private String parseField(EasyNode el,String parentField) throws QueryGenException {
  if (!el.hasAttr("String_Node_Str") && !el.hasAttr("String_Node_Str"))   return parentField;
  String attVal=el.attrValue("String_Node_Str");
  if (attVal == null || attVal.length() == 0)   attVal=el.attrValue("String_Node_Str");
  if (attVal.length() == 0)   error("String_Node_Str");
  if (attVal.equals("String_Node_Str") && !parentField.equals("String_Node_Str"))   error("String_Node_Str");
  if (parentField != null && !parentField.equals(attVal))   error("String_Node_Str");
  return attVal;
}

Fixed version (ground truth):
/** 
 * If the given element has a 'field' attribute, return its value; otherwise return 'parentField'. Also checks that field cannot be specified if parentField has already been.
 */
private String parseField(EasyNode el,String parentField) throws QueryGenException {
  if (!el.hasAttr("String_Node_Str") && !el.hasAttr("String_Node_Str"))   return parentField;
  String attVal=el.attrValue("String_Node_Str");
  if (attVal == null || attVal.length() == 0)   attVal=el.attrValue("String_Node_Str");
  if (attVal.length() == 0)   error("String_Node_Str");
  if (attVal.equals("String_Node_Str") && (parentField == null || !parentField.equals("String_Node_Str")))   error("String_Node_Str");
  if (parentField != null && !parentField.equals(attVal))   error("String_Node_Str");
  return attVal;
}
Program: 24821
Project: 24821
Buggy source:
public boolean next(boolean force){
  if (tokens == null)   reseek(0);
 else   if (tokNum == tokens.length - 1) {
    if (chunk.chunkNum + 1 > chunkSource.lastChunk)     return false;
    Chunk next=chunkSource.loadChunk(chunk.chunkNum + 1);
    if (!force && next.tokens.length == 0)     return false;
    reseek(next);
    return true;
  }
  return super.next(force);
}

Fixed version (ground truth):
public boolean next(boolean force){
  if (tokens == null)   reseek(0);
 else   if (tokNum == tokens.length - 1) {
    while (true) {
      if (chunk.chunkNum + 1 > chunkSource.lastChunk)       return false;
      Chunk next=chunkSource.loadChunk(chunk.chunkNum + 1);
      if (next.tokens.length == 0) {
        if (!force)         return false;
        chunk=next;
        continue;
      }
      reseek(next);
      return true;
    }
  }
  return super.next(force);
}