nus-yam/ex-repair huggingface dataset:
Program: 31365
Project: 31365
Buggy source:
@Override protected void onPartBegin(IOContext context,RequestHeaderBuffer hb) throws IOException {
  ImportHandlerContext h=lvContext.get(context);
  if (Chars.equals("String_Node_Str",hb.getContentDispositionName())) {
    if (hb.getContentDispositionFilename() == null) {
      context.simpleResponse().send(400,"String_Node_Str");
      throw DisconnectedChannelException.INSTANCE;
    }
    h.analysed=false;
    h.importer.of(hb.getContentDispositionFilename().toString());
    h.part=MessagePart.DATA;
  }
 else   if (Chars.equals("String_Node_Str",hb.getContentDispositionName())) {
    h.part=MessagePart.SCHEMA;
  }
 else {
    h.part=MessagePart.UNKNOWN;
  }
}

Fixed version (ground truth):
@Override protected void onPartBegin(IOContext context,RequestHeaderBuffer hb) throws IOException {
  ImportHandlerContext h=lvContext.get(context);
  if (Chars.equals("String_Node_Str",hb.getContentDispositionName())) {
    if (hb.getContentDispositionFilename() == null) {
      context.simpleResponse().send(400,"String_Node_Str");
      throw DisconnectedChannelException.INSTANCE;
    }
    h.analysed=false;
    h.importer.of(nameExtractor.get().of(hb.getContentDispositionFilename()).toString());
    h.part=MessagePart.DATA;
  }
 else   if (Chars.equals("String_Node_Str",hb.getContentDispositionName())) {
    h.part=MessagePart.SCHEMA;
  }
 else {
    h.part=MessagePart.UNKNOWN;
  }
}
Program: 31368
Project: 31368
Buggy source:
private int parseMethod(long lo,int len) throws HeadersTooLargeException {
  long p=lo;
  long hi=lo + len;
  int offset=0;
  while (p < hi) {
    if (_wptr == this.hi) {
      throw HeadersTooLargeException.INSTANCE;
    }
    char b=(char)Unsafe.getUnsafe().getByte(p++);
    if (b == '\r') {
      continue;
    }
switch (b) {
case ' ':
      if (m) {
        method=pool.next().of(_lo,_wptr);
        _lo=_wptr + 1;
        m=false;
      }
 else       if (u) {
        url=pool.next().of(_lo,_wptr);
        u=false;
        _lo=_wptr + 1;
      }
 else       if (q) {
        int o=Misc.urlDecode(_lo,_wptr,urlParams,pool);
        q=false;
        _lo=_wptr;
        _wptr-=o;
      }
    break;
case '?':
  url=pool.next().of(_lo,_wptr);
u=false;
q=true;
_lo=_wptr + 1;
break;
case '\n':
methodLine=pool.next().of(((DirectByteCharSequence)method).getLo(),_wptr);
needMethod=false;
this._lo=_wptr;
return (int)(p - lo);
default :
break;
}
Unsafe.getUnsafe().putByte(_wptr++,(byte)b);
}
return (int)(p - lo);
}

Fixed version (ground truth):
private int parseMethod(long lo,int len) throws HeadersTooLargeException {
  long p=lo;
  long hi=lo + len;
  while (p < hi) {
    if (_wptr == this.hi) {
      throw HeadersTooLargeException.INSTANCE;
    }
    char b=(char)Unsafe.getUnsafe().getByte(p++);
    if (b == '\r') {
      continue;
    }
switch (b) {
case ' ':
      if (m) {
        method=pool.next().of(_lo,_wptr);
        _lo=_wptr + 1;
        m=false;
      }
 else       if (u) {
        url=pool.next().of(_lo,_wptr);
        u=false;
        _lo=_wptr + 1;
      }
 else       if (q) {
        int o=Misc.urlDecode(_lo,_wptr,urlParams,pool);
        q=false;
        _lo=_wptr;
        _wptr-=o;
      }
    break;
case '?':
  url=pool.next().of(_lo,_wptr);
u=false;
q=true;
_lo=_wptr + 1;
break;
case '\n':
methodLine=pool.next().of(((DirectByteCharSequence)method).getLo(),_wptr);
needMethod=false;
this._lo=_wptr;
return (int)(p - lo);
default :
break;
}
Unsafe.getUnsafe().putByte(_wptr++,(byte)b);
}
return (int)(p - lo);
}
Program: 31369
Project: 31369
Buggy source:
public void clear(int capacity){
  setAll(capacity,noEntryValue);
}

Fixed version (ground truth):
public void clear(int capacity){
  ensureCapacity(capacity);
  pos=0;
  Arrays.fill(buffer,noEntryValue);
}
Program: 31370
Project: 31370
Buggy source:
public void setAll(int capacity,int value){
  ensureCapacity0(capacity);
  pos=0;
  Arrays.fill(buffer,value);
}

Fixed version (ground truth):
public void setAll(int capacity,int value){
  ensureCapacity0(capacity);
  pos=capacity;
  Arrays.fill(buffer,value);
}
Program: 31371
Project: 31371
Buggy source:
public void setAll(int capacity,T value){
  ensureCapacity0(capacity);
  pos=0;
  Arrays.fill(buffer,value);
}

Fixed version (ground truth):
public void setAll(int capacity,T value){
  ensureCapacity0(capacity);
  pos=capacity;
  Arrays.fill(buffer,value);
}
Program: 31372
Project: 31372
Buggy source:
public static void urlDecode(long lo,long hi,CharSequenceObjHashMap<CharSequence> map,ObjectPool<DirectByteCharSequence> pool){
  long _lo=lo;
  long rp=lo;
  long wp=lo;
  final DirectByteCharSequence temp=pool.next();
  CharSequence name=null;
  while (rp < hi) {
    char b=(char)Unsafe.getUnsafe().getByte(rp++);
switch (b) {
case '=':
      if (_lo < wp) {
        name=pool.next().of(_lo,wp);
      }
    _lo=rp;
  wp=rp - 1;
break;
case '&':
if (name != null) {
map.put(name,pool.next().of(_lo,wp));
name=null;
}
_lo=rp;
wp=rp - 1;
break;
case '+':
Unsafe.getUnsafe().putByte(wp,(byte)' ');
break;
case '%':
try {
if (rp + 1 < hi) {
Unsafe.getUnsafe().putByte(wp++,(byte)Numbers.parseHexInt(temp.of(rp,rp+=2)));
continue;
}
}
 catch (NumericException ignore) {
}
name=null;
break;
default :
Unsafe.getUnsafe().putByte(wp,(byte)b);
break;
}
wp++;
}
if (_lo < wp && name != null) {
map.put(name,pool.next().of(_lo,wp));
}
}

Fixed version (ground truth):
public static int urlDecode(long lo,long hi,CharSequenceObjHashMap<CharSequence> map,ObjectPool<DirectByteCharSequence> pool){
  long _lo=lo;
  long rp=lo;
  long wp=lo;
  final DirectByteCharSequence temp=pool.next();
  int offset=0;
  CharSequence name=null;
  while (rp < hi) {
    char b=(char)Unsafe.getUnsafe().getByte(rp++);
switch (b) {
case '=':
      if (_lo < wp) {
        name=pool.next().of(_lo,wp);
      }
    _lo=rp - offset;
  break;
case '&':
if (name != null) {
  map.put(name,pool.next().of(_lo,wp));
  name=null;
}
_lo=rp - offset;
break;
case '+':
Unsafe.getUnsafe().putByte(wp++,(byte)' ');
continue;
case '%':
try {
if (rp + 1 < hi) {
Unsafe.getUnsafe().putByte(wp++,(byte)Numbers.parseHexInt(temp.of(rp,rp+=2)));
offset+=2;
continue;
}
}
 catch (NumericException ignore) {
}
name=null;
break;
default :
break;
}
Unsafe.getUnsafe().putByte(wp++,(byte)b);
}
if (_lo < wp && name != null) {
map.put(name,pool.next().of(_lo,wp));
}
return offset;
}
Program: 31373
Project: 31373
Buggy source:
private int parseMethod(long lo,int len) throws HeadersTooLargeException {
  long p=lo;
  long hi=lo + len;
  while (p < hi) {
    if (_wptr == this.hi) {
      throw HeadersTooLargeException.INSTANCE;
    }
    char b=(char)Unsafe.getUnsafe().getByte(p++);
    if (b == '\r') {
      continue;
    }
    Unsafe.getUnsafe().putByte(_wptr++,(byte)b);
switch (b) {
case ' ':
      if (m) {
        method=pool.next().of(_lo,_wptr - 1);
        _lo=_wptr;
        m=false;
      }
 else       if (u) {
        url=pool.next().of(_lo,_wptr - 1);
        u=false;
        _lo=_wptr;
      }
 else       if (q) {
        Misc.urlDecode(_lo,_wptr - 1,urlParams,pool);
        q=false;
        _lo=_wptr;
      }
    break;
case '?':
  url=pool.next().of(_lo,_wptr - 1);
u=false;
q=true;
_lo=_wptr;
break;
case '\n':
methodLine=pool.next().of(((DirectByteCharSequence)method).getLo(),_wptr - 1);
needMethod=false;
this._lo=_wptr;
return (int)(p - lo);
default :
break;
}
}
return (int)(p - lo);
}

Fixed version (ground truth):
private int parseMethod(long lo,int len) throws HeadersTooLargeException {
  long p=lo;
  long hi=lo + len;
  int offset=0;
  while (p < hi) {
    if (_wptr == this.hi) {
      throw HeadersTooLargeException.INSTANCE;
    }
    char b=(char)Unsafe.getUnsafe().getByte(p++);
    if (b == '\r') {
      continue;
    }
switch (b) {
case ' ':
      if (m) {
        method=pool.next().of(_lo,_wptr);
        _lo=_wptr + 1;
        m=false;
      }
 else       if (u) {
        url=pool.next().of(_lo,_wptr);
        u=false;
        _lo=_wptr + 1;
      }
 else       if (q) {
        int o=Misc.urlDecode(_lo,_wptr,urlParams,pool);
        q=false;
        _lo=_wptr;
        _wptr-=o;
      }
    break;
case '?':
  url=pool.next().of(_lo,_wptr);
u=false;
q=true;
_lo=_wptr + 1;
break;
case '\n':
methodLine=pool.next().of(((DirectByteCharSequence)method).getLo(),_wptr);
needMethod=false;
this._lo=_wptr;
return (int)(p - lo);
default :
break;
}
Unsafe.getUnsafe().putByte(_wptr++,(byte)b);
}
return (int)(p - lo);
}
Program: 31374
Project: 31374
Buggy source:
@Override public void reset(){
  recordSource.reset();
  map.clear();
}

Fixed version (ground truth):
@Override public void reset(){
  recordSource.reset();
  map.clear();
  nextRecord=null;
}
Program: 31375
Project: 31375
Buggy source:
@SuppressFBWarnings({"String_Node_Str"}) public ResampledRecordSource(RecordSource recordSource,@Transient ObjHashSet<String> keyColumns,ObjList<AggregatorFunction> aggregators,TimestampSampler sampler){
  int keyColumnsSize=keyColumns.size();
  this.keyIndices=new IntList(keyColumnsSize);
  ObjHashSet<String> keyCols=new ObjHashSet<>();
  RecordMetadata rm=recordSource.getMetadata();
  this.tsIndex=rm.getTimestampIndex();
  keyCols.add(rm.getColumnName(tsIndex));
  for (int i=0; i < keyColumnsSize; i++) {
    keyCols.add(keyColumns.get(i));
    int index=rm.getColumnIndex(keyColumns.get(i));
    if (index != tsIndex) {
      keyIndices.add(index);
    }
  }
  this.aggregators=aggregators;
  this.sampler=sampler;
  ObjList<MapRecordValueInterceptor> interceptors=new ObjList<>();
  ObjList<RecordColumnMetadata> columns=tlColumns.get();
  columns.clear();
  int index=0;
  for (int i=0, sz=aggregators.size(); i < sz; i++) {
    AggregatorFunction func=aggregators.getQuick(i);
    int n=columns.size();
    func.prepare(columns,index);
    index+=columns.size() - n;
    if (func instanceof MapRecordValueInterceptor) {
      interceptors.add((MapRecordValueInterceptor)func);
    }
  }
  this.map=new MultiMap(rm,keyCols,columns,interceptors);
  this.recordSource=recordSource;
}

Fixed version (ground truth):
@SuppressFBWarnings({"String_Node_Str"}) public ResampledRecordSource(RecordSource recordSource,int timestampColumnIndex,@Transient ObjHashSet<String> keyColumns,ObjList<AggregatorFunction> aggregators,TimestampSampler sampler){
  int keyColumnsSize=keyColumns.size();
  this.keyIndices=new IntList(keyColumnsSize);
  ObjHashSet<String> keyCols=new ObjHashSet<>();
  RecordMetadata rm=recordSource.getMetadata();
  this.tsIndex=timestampColumnIndex;
  keyCols.add(rm.getColumnName(tsIndex));
  for (int i=0; i < keyColumnsSize; i++) {
    keyCols.add(keyColumns.get(i));
    int index=rm.getColumnIndex(keyColumns.get(i));
    if (index != tsIndex) {
      keyIndices.add(index);
    }
  }
  this.aggregators=aggregators;
  this.sampler=sampler;
  ObjList<MapRecordValueInterceptor> interceptors=new ObjList<>();
  ObjList<RecordColumnMetadata> columns=tlColumns.get();
  columns.clear();
  int index=0;
  for (int i=0, sz=aggregators.size(); i < sz; i++) {
    AggregatorFunction func=aggregators.getQuick(i);
    int n=columns.size();
    func.prepare(columns,index);
    index+=columns.size() - n;
    if (func instanceof MapRecordValueInterceptor) {
      interceptors.add((MapRecordValueInterceptor)func);
    }
  }
  this.map=new MultiMap(rm,keyCols,columns,interceptors);
  this.recordSource=recordSource;
}
Program: 31376
Project: 31376
Buggy source:
private void rehash(){
  int capacity=keyCapacity << 1;
  mask=capacity - 1;
  LongList pointers=new LongList(capacity);
  pointers.zero((byte)-1);
  pointers.setPos(capacity);
  for (int i=0, k=this.offsets.size(); i < k; i++) {
    long offset=this.offsets.get(i);
    if (offset == -1) {
      continue;
    }
    int index=Hash.hashMem(kStart + offset + keyBlockOffset,Unsafe.getUnsafe().getInt(kStart + offset) - keyBlockOffset) & mask;
    while (pointers.get(index) != -1) {
      index=(index + 1) & mask;
    }
    pointers.setQuick(index,offset);
  }
  this.offsets=pointers;
  this.free+=(capacity - keyCapacity) * loadFactor;
  this.keyCapacity=capacity;
}

Fixed version (ground truth):
private void rehash(){
  int capacity=keyCapacity << 1;
  mask=capacity - 1;
  LongList pointers=new LongList(capacity);
  pointers.setPos(capacity);
  pointers.zero(-1);
  for (int i=0, k=this.offsets.size(); i < k; i++) {
    long offset=this.offsets.get(i);
    if (offset == -1) {
      continue;
    }
    int index=Hash.hashMem(kStart + offset + keyBlockOffset,Unsafe.getUnsafe().getInt(kStart + offset) - keyBlockOffset) & mask;
    while (pointers.get(index) != -1) {
      index=(index + 1) & mask;
    }
    pointers.setQuick(index,offset);
  }
  this.offsets=pointers;
  this.free+=(capacity - keyCapacity) * loadFactor;
  this.keyCapacity=capacity;
}
Program: 31377
Project: 31377
Buggy source:
public void clear(){
  kPos=kStart;
  free=(int)(keyCapacity * loadFactor);
  size=0;
  offsets.fill(-1);
}

Fixed version (ground truth):
public void clear(){
  kPos=kStart;
  free=(int)(keyCapacity * loadFactor);
  size=0;
  offsets.zero(-1);
}
Program: 31378
Project: 31378
Buggy source:
/** 
 * Optimiser may be attempting to order join clauses several times. Every time ordering takes place optimiser will keep at most two lists: one is last known order the other is new order. If new order cost is better optimiser will replace last known order with new one. <p> To facilitate this behaviour the function will always return non-current list.
 * @return non current order list.
 */
public IntList nextOrderedJoinModels(){
  IntList ordered=orderedJoinModels == orderedJoinModels1 ? orderedJoinModels2 : orderedJoinModels1;
  ordered.clear();
  return ordered;
}

Fixed version (ground truth):
/** 
 * Optimiser may be attempting to order join clauses several times. Every time ordering takes place optimiser will keep at most two lists: one is last known order the other is new order. If new order cost is better optimiser will replace last known order with new one. <p/> To facilitate this behaviour the function will always return non-current list.
 * @return non current order list.
 */
public IntList nextOrderedJoinModels(){
  IntList ordered=orderedJoinModels == orderedJoinModels1 ? orderedJoinModels2 : orderedJoinModels1;
  ordered.clear();
  return ordered;
}
Program: 31379
Project: 31379
Buggy source:
public void clear(){
  columns.clear();
  joinModels.clear();
  joinModels.add(this);
  sampleBy=null;
  orderBy.clear();
  dependencies.clear();
  parsedWhere.clear();
  whereClause=null;
  nestedModel=null;
  journalName=null;
  alias=null;
  latestBy=null;
  recordSource=null;
  metadata=null;
  joinCriteria=null;
  joinType=JoinType.INNER;
  orderedJoinModels1.clear();
  orderedJoinModels2.clear();
  parsedWhereConsts.clear();
  aliasIndexes.clear();
  postJoinWhereClause=null;
  context=null;
  orderedJoinModels=orderedJoinModels2;
  limitHi=null;
  limitLo=null;
  limitHiVc=null;
  limitLoVc=null;
  columnNameFrequencyMap.clear();
  parameterMap.clear();
}

Fixed version (ground truth):
public void clear(){
  columns.clear();
  joinModels.clear();
  joinModels.add(this);
  sampleBy=null;
  orderBy.clear();
  dependencies.clear();
  parsedWhere.clear();
  whereClause=null;
  nestedModel=null;
  journalName=null;
  alias=null;
  latestBy=null;
  recordSource=null;
  metadata=null;
  joinCriteria=null;
  joinType=JoinType.INNER;
  orderedJoinModels1.clear();
  orderedJoinModels2.clear();
  parsedWhereConsts.clear();
  aliasIndexes.clear();
  postJoinWhereClause=null;
  context=null;
  orderedJoinModels=orderedJoinModels2;
  limitHi=null;
  limitLo=null;
  limitHiVc=null;
  limitLoVc=null;
  columnNameFrequencyMap.clear();
  parameterMap.clear();
  timestamp=null;
}
Program: 31381
Project: 31381
Buggy source:
private RecordSource createAsOfJoin(ExprNode masterTimestampNode,QueryModel model,RecordSource master,RecordSource slave) throws ParserException {
  JoinContext jc=model.getContext();
  ExprNode slaveTimestampNode=model.getTimestamp();
  RecordMetadata masterMetadata=master.getMetadata();
  RecordMetadata slaveMetadata=slave.getMetadata();
  int slaveTimestampIndex;
  int masterTimestampIndex;
  if (slaveTimestampNode != null) {
    slaveTimestampIndex=slaveMetadata.getColumnIndexQuiet(slaveTimestampNode.token);
    if (slaveTimestampIndex == -1) {
      throw QueryError.$(slaveTimestampNode.position,"String_Node_Str");
    }
  }
 else   if (slaveMetadata.getTimestampIndex() == -1) {
    throw QueryError.$(0,"String_Node_Str");
  }
 else {
    slaveTimestampIndex=slaveMetadata.getTimestampIndex();
  }
  if (masterTimestampNode != null) {
    masterTimestampIndex=masterMetadata.getColumnIndexQuiet(masterTimestampNode.token);
    if (masterTimestampIndex == -1) {
      throw QueryError.$(masterTimestampNode.position,"String_Node_Str");
    }
  }
 else   if (masterMetadata.getTimestampIndex() == -1) {
    throw QueryError.$(0,"String_Node_Str");
  }
 else {
    masterTimestampIndex=masterMetadata.getTimestampIndex();
  }
  if (jc == null) {
    return new AsOfJoinRecordSource(master,masterTimestampIndex,slave,slaveTimestampIndex);
  }
 else {
    int sz=jc.aNames.size();
    CharSequenceHashSet slaveKeys=new CharSequenceHashSet();
    CharSequenceHashSet masterKeys=new CharSequenceHashSet();
    for (int i=0; i < sz; i++) {
      slaveKeys.add(jc.aNames.getQuick(i));
      masterKeys.add(jc.bNames.getQuick(i));
    }
    return new AsOfPartitionedJoinRecordSource(master,masterTimestampIndex,slave,slaveTimestampIndex,masterKeys,slaveKeys,4 * 1024 * 1024);
  }
}

Fixed version (ground truth):
private RecordSource createAsOfJoin(ExprNode masterTimestampNode,QueryModel model,RecordSource master,RecordSource slave) throws ParserException {
  JoinContext jc=model.getContext();
  ExprNode slaveTimestampNode=model.getTimestamp();
  RecordMetadata masterMetadata=master.getMetadata();
  RecordMetadata slaveMetadata=slave.getMetadata();
  int slaveTimestampIndex=getTimestampIndex(model,slaveTimestampNode,slaveMetadata);
  int masterTimestampIndex=getTimestampIndex(model,masterTimestampNode,masterMetadata);
  if (jc == null) {
    return new AsOfJoinRecordSource(master,masterTimestampIndex,slave,slaveTimestampIndex);
  }
 else {
    int sz=jc.aNames.size();
    CharSequenceHashSet slaveKeys=new CharSequenceHashSet();
    CharSequenceHashSet masterKeys=new CharSequenceHashSet();
    for (int i=0; i < sz; i++) {
      slaveKeys.add(jc.aNames.getQuick(i));
      masterKeys.add(jc.bNames.getQuick(i));
    }
    return new AsOfPartitionedJoinRecordSource(master,masterTimestampIndex,slave,slaveTimestampIndex,masterKeys,slaveKeys,4 * 1024 * 1024);
  }
}
Program: 31382
Project: 31382
Buggy source:
private void parseSelectColumns(QueryModel model) throws ParserException {
  CharSequence tok;
  while (true) {
    ExprNode expr=expr();
    tok=tok();
    if (Chars.equals(tok,"String_Node_Str")) {
      model.addColumn(queryColumnPool.next().of(null,expr));
      break;
    }
    if (Chars.equals(tok,"String_Node_Str")) {
      model.addColumn(queryColumnPool.next().of(null,expr));
      continue;
    }
    model.addColumn(queryColumnPool.next().of(tok.toString(),expr));
    tok=tok();
    if (Chars.equals(tok,"String_Node_Str")) {
      break;
    }
    if (!Chars.equals(tok,',')) {
      throw err("String_Node_Str");
    }
  }
}

Fixed version (ground truth):
private void parseSelectColumns(QueryModel model) throws ParserException {
  CharSequence tok;
  while (true) {
    ExprNode expr=expr();
    tok=tok();
    if (Chars.equals(tok,"String_Node_Str")) {
      model.addColumn(queryColumnPool.next().of(null,expr));
      break;
    }
    if (Chars.equals(tok,',')) {
      model.addColumn(queryColumnPool.next().of(null,expr));
      continue;
    }
    model.addColumn(queryColumnPool.next().of(tok.toString(),expr));
    tok=tok();
    if (Chars.equals(tok,"String_Node_Str")) {
      break;
    }
    if (!Chars.equals(tok,',')) {
      throw err("String_Node_Str");
    }
  }
}
Program: 31383
Project: 31383
Buggy source:
private QueryModel parseJoin(CharSequence tok,QueryModel.JoinType type) throws ParserException {
  QueryModel joinModel=queryModelPool.next();
  joinModel.setJoinType(type);
  if (!Chars.equals(tok,"String_Node_Str")) {
    expectTok(tok(),"String_Node_Str");
  }
  tok=tok();
  if (Chars.equals(tok,"String_Node_Str")) {
    joinModel.setNestedModel(parseQuery(true));
    expectTok(tok(),"String_Node_Str");
  }
 else {
    lexer.unparse();
    joinModel.setJournalName(expr());
  }
  tok=lexer.optionTok();
  if (tok != null && !aliasStopSet.contains(tok)) {
    lexer.unparse();
    joinModel.setAlias(expr());
  }
 else {
    lexer.unparse();
  }
  tok=lexer.optionTok();
  if (type == QueryModel.JoinType.CROSS && tok != null && Chars.equals(tok,"String_Node_Str")) {
    throw QueryError.$(lexer.position(),"String_Node_Str");
  }
switch (type) {
case ASOF:
    if (tok == null || !Chars.equals("String_Node_Str",tok)) {
      lexer.unparse();
      break;
    }
case INNER:
case OUTER:
  expectTok(tok,"String_Node_Str");
ExprNode expr=expr();
if (expr == null) {
throw QueryError.$(lexer.position(),"String_Node_Str");
}
joinModel.setJoinCriteria(expr);
break;
default :
lexer.unparse();
}
return joinModel;
}

Fixed version (ground truth):
private QueryModel parseJoin(CharSequence tok,QueryModel.JoinType type) throws ParserException {
  QueryModel joinModel=queryModelPool.next();
  joinModel.setJoinType(type);
  if (!Chars.equals(tok,"String_Node_Str")) {
    expectTok(tok(),"String_Node_Str");
  }
  tok=tok();
  if (Chars.equals(tok,'(')) {
    joinModel.setNestedModel(parseQuery(true));
    expectTok(tok(),"String_Node_Str");
  }
 else {
    lexer.unparse();
    joinModel.setJournalName(expr());
  }
  tok=lexer.optionTok();
  if (tok != null && !aliasStopSet.contains(tok)) {
    lexer.unparse();
    joinModel.setAlias(expr());
  }
 else {
    lexer.unparse();
  }
  tok=lexer.optionTok();
  if (type == QueryModel.JoinType.CROSS && tok != null && Chars.equals(tok,"String_Node_Str")) {
    throw QueryError.$(lexer.position(),"String_Node_Str");
  }
switch (type) {
case ASOF:
    if (tok == null || !Chars.equals("String_Node_Str",tok)) {
      lexer.unparse();
      break;
    }
case INNER:
case OUTER:
  expectTok(tok,"String_Node_Str");
ExprNode expr=expr();
if (expr == null) {
throw QueryError.$(lexer.position(),"String_Node_Str");
}
joinModel.setJoinCriteria(expr);
break;
default :
lexer.unparse();
}
return joinModel;
}
Program: 31385
Project: 31385
Buggy source:
public RecordCursor get(MultiMap.KeyWriter key){
  MapValues values=map.getValues(key);
  records.init(values == null ? -1 : values.getLong(0));
  return records;
}

Fixed version (ground truth):
public RecordCursor get(MultiMap.KeyWriter key){
  MapValues values=map.getValues(key);
  records.of(values == null ? -1 : values.getLong(0));
  return records;
}
Program: 31386
Project: 31386
Buggy source:
@Override public Record next(){
  accessor.init(readOffset + 8);
  readOffset=Unsafe.getUnsafe().getLong(mem.addressOf(readOffset));
  return accessor;
}

Fixed version (ground truth):
@Override public Record next(){
  accessor.of(readOffset + 8);
  readOffset=Unsafe.getUnsafe().getLong(mem.addressOf(readOffset));
  return accessor;
}
Program: 31387
Project: 31387
Buggy source:
public Record recordAt(long offset){
  accessor.init(offset + 8);
  return accessor;
}

Fixed version (ground truth):
public Record recordAt(long offset){
  accessor.of(offset + 8);
  return accessor;
}
Program: 31389
Project: 31389
Buggy source:
@Override public Record next(){
  long t=current;
  long p=rightOf(t);
  if (p != 0) {
    long l;
    while ((l=leftOf(p)) != 0) {
      p=l;
    }
  }
 else {
    p=parentOf(t);
    long ch=t;
    while (p != 0 && ch == rightOf(p)) {
      ch=p;
      p=parentOf(p);
    }
  }
  current=p;
  return records.recordAt(refOf(t));
}

Fixed version (ground truth):
@Override public Record next(){
  return records.next();
}
Program: 31390
Project: 31390
Buggy source:
private void put(Record record){
  if (root == 0) {
    root=allocateBlock();
    setRef(root,records.append(record,-1));
    setParent(root,0);
    setLeft(root,0);
    setRight(root,0);
    return;
  }
  comparator.setLeft(record);
  long p=root;
  long parent;
  int cmp;
  do {
    parent=p;
    cmp=comparator.compare(records.recordAt(refOf(p)));
    if (cmp < 0) {
      p=leftOf(p);
    }
 else     if (cmp > 0) {
      p=rightOf(p);
    }
 else {
      setRef(p,records.append(record,refOf(p)));
      return;
    }
  }
 while (p > 0);
  p=allocateBlock();
  setParent(p,parent);
  setRef(p,records.append(record,-1));
  if (cmp < 0) {
    setLeft(parent,p);
  }
 else {
    setRight(parent,p);
  }
  fix(p);
}

Fixed version (ground truth):
private void put(Record record){
  if (root == 0) {
    root=allocateBlock();
    long r=records.append(record,-1);
    setTop(root,r);
    setRef(root,r);
    setParent(root,0);
    setLeft(root,0);
    setRight(root,0);
    return;
  }
  comparator.setLeft(record);
  long p=root;
  long parent;
  int cmp;
  do {
    parent=p;
    cmp=comparator.compare(records.recordAt(refOf(p)));
    if (cmp < 0) {
      p=leftOf(p);
    }
 else     if (cmp > 0) {
      p=rightOf(p);
    }
 else {
      setRef(p,records.append(record,refOf(p)));
      return;
    }
  }
 while (p > 0);
  p=allocateBlock();
  setParent(p,parent);
  long r=records.append(record,-1);
  setTop(p,r);
  setRef(p,r);
  if (cmp < 0) {
    setLeft(parent,p);
  }
 else {
    setRight(parent,p);
  }
  fix(p);
}
Program: 31391
Project: 31391
Buggy source:
@Override public boolean hasNext(){
  return current != 0;
}

Fixed version (ground truth):
@Override public boolean hasNext(){
  if (records.hasNext()) {
    return true;
  }
  current=successor(current);
  if (current == 0) {
    return false;
  }
  records.of(topOf(current));
  return true;
}
Program: 31392
Project: 31392
Buggy source:
@Override public void reset(){
  records.clear();
}

Fixed version (ground truth):
@Override public void reset(){
  recordSource.reset();
  clear();
}
Program: 31393
Project: 31393
Buggy source:
private void setup(){
  long p=root;
  if (p != 0) {
    while (leftOf(p) != 0) {
      p=leftOf(p);
    }
  }
  current=p;
}

Fixed version (ground truth):
private void setup(){
  long p=root;
  if (p != 0) {
    while (leftOf(p) != 0) {
      p=leftOf(p);
    }
  }
  records.of(topOf(current=p));
}
Program: 31394
Project: 31394
Buggy source:
public void clear(){
  columns.clear();
  joinModels.clear();
  joinModels.add(this);
  sampleBy=null;
  orderBy.clear();
  dependencies.clear();
  parsedWhere.clear();
  whereClause=null;
  nestedModel=null;
  journalName=null;
  alias=null;
  latestBy=null;
  recordSource=null;
  metadata=null;
  joinCriteria=null;
  joinType=JoinType.INNER;
  orderedJoinModels1.clear();
  orderedJoinModels2.clear();
  parsedWhereConsts.clear();
  aliasIndexes.clear();
  postJoinWhereClause=null;
  context=null;
  orderedJoinModels=orderedJoinModels2;
  limitHi=null;
  limitLo=null;
  limitHiVc=null;
  limitLoVc=null;
  columnNameFrequencyMap.clear();
  parameterMap.clear();
  timestamp=null;
}

Fixed version (ground truth):
public void clear(){
  columns.clear();
  joinModels.clear();
  joinModels.add(this);
  sampleBy=null;
  orderBy.clear();
  dependencies.clear();
  parsedWhere.clear();
  whereClause=null;
  nestedModel=null;
  journalName=null;
  alias=null;
  latestBy=null;
  recordSource=null;
  metadata=null;
  joinCriteria=null;
  joinType=JoinType.INNER;
  orderedJoinModels1.clear();
  orderedJoinModels2.clear();
  parsedWhereConsts.clear();
  aliasIndexes.clear();
  postJoinWhereClause=null;
  context=null;
  orderedJoinModels=orderedJoinModels2;
  limitHi=null;
  limitLo=null;
  limitHiVc=null;
  limitLoVc=null;
  columnNameFrequencyMap.clear();
  parameterMap.clear();
  timestamp=null;
  orderColumnIndices.clear();
}
Program: 31395
Project: 31395
Buggy source:
private RecordSource order(RecordSource rs,QueryModel model) throws ParserException {
  ObjList<ExprNode> orderBy=model.getOrderBy();
  int n=orderBy.size();
  if (n > 0) {
    RecordMetadata m=rs.getMetadata();
    for (int i=0; i < n; i++) {
      ExprNode tok=orderBy.getQuick(i);
      int index=m.getColumnIndexQuiet(tok.token);
      if (index == -1) {
        throw QueryError.invalidColumn(tok.position,tok.token);
      }
      orderColumnIndices.add(index);
    }
    return new RBTreeSortedRecordSource(rs,cc.compile(RBTreeSortedRecordSource.class,m,orderColumnIndices));
  }
 else {
    return rs;
  }
}

Fixed version (ground truth):
private RecordSource order(RecordSource rs,QueryModel model) throws ParserException {
  ObjList<ExprNode> orderBy=model.getOrderBy();
  IntList indices=model.getOrderColumnIndices();
  int n=orderBy.size();
  if (n > 0) {
    RecordMetadata m=rs.getMetadata();
    for (int i=0; i < n; i++) {
      ExprNode tok=orderBy.getQuick(i);
      int index=m.getColumnIndexQuiet(tok.token);
      if (index == -1) {
        throw QueryError.invalidColumn(tok.position,tok.token);
      }
      indices.add(index);
    }
    return new RBTreeSortedRecordSource(rs,cc.compile(RBTreeSortedRecordSource.class,m,indices));
  }
 else {
    return rs;
  }
}
Program: 31396
Project: 31396
Buggy source:
private void clearState(){
  csPool.clear();
  exprNodePool.clear();
  contextPool.clear();
  intListPool.clear();
  joinClausesSwap1.clear();
  joinClausesSwap2.clear();
  queryFilterAnalyser.reset();
  constNameToIndex.clear();
  constNameToNode.clear();
  constNameToToken.clear();
  orderColumnIndices.clear();
}

Fixed version (ground truth):
private void clearState(){
  csPool.clear();
  exprNodePool.clear();
  contextPool.clear();
  intListPool.clear();
  joinClausesSwap1.clear();
  joinClausesSwap2.clear();
  queryFilterAnalyser.reset();
  constNameToIndex.clear();
  constNameToNode.clear();
  constNameToToken.clear();
}
Program: 31397
Project: 31397
Buggy source:
private <T>void writeAndReadRecords(JournalWriter<T> journal,int count,int pageSize,RecordGenerator<T> generator) throws IOException, JournalException, ParserException {
  for (int i=0; i < count; i++) {
    journal.append(generator.generate(i));
  }
  journal.commit();
  try (MemoryPages buffer=new MemoryPages(pageSize)){
    MemoryRecordAccessor a=new MemoryRecordAccessor(journal.getMetadata(),buffer);
    LongList offsets=new LongList();
    for (    Record rec : compiler.compile(factory,journal.getLocation().getName())) {
      offsets.add(a.append(rec));
    }
    for (int i=0; i < count; i++) {
      a.init(offsets.getQuick(i));
      generator.assertRecord(a,i);
    }
  }
 }

Fixed version (ground truth):
private <T>void writeAndReadRecords(JournalWriter<T> journal,int count,int pageSize,RecordGenerator<T> generator) throws IOException, JournalException, ParserException {
  for (int i=0; i < count; i++) {
    journal.append(generator.generate(i));
  }
  journal.commit();
  try (MemoryPages buffer=new MemoryPages(pageSize)){
    MemoryRecordAccessor a=new MemoryRecordAccessor(journal.getMetadata(),buffer);
    LongList offsets=new LongList();
    for (    Record rec : compiler.compile(factory,journal.getLocation().getName())) {
      offsets.add(a.append(rec));
    }
    for (int i=0; i < count; i++) {
      a.of(offsets.getQuick(i));
      generator.assertRecord(a,i);
    }
  }
 }
Program: 31398
Project: 31398
Buggy source:
private void buildHashTable(){
  for (  Record r : slaveCursor) {
    MultiMap.KeyWriter key=recordMap.claimKey();
    for (int i=0, k=slaveColumns.size(); i < k; i++) {
      setKey(key,r,slaveColIndex.getQuick(i),slaveColumns.getQuick(i).getType());
    }
    if (byRowId) {
      recordMap.add(key,rowIdRecord.of(r.getRowId()));
    }
 else {
      recordMap.add(key,r);
    }
  }
}

Fixed version (ground truth):
private void buildHashTable(){
  for (  Record r : slaveCursor) {
    MultiMap.KeyWriter key=recordMap.claimKey();
    for (int i=0, k=slaveColumns.size(); i < k; i++) {
      setKey(key,r,slaveColIndex.getQuick(i),slaveColumns.getQuick(i).getType());
    }
    if (byRowId) {
      recordMap.add(key,fakeRecord.of(r.getRowId()));
    }
 else {
      recordMap.add(key,r);
    }
  }
}
Program: 31399
Project: 31399
Buggy source:
private MultiRecordMap createRecordMap(RecordSource masterSource,RecordSource slaveSource){
  RecordMetadata mm=masterSource.getMetadata();
  for (int i=0, k=masterColIndex.size(); i < k; i++) {
    this.masterColumns.add(mm.getColumnQuick(masterColIndex.getQuick(i)));
  }
  RecordMetadata sm=slaveSource.getMetadata();
  ObjHashSet<String> keyCols=new ObjHashSet<>();
  for (int i=0, k=slaveColIndex.size(); i < k; i++) {
    int index=slaveColIndex.getQuick(i);
    this.slaveColumns.add(sm.getColumnQuick(index));
    keyCols.add(sm.getColumnName(index));
  }
  return byRowId ? new MultiRecordMap(sm,keyCols,rowIdRecord.getMetadata()) : new MultiRecordMap(sm,keyCols,slaveSource.getMetadata());
}

Fixed version (ground truth):
private MultiRecordMap createRecordMap(RecordSource masterSource,RecordSource slaveSource){
  RecordMetadata mm=masterSource.getMetadata();
  for (int i=0, k=masterColIndex.size(); i < k; i++) {
    this.masterColumns.add(mm.getColumnQuick(masterColIndex.getQuick(i)));
  }
  RecordMetadata sm=slaveSource.getMetadata();
  ObjHashSet<String> keyCols=new ObjHashSet<>();
  for (int i=0, k=slaveColIndex.size(); i < k; i++) {
    int index=slaveColIndex.getQuick(i);
    this.slaveColumns.add(sm.getColumnQuick(index));
    keyCols.add(sm.getColumnName(index));
  }
  return byRowId ? new MultiRecordMap(sm,keyCols,fakeRecord.getMetadata()) : new MultiRecordMap(sm,keyCols,slaveSource.getMetadata());
}
Program: 31400
Project: 31400
Buggy source:
public RBTreeSortedRecordSource(RecordSource recordSource,RecordComparator comparator){
  this.recordSource=recordSource;
  this.comparator=comparator;
  this.mem=new MemoryPages(1024 * 1024);
  this.byRowId=recordSource.supportsRowIdAccess();
  this.records=new RecordDequeue(byRowId ? rowIdRecord.getMetadata() : recordSource.getMetadata(),4 * 1024 * 1024);
}

Fixed version (ground truth):
public RBTreeSortedRecordSource(RecordSource recordSource,RecordComparator comparator){
  this.recordSource=recordSource;
  this.comparator=comparator;
  this.mem=new MemoryPages(1024 * 1024);
  this.byRowId=recordSource.supportsRowIdAccess();
  this.records=new RecordDequeue(byRowId ? fakeRecord.getMetadata() : recordSource.getMetadata(),4 * 1024 * 1024);
}
Program: 31401
Project: 31401
Buggy source:
private void put(long rowId){
  if (root == 0) {
    putParent(rowIdRecord.of(rowId));
    return;
  }
  comparator.setLeft(sourceCursor.getByRowId(rowId));
  long p=root;
  long parent;
  int cmp;
  do {
    parent=p;
    long r=refOf(p);
    cmp=comparator.compare(sourceCursor.getByRowId(records.recordAt(r).getLong(0)));
    if (cmp < 0) {
      p=leftOf(p);
    }
 else     if (cmp > 0) {
      p=rightOf(p);
    }
 else {
      setRef(p,records.append(rowIdRecord.of(rowId),r));
      return;
    }
  }
 while (p > 0);
  p=allocateBlock();
  setParent(p,parent);
  long r=records.append(rowIdRecord.of(rowId),(long)-1);
  setTop(p,r);
  setRef(p,r);
  if (cmp < 0) {
    setLeft(parent,p);
  }
 else {
    setRight(parent,p);
  }
  fix(p);
}

Fixed version (ground truth):
private void put(long rowId){
  if (root == 0) {
    putParent(fakeRecord.of(rowId));
    return;
  }
  comparator.setLeft(sourceCursor.getByRowId(rowId));
  long p=root;
  long parent;
  int cmp;
  do {
    parent=p;
    long r=refOf(p);
    cmp=comparator.compare(sourceCursor.getByRowId(records.recordAt(r).getLong(0)));
    if (cmp < 0) {
      p=leftOf(p);
    }
 else     if (cmp > 0) {
      p=rightOf(p);
    }
 else {
      setRef(p,records.append(fakeRecord.of(rowId),r));
      return;
    }
  }
 while (p > 0);
  p=allocateBlock();
  setParent(p,parent);
  long r=records.append(fakeRecord.of(rowId),(long)-1);
  setTop(p,r);
  setRef(p,r);
  if (cmp < 0) {
    setLeft(parent,p);
  }
 else {
    setRight(parent,p);
  }
  fix(p);
}
Program: 31402
Project: 31402
Buggy source:
@Override public long getRowId(){
  return 0;
}

Fixed version (ground truth):
@Override public long getRowId(){
  return base.getRowId();
}
Program: 31403
Project: 31403
Buggy source:
public VirtualRecord(RecordMetadata metadata,int split,ObjList<VirtualColumn> virtualColumns){
  super(metadata);
  this.split=split;
  this.virtualColumns=virtualColumns;
}

Fixed version (ground truth):
VirtualRecord(RecordMetadata metadata,int split,ObjList<VirtualColumn> virtualColumns){
  super(metadata);
  this.split=split;
  this.virtualColumns=virtualColumns;
}
Program: 31404
Project: 31404
Buggy source:
void release(final JournalCachingFactory factory){
  if (running.get()) {
    factory.expireOpenFiles();
    pool.addFirst(factory);
  }
 else {
    factory.clearPool();
    factory.close();
  }
}

Fixed version (ground truth):
void release(final JournalCachingFactory factory){
  if (running.get()) {
    if (openCount.get() < capacity) {
      factory.expireOpenFiles();
      pool.addFirst(factory);
      return;
    }
  }
  openCount.decrementAndGet();
  factory.clearPool();
  factory.close();
}
Program: 31405
Project: 31405
Buggy source:
public JournalCachingFactory get() throws InterruptedException {
  if (running.get()) {
    JournalCachingFactory factory=pool.poll();
    if (factory == null) {
      int index=allLength.incrementAndGet() - 1;
      if (index < capacity) {
        factory=new JournalCachingFactory(configuration,this);
      }
    }
 else {
      factory.setInUse();
    }
    return factory;
  }
 else {
    throw new InterruptedException("String_Node_Str");
  }
}

Fixed version (ground truth):
public JournalCachingFactory get() throws InterruptedException {
  if (running.get()) {
    JournalCachingFactory factory=pool.poll();
    if (factory == null) {
      openCount.incrementAndGet();
      factory=new JournalCachingFactory(configuration,this);
    }
 else {
      factory.setInUse();
    }
    return factory;
  }
 else {
    throw new InterruptedException("String_Node_Str");
  }
}
Program: 31408
Project: 31408
Buggy source:
@Override public void clear(){
  debug().$("String_Node_Str").$();
  metadata=null;
  records=null;
  current=null;
  if (factory != null) {
    debug().$("String_Node_Str").$();
    factory.close();
    factory=null;
  }
  if (recordSource != null) {
    queryCompilerLocal.get().reuse(query,recordSource);
    recordSource=null;
  }
  query=null;
}

Fixed version (ground truth):
@Override public void clear(){
  debug().$("String_Node_Str").$();
  metadata=null;
  cursor=null;
  record=null;
  debug().$("String_Node_Str").$();
  factory=Misc.free(factory);
  if (recordSource != null) {
    COMPILER.get().reuse(query,recordSource);
    recordSource=null;
  }
  query=null;
}
Program: 31411
Project: 31411
Buggy source:
public KeyWriter putStr(CharSequence value){
  int len=value.length();
  checkSize(len << 1);
  for (int i=0; i < len; i++) {
    Unsafe.getUnsafe().putChar(appendAddr + (i << 1),value.charAt(i));
  }
  appendAddr+=len << 1;
  writeOffset();
  return this;
}

Fixed version (ground truth):
public KeyWriter putStr(CharSequence value){
  if (value == null) {
    Unsafe.getUnsafe().putInt(nextColOffset,0);
    nextColOffset+=4;
  }
 else {
    int len=value.length();
    checkSize(len << 1);
    for (int i=0; i < len; i++) {
      Unsafe.getUnsafe().putChar(appendAddr + (i << 1),value.charAt(i));
    }
    appendAddr+=len << 1;
    writeOffset();
  }
  return this;
}
Program: 31412
Project: 31412
Buggy source:
public void reuse(CharSequence query,RecordSource rs){
  if (query != null) {
    cache.put(query,rs);
  }
}

Fixed version (ground truth):
public void reuse(CharSequence query,RecordSource rs){
  if (query != null) {
    cache.put(query.toString(),rs);
  }
}
Program: 31413
Project: 31413
Buggy source:
public RecordSource compileSource(JournalReaderFactory factory,CharSequence query) throws ParserException, JournalException {
  RecordSource rs=cache.peek(query);
  if (rs == null) {
    cache.put(query,rs=resetAndCompile(factory,query));
  }
 else {
    rs.reset();
  }
  return rs;
}

Fixed version (ground truth):
public RecordSource compileSource(JournalReaderFactory factory,CharSequence query) throws ParserException, JournalException {
  RecordSource rs=cache.peek(query);
  if (rs == null) {
    cache.put(query.toString(),rs=resetAndCompile(factory,query));
  }
 else {
    rs.reset();
  }
  return rs;
}
Program: 31414
Project: 31414
Buggy source:
public V poll(CharSequence key){
  int index=getIndex(key);
  if (index == NOT_FOUND) {
    return null;
  }
  V value=Unsafe.arrayGet(values,index);
  Unsafe.arrayPut(values,index,null);
  return value;
}

Fixed version (ground truth):
public V poll(CharSequence key){
  int index=getIndex(key);
  if (index == NOT_FOUND) {
    return null;
  }
  V value=Unsafe.arrayGet(values,index);
  Unsafe.arrayPut(values,index,null);
  Unsafe.arrayPut(keys,index,null);
  return value;
}
Program: 31415
Project: 31415
Buggy source:
@Test public void testJsonEncodeNumbers() throws Exception {
  generateJournal(null,1.900232E-10,Double.MAX_VALUE,Long.MAX_VALUE,Integer.MIN_VALUE,10);
  HttpServer server=new HttpServer(new HttpServerConfiguration(),new SimpleUrlMatcher(){
{
      put("String_Node_Str",createHandler());
    }
  }
);
  server.start();
  try {
    String query="String_Node_Str";
    QueryResponse queryResponse=download(query);
    Assert.assertEquals(1.900232E-10,queryResponse.result[0].x,1E-6);
    Assert.assertEquals(Double.MAX_VALUE,queryResponse.result[0].y,1E-6);
    Assert.assertEquals(Long.MAX_VALUE,queryResponse.result[0].z);
    Assert.assertEquals(0,queryResponse.result[0].w);
    Assert.assertEquals(10,queryResponse.result[0].timestamp);
    Assert.assertEquals(false,queryResponse.moreExist);
  }
  finally {
    factoryPool.close();
    server.halt();
  }
}

Fixed version (ground truth):
@Test public void testJsonEncodeNumbers() throws Exception {
  generateJournal(null,1.900232E-10,Double.MAX_VALUE,Long.MAX_VALUE,Integer.MIN_VALUE,10);
  HttpServer server=new HttpServer(new HttpServerConfiguration(),new SimpleUrlMatcher(){
{
      put("String_Node_Str",createHandler());
    }
  }
);
  server.start();
  try {
    String query="String_Node_Str";
    QueryResponse queryResponse=download(query);
    Assert.assertEquals(1.900232E-10,queryResponse.result[0].x,1E-6);
    Assert.assertEquals(Double.MAX_VALUE,queryResponse.result[0].y,1E-6);
    Assert.assertEquals(Long.MAX_VALUE,queryResponse.result[0].z);
    Assert.assertEquals(0,queryResponse.result[0].w);
    Assert.assertEquals(10,queryResponse.result[0].timestamp);
    Assert.assertEquals(false,queryResponse.moreExist);
    Assert.assertEquals("String_Node_Str",queryResponse.result[4].id);
    Assert.assertTrue(Double.isNaN(queryResponse.result[4].y));
  }
  finally {
    factoryPool.close();
    server.halt();
  }
}
Program: 31416
Project: 31416
Buggy source:
@Test public void testJsonPooling() throws Exception {
  generateJournal();
  HttpServer server=new HttpServer(new HttpServerConfiguration(),new SimpleUrlMatcher(){
{
      put("String_Node_Str",createHandler());
    }
  }
);
  server.start();
  try {
    QueryResponse queryResponse1=download("String_Node_Str");
    QueryResponse queryResponse2=download("String_Node_Str");
    Assert.assertEquals(10,queryResponse1.result.length);
    Assert.assertEquals(10,queryResponse2.result.length);
  }
  finally {
    factoryPool.close();
    server.halt();
  }
}

Fixed version (ground truth):
@Test public void testJsonPooling() throws Exception {
  generateJournal();
  final JsonHandler[] handler=new JsonHandler[1];
  HttpServer server=new HttpServer(new HttpServerConfiguration(),new SimpleUrlMatcher(){
{
      put("String_Node_Str",handler[0]=createHandler());
    }
  }
);
  server.start();
  try {
    QueryResponse queryResponse1=download("String_Node_Str");
    QueryResponse queryResponse2=download("String_Node_Str");
    QueryResponse queryResponse3=download("String_Node_Str");
    QueryResponse queryResponse4=download("String_Node_Str");
    Assert.assertEquals(10,queryResponse1.result.length);
    Assert.assertEquals(10,queryResponse2.result.length);
    Assert.assertEquals(10,queryResponse3.result.length);
    Assert.assertEquals(10,queryResponse4.result.length);
  }
  finally {
    factoryPool.close();
    server.halt();
  }
}
Program: 31417
Project: 31417
Buggy source:
@SuppressWarnings("String_Node_Str") public JournalFactoryPool(JournalConfiguration configuration,int capacity) throws InterruptedException {
  this.configuration=configuration;
  this.capacity=capacity;
  this.pool=new ConcurrentLinkedDeque<>();
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public JournalFactoryPool(JournalConfiguration configuration,int capacity){
  this.configuration=configuration;
  this.capacity=capacity;
  this.pool=new ConcurrentLinkedDeque<>();
}
Program: 31418
Project: 31418
Buggy source:
public JournalCachingFactory get() throws InterruptedException, JournalException {
  if (running.get()) {
    JournalCachingFactory factory=pool.poll();
    if (factory == null) {
      int index=allLength.incrementAndGet() - 1;
      if (index < capacity) {
        factory=new JournalCachingFactory(configuration,this);
      }
    }
 else {
      factory.setInUse();
    }
    return factory;
  }
 else {
    throw new InterruptedException("String_Node_Str");
  }
}

Fixed version (ground truth):
public JournalCachingFactory get() throws InterruptedException {
  if (running.get()) {
    JournalCachingFactory factory=pool.poll();
    if (factory == null) {
      int index=allLength.incrementAndGet() - 1;
      if (index < capacity) {
        factory=new JournalCachingFactory(configuration,this);
      }
    }
 else {
      factory.setInUse();
    }
    return factory;
  }
 else {
    throw new InterruptedException("String_Node_Str");
  }
}
Program: 31419
Project: 31419
Buggy source:
@Override public void close(){
  if (running.get()) {
    running.set(false);
    JournalCachingFactory factory;
    while ((factory=pool.poll()) != null) {
      try {
        factory.clearPool();
        factory.close();
      }
 catch (      Throwable ex) {
        LOG.info().$("String_Node_Str").$(ex).$();
      }
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  if (running.compareAndSet(true,false)) {
    JournalCachingFactory factory;
    while ((factory=pool.poll()) != null) {
      try {
        factory.clearPool();
        factory.close();
      }
 catch (      Throwable ex) {
        LOG.info().$("String_Node_Str").$(ex).$();
      }
    }
  }
}
Program: 31420
Project: 31420
Buggy source:
public void halt() throws IOException, InterruptedException {
  if (running) {
    running=false;
    startComplete.await();
    for (int i=0; i < workers.size(); i++) {
      workers.getQuick(i).halt();
    }
    haltLatch.await();
    dispatcher.close();
    for (int i=0; i < ioQueue.getCapacity(); i++) {
      IOEvent ev=ioQueue.get(i);
      if (ev != null && ev.context != null) {
        ev.context.close();
      }
    }
  }
}

Fixed version (ground truth):
public void halt() throws IOException, InterruptedException {
  if (running) {
    running=false;
    startComplete.await();
    for (int i=0; i < workers.size(); i++) {
      workers.getQuick(i).halt();
    }
    haltLatch.await();
    dispatcher.close();
    for (int i=0; i < ioQueue.getCapacity(); i++) {
      IOEvent ev=ioQueue.get(i);
      if (ev != null && ev.context != null) {
        ev.context=Misc.free(ev.context);
      }
    }
  }
}
Program: 31421
Project: 31421
Buggy source:
@Override public void close(){
  Misc.free(channel);
  request.close();
  response.close();
  map.close();
}

Fixed version (ground truth):
@Override public void close(){
  if (open.compareAndSet(true,false)) {
    Misc.free(channel);
    Misc.free(request);
    Misc.free(response);
    Misc.free(map);
  }
}
Program: 31422
Project: 31422
Buggy source:
void prepare(RecordMetadata metadata,ObjList<RecordColumnMetadata> columns,int offset);

Fixed version (ground truth):
void prepare(ObjList<RecordColumnMetadata> columns,int offset);