nus-yam/ex-repair huggingface dataset:
Program: 30952
Project: 30952
Buggy source:
@SuppressWarnings("String_Node_Str") private static float parseFloat(CharSequence sequence,int lo,int lim) throws NumericException {
  int p=lo;
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  if (negative) {
    p++;
  }
  if (p >= lim) {
    throw NumericException.INSTANCE;
  }
switch (sequence.charAt(p)) {
case 'N':
    return parseFloatConst(sequence,p,lim,NaN,Float.NaN);
case 'I':
  return parseFloatConst(sequence,p,lim,INFINITY,negative ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY);
default :
break;
}
int val=0;
int dp=-1;
int dpe=lim;
int exp=0;
out: for (int i=p; i < lim; i++) {
int c=sequence.charAt(i);
switch (c) {
case '.':
dp=i;
continue;
case 'E':
case 'e':
exp=parseInt(sequence,i + 1,lim);
if (dpe == lim) {
dpe=i;
}
break out;
case 'F':
case 'f':
if (i + 1 < lim) {
throw NumericException.INSTANCE;
}
if (dpe == lim) {
dpe=i;
}
break out;
default :
if (c < '0' || c > '9') {
throw NumericException.INSTANCE;
}
if (val <= INT_OVERFLOW_MAX) {
val=(val << 3) + (val << 1) + (c - '0');
}
 else if (dpe == lim) {
dpe=i;
}
break;
}
}
exp=dp == -1 ? exp : exp - (dpe - dp - 1);
if (exp > 38) {
exp=38;
}
 else if (exp < -38) {
exp=-38;
}
if (exp > 0) {
return (negative ? -val : val) * pow10f[exp];
}
 else {
return (negative ? -val : val) / pow10f[-exp];
}
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static float parseFloat(CharSequence sequence,int lo,int lim) throws NumericException {
  int p=lo;
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  if (negative) {
    p++;
  }
  if (p >= lim) {
    throw NumericException.INSTANCE;
  }
switch (sequence.charAt(p)) {
case 'N':
    return parseFloatConst(sequence,p,lim,NaN,Float.NaN);
case 'I':
  return parseFloatConst(sequence,p,lim,INFINITY,negative ? Float.NEGATIVE_INFINITY : Float.POSITIVE_INFINITY);
default :
break;
}
int val=0;
int dp=-1;
int dpe=lim;
int exp=0;
out: for (int i=p; i < lim; i++) {
int c=sequence.charAt(i);
switch (c) {
case '.':
dp=i;
continue;
case 'E':
case 'e':
exp=parseInt(sequence,i + 1,lim);
if (dpe == lim) {
dpe=i;
}
break out;
case 'F':
case 'f':
if (i == 0 || i + 1 < lim) {
throw NumericException.INSTANCE;
}
if (dpe == lim) {
dpe=i;
}
break out;
default :
if (c < '0' || c > '9') {
throw NumericException.INSTANCE;
}
if (val <= INT_OVERFLOW_MAX) {
val=(val << 3) + (val << 1) + (c - '0');
}
 else if (dpe == lim) {
dpe=i;
}
break;
}
}
exp=dp == -1 ? exp : exp - (dpe - dp - 1);
if (exp > 38) {
exp=38;
}
 else if (exp < -38) {
exp=-38;
}
if (exp > 0) {
return (negative ? -val : val) * pow10f[exp];
}
 else {
return (negative ? -val : val) / pow10f[-exp];
}
}
Program: 30953
Project: 30953
Buggy source:
@SuppressWarnings("String_Node_Str") private static double parseDouble(CharSequence sequence,final int p,int lim) throws NumericException {
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  int i=p;
  if (negative) {
    i++;
  }
  if (i >= lim) {
    throw NumericException.INSTANCE;
  }
switch (sequence.charAt(i)) {
case 'N':
    return parseConst(sequence,i,lim,NaN,Double.NaN);
case 'I':
  return parseConst(sequence,i,lim,INFINITY,negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);
default :
break;
}
long val=0;
int dp=-1;
int dpe=lim;
int exp=0;
out: for (; i < lim; i++) {
int c=sequence.charAt(i);
switch (c) {
case '.':
dp=i;
continue;
case 'E':
case 'e':
exp=parseInt(sequence,i + 1,lim);
if (dpe == lim) {
dpe=i;
}
break out;
case 'D':
case 'd':
if (i + 1 < lim) {
throw NumericException.INSTANCE;
}
if (dpe == lim) {
dpe=i;
}
break out;
default :
if (c < '0' || c > '9') {
throw NumericException.INSTANCE;
}
if (val <= LONG_OVERFLOW_MAX) {
val=(val << 3) + (val << 1) + (c - '0');
}
 else if (dpe == lim) {
dpe=i;
}
break;
}
}
exp=dp == -1 ? exp : exp - (dpe - dp - 1);
if (exp > 308) {
exp=308;
}
 else if (exp < -308) {
exp=-308;
}
if (exp > 0) {
return (negative ? -val : val) * pow10d[exp];
}
 else {
return (negative ? -val : val) / pow10d[-exp];
}
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private static double parseDouble(CharSequence sequence,final int p,int lim) throws NumericException {
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  int i=p;
  if (negative) {
    i++;
  }
  if (i >= lim) {
    throw NumericException.INSTANCE;
  }
switch (sequence.charAt(i)) {
case 'N':
    return parseConst(sequence,i,lim,NaN,Double.NaN);
case 'I':
  return parseConst(sequence,i,lim,INFINITY,negative ? Double.NEGATIVE_INFINITY : Double.POSITIVE_INFINITY);
default :
break;
}
long val=0;
int dp=-1;
int dpe=lim;
int exp=0;
out: for (; i < lim; i++) {
int c=sequence.charAt(i);
switch (c) {
case '.':
dp=i;
continue;
case 'E':
case 'e':
exp=parseInt(sequence,i + 1,lim);
if (dpe == lim) {
dpe=i;
}
break out;
case 'D':
case 'd':
if (i + 1 < lim || i == 0) {
throw NumericException.INSTANCE;
}
if (dpe == lim) {
dpe=i;
}
break out;
default :
if (c < '0' || c > '9') {
throw NumericException.INSTANCE;
}
if (val <= LONG_OVERFLOW_MAX) {
val=(val << 3) + (val << 1) + (c - '0');
}
 else if (dpe == lim) {
dpe=i;
}
break;
}
}
exp=dp == -1 ? exp : exp - (dpe - dp - 1);
if (exp > 308) {
exp=308;
}
 else if (exp < -308) {
exp=-308;
}
if (exp > 0) {
return (negative ? -val : val) * pow10d[exp];
}
 else {
return (negative ? -val : val) / pow10d[-exp];
}
}
Program: 30954
Project: 30954
Buggy source:
private static long parseLong0(CharSequence sequence,final int p,int lim) throws NumericException {
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  int i=p;
  if (negative) {
    i++;
  }
  if (i >= lim) {
    throw NumericException.INSTANCE;
  }
  long val=0;
  for (; i < lim; i++) {
    int c=sequence.charAt(i);
    if (c == 'L' || c == 'l') {
      if (i + 1 < lim) {
        throw NumericException.INSTANCE;
      }
      break;
    }
    if (c < '0' || c > '9') {
      throw NumericException.INSTANCE;
    }
    long r=(val << 3) + (val << 1) - (c - '0');
    if (r > val) {
      throw NumericException.INSTANCE;
    }
    val=r;
  }
  if (val == Long.MIN_VALUE && !negative) {
    throw NumericException.INSTANCE;
  }
  return negative ? val : -val;
}

Fixed version (ground truth):
private static long parseLong0(CharSequence sequence,final int p,int lim) throws NumericException {
  if (lim == p) {
    throw NumericException.INSTANCE;
  }
  boolean negative=sequence.charAt(p) == '-';
  int i=p;
  if (negative) {
    i++;
  }
  if (i >= lim) {
    throw NumericException.INSTANCE;
  }
  long val=0;
  for (; i < lim; i++) {
    int c=sequence.charAt(i);
    if (c == 'L' || c == 'l') {
      if (i == 0 || i + 1 < lim) {
        throw NumericException.INSTANCE;
      }
      break;
    }
    if (c < '0' || c > '9') {
      throw NumericException.INSTANCE;
    }
    long r=(val << 3) + (val << 1) - (c - '0');
    if (r > val) {
      throw NumericException.INSTANCE;
    }
    val=r;
  }
  if (val == Long.MIN_VALUE && !negative) {
    throw NumericException.INSTANCE;
  }
  return negative ? val : -val;
}
Program: 30955
Project: 30955
Buggy source:
@Override public void onLineCount(int count){
  if (calcTypes(count,true) && (forceHeader || !calcTypes(count - 1,false))) {
    for (int i=0; i < fieldCount; i++) {
      _metadata.getQuick(i).name=_headers.getQuick(i);
    }
    header=true;
  }
  if (!header) {
    for (int i=0; i < fieldCount; i++) {
      tempSink.clear();
      tempSink.put('f').put(i);
      _metadata.getQuick(i).name=tempSink.toString();
    }
  }
  if (schemaColumns.size() > 0) {
    for (int i=0, k=_metadata.size(); i < k; i++) {
      ImportedColumnMetadata _m=_metadata.getQuick(i);
      ImportedColumnMetadata m=schemaColumns.get(_m.name);
      if (m != null) {
        _m.importedColumnType=m.importedColumnType;
      }
    }
  }
}

Fixed version (ground truth):
@Override public void onLineCount(int count){
  if ((calcTypes(count,true) && !calcTypes(count - 1,false)) || forceHeader) {
    for (int i=0; i < fieldCount; i++) {
      _metadata.getQuick(i).name=_headers.getQuick(i);
    }
    header=true;
  }
  if (!header) {
    for (int i=0; i < fieldCount; i++) {
      tempSink.clear();
      tempSink.put('f').put(i);
      _metadata.getQuick(i).name=tempSink.toString();
    }
  }
  if (schemaColumns.size() > 0) {
    for (int i=0, k=_metadata.size(); i < k; i++) {
      ImportedColumnMetadata _m=_metadata.getQuick(i);
      ImportedColumnMetadata m=schemaColumns.get(_m.name);
      if (m != null) {
        _m.importedColumnType=m.importedColumnType;
      }
    }
  }
}
Program: 30956
Project: 30956
Buggy source:
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  if (journal instanceof R) {
    Entry e=entries.get(name);
    if (e == null) {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
      return true;
    }
    long thread=Thread.currentThread().getId();
    R r=(R)journal;
    if (Unsafe.arrayGet(r.entry.allocations,r.index) == thread) {
      if (closed) {
        Unsafe.arrayPut(r.entry.readers,r.index,null);
        return true;
      }
      Unsafe.arrayPut(r.entry.releaseTimes,r.index,System.currentTimeMillis());
      Unsafe.arrayPutOrdered(r.entry.allocations,r.index,-1L);
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
      return false;
    }
    LOG.error().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(r.entry.index).$(',').$(r.index).$();
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  if (journal instanceof R) {
    Entry e=entries.get(name);
    if (e == null) {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
      return true;
    }
    long thread=Thread.currentThread().getId();
    R r=(R)journal;
    if (Unsafe.arrayGet(r.entry.allocations,r.index) == thread) {
      if (closed) {
        Unsafe.arrayPut(r.entry.readers,r.index,null);
        return true;
      }
      Unsafe.arrayPut(r.entry.releaseTimes,r.index,System.currentTimeMillis());
      Unsafe.arrayPutOrdered(r.entry.allocations,r.index,UNALLOCATED);
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
      return false;
    }
    LOG.error().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(r.entry.index).$(',').$(r.index).$();
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$();
  }
  return true;
}
Program: 30958
Project: 30958
Buggy source:
private void releaseAll(long deadline){
  long thread=Thread.currentThread().getId();
  R r;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (deadline > Unsafe.arrayGet(e.releaseTimes,i) && (r=Unsafe.arrayGet(e.readers,i)) != null) {
          if (Unsafe.cas(e.allocations,i,-1L,thread)) {
            if (deadline > Unsafe.arrayGet(e.releaseTimes,i)) {
              r.setCloseInterceptor(null);
              try {
                r.close();
              }
 catch (              Throwable e1) {
                LOG.error().$("String_Node_Str").$(r.getName()).$("String_Node_Str").$(e1.getMessage()).$();
              }
              Unsafe.arrayPut(e.readers,i,null);
            }
          }
        }
      }
      e=e.next;
    }
 while (e != null);
  }
}

Fixed version (ground truth):
private void releaseAll(long deadline){
  long thread=Thread.currentThread().getId();
  R r;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (deadline > Unsafe.arrayGet(e.releaseTimes,i) && (r=Unsafe.arrayGet(e.readers,i)) != null) {
          if (Unsafe.cas(e.allocations,i,UNALLOCATED,thread)) {
            if (deadline > Unsafe.arrayGet(e.releaseTimes,i)) {
              r.setCloseInterceptor(null);
              try {
                r.close();
              }
 catch (              Throwable e1) {
                LOG.error().$("String_Node_Str").$(r.getName()).$("String_Node_Str").$(e1.getMessage()).$();
              }
              Unsafe.arrayPut(e.readers,i,null);
            }
            Unsafe.arrayPutOrdered(e.allocations,i,UNALLOCATED);
          }
        }
      }
      e=e.next;
    }
 while (e != null);
  }
}
Program: 30959
Project: 30959
Buggy source:
public int countFreeWriters(){
  int count=0;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    if (me.getValue().owner == -1L) {
      count++;
    }
  }
  return count;
}

Fixed version (ground truth):
int countFreeWriters(){
  int count=0;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    if (e.owner == -1L) {
      count++;
    }
 else {
      LOG.info().$("String_Node_Str").$(me.getKey()).$("String_Node_Str").$(me.getValue().owner).$();
    }
  }
  return count;
}
Program: 30960
Project: 30960
Buggy source:
private boolean releaseAll(long deadline){
  long threadId=Thread.currentThread().getId();
  boolean removed=false;
  Iterator<Map.Entry<String,Entry>> iterator=entries.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<String,Entry> me=iterator.next();
    Entry e=me.getValue();
    if ((deadline > e.lastReleaseTime && e.owner == -1)) {
      if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,threadId)) {
        LOG.info().$("String_Node_Str").$(me.getKey()).$('\'').$();
        e.writer.setCloseInterceptor(null);
        try {
          e.writer.close();
        }
 catch (        Throwable e1) {
          LOG.error().$("String_Node_Str").$(e.writer.getName()).$("String_Node_Str").$(e1.getMessage()).$();
        }
        iterator.remove();
        removed=true;
        Unsafe.getUnsafe().putOrderedLong(e,ENTRY_OWNER,-1L);
      }
    }
 else     if (e.allocationFailure) {
      LOG.info().$("String_Node_Str").$(me.getKey()).$('\'').$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}

Fixed version (ground truth):
private boolean releaseAll(long deadline){
  long threadId=Thread.currentThread().getId();
  boolean removed=false;
  Iterator<Map.Entry<String,Entry>> iterator=entries.entrySet().iterator();
  while (iterator.hasNext()) {
    Map.Entry<String,Entry> me=iterator.next();
    Entry e=me.getValue();
    if ((deadline > e.lastReleaseTime && e.owner == -1)) {
      if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,threadId)) {
        LOG.info().$("String_Node_Str").$(me.getKey()).$('\'').$();
        JournalWriter w=e.writer;
        if (w != null) {
          w.setCloseInterceptor(null);
          try {
            w.close();
          }
 catch (          Throwable e1) {
            LOG.error().$("String_Node_Str").$(w.getName()).$("String_Node_Str").$(e1.getMessage()).$();
          }
        }
        iterator.remove();
        removed=true;
        Unsafe.getUnsafe().putOrderedLong(e,ENTRY_OWNER,-1L);
      }
    }
 else     if (e.allocationFailure) {
      LOG.info().$("String_Node_Str").$(me.getKey()).$('\'').$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}
Program: 30962
Project: 30962
Buggy source:
@Test public void testAllocateAndClear() throws Exception {
  final JournalMetadata<?> m=theFactory.getConfiguration().buildWithRootLocation(new JournalStructure("String_Node_Str").$date("String_Node_Str").$());
  final CachingWriterFactory wf=theFactory.getCachingWriterFactory();
  int n=2;
  final CyclicBarrier barrier=new CyclicBarrier(n);
  final CountDownLatch halt=new CountDownLatch(n);
  final AtomicInteger errors=new AtomicInteger();
  final AtomicInteger writerCount=new AtomicInteger();
  new Thread(){
    @Override public void run(){
      try {
        for (int i=0; i < 1000; i++) {
          try (JournalWriter w=wf.writer(m)){
            if (w != null) {
              writerCount.incrementAndGet();
            }
          }
           if (i == 1) {
            barrier.await();
          }
          LockSupport.parkNanos(10L);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        errors.incrementAndGet();
      }
 finally {
        halt.countDown();
      }
    }
  }
.start();
  new Thread(){
    @Override public void run(){
      try {
        barrier.await();
        for (int i=0; i < 1000; i++) {
          wf.run();
          LockSupport.parkNanos(10L);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        errors.incrementAndGet();
      }
 finally {
        halt.countDown();
      }
    }
  }
.start();
  halt.await();
  Assert.assertTrue(writerCount.get() > 0);
  Assert.assertEquals(0,errors.get());
  Assert.assertEquals(1,wf.countFreeWriters());
}

Fixed version (ground truth):
@Test public void testAllocateAndClear() throws Exception {
  final JournalMetadata<?> m=theFactory.getConfiguration().buildWithRootLocation(new JournalStructure("String_Node_Str").$date("String_Node_Str").$());
  final CachingWriterFactory wf=theFactory.getCachingWriterFactory();
  int n=2;
  final CyclicBarrier barrier=new CyclicBarrier(n);
  final CountDownLatch halt=new CountDownLatch(n);
  final AtomicInteger errors=new AtomicInteger();
  final AtomicInteger writerCount=new AtomicInteger();
  new Thread(){
    @Override public void run(){
      try {
        for (int i=0; i < 1000; i++) {
          try (JournalWriter w=wf.writer(m)){
            if (w != null) {
              writerCount.incrementAndGet();
            }
          }
           if (i == 1) {
            barrier.await();
          }
          LockSupport.parkNanos(10L);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        errors.incrementAndGet();
      }
 finally {
        halt.countDown();
      }
    }
  }
.start();
  new Thread(){
    @Override public void run(){
      try {
        barrier.await();
        for (int i=0; i < 1000; i++) {
          wf.run();
          LockSupport.parkNanos(10L);
        }
      }
 catch (      Exception e) {
        e.printStackTrace();
        errors.incrementAndGet();
      }
 finally {
        halt.countDown();
      }
    }
  }
.start();
  halt.await();
  Assert.assertTrue(writerCount.get() > 0);
  Assert.assertEquals(0,errors.get());
}
Program: 30963
Project: 30963
Buggy source:
private JournalWriter checkAndReturn(long thread,Entry e,String name,JournalMetadata<?> metadata) throws JournalException {
  JournalMetadata wm=e.writer.getMetadata();
  if (metadata.isCompatible(wm,false)) {
    if (metadata.getModelClass() != null && wm.getModelClass() == null) {
      closeWriter(thread,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX,FactoryConstants.CR_REOPEN);
      createWriter(thread,name,e,metadata);
    }
 else {
      notifyListener(thread,name,FactoryEventListener.EV_GET);
    }
    return e.writer;
  }
  JournalMetadataException ex=new JournalMetadataException(wm,metadata);
  notifyListener(thread,name,FactoryEventListener.EV_INCOMPATIBLE);
  if (closed) {
    closeWriter(thread,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX,FactoryConstants.CR_POOL_CLOSE);
  }
  e.owner=-1L;
  throw ex;
}

Fixed version (ground truth):
private JournalWriter checkAndReturn(long thread,Entry e,String name,JournalMetadata<?> metadata) throws JournalException {
  JournalMetadata wm=e.writer.getMetadata();
  if (metadata.isCompatible(wm,false)) {
    if (metadata.getModelClass() != null && wm.getModelClass() == null) {
      closeWriter(thread,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX,FactoryConstants.CR_REOPEN);
      return createWriter(thread,name,e,metadata);
    }
 else {
      LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(thread).$();
      notifyListener(thread,name,FactoryEventListener.EV_GET);
      return e.writer;
    }
  }
  JournalMetadataException ex=new JournalMetadataException(wm,metadata);
  notifyListener(thread,name,FactoryEventListener.EV_INCOMPATIBLE);
  if (closed) {
    closeWriter(thread,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX,FactoryConstants.CR_POOL_CLOSE);
  }
  e.owner=-1L;
  throw ex;
}
Program: 30964
Project: 30964
Buggy source:
@Override protected boolean releaseAll(long deadline){
  long threadId=Thread.currentThread().getId();
  boolean removed=false;
  final int reason=deadline == Long.MAX_VALUE ? FactoryConstants.CR_POOL_CLOSE : FactoryConstants.CR_IDLE;
  Iterator<Entry> iterator=entries.values().iterator();
  while (iterator.hasNext()) {
    Entry e=iterator.next();
    if ((deadline > e.lastReleaseTime && e.owner == -1)) {
      if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,threadId)) {
        closeWriter(threadId,e,FactoryEventListener.EV_EXPIRE,FactoryEventListener.EV_EXPIRE_EX,reason);
        iterator.remove();
        removed=true;
        Unsafe.getUnsafe().putOrderedLong(e,ENTRY_OWNER,-1L);
      }
    }
 else     if (e.ex != null) {
      LOG.info().$("String_Node_Str").$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}

Fixed version (ground truth):
@Override protected boolean releaseAll(long deadline){
  long thread=Thread.currentThread().getId();
  boolean removed=false;
  final int reason=deadline == Long.MAX_VALUE ? FactoryConstants.CR_POOL_CLOSE : FactoryConstants.CR_IDLE;
  Iterator<Entry> iterator=entries.values().iterator();
  while (iterator.hasNext()) {
    Entry e=iterator.next();
    if ((deadline > e.lastReleaseTime && e.owner == -1)) {
      if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,thread)) {
        closeWriter(thread,e,FactoryEventListener.EV_EXPIRE,FactoryEventListener.EV_EXPIRE_EX,reason);
        iterator.remove();
        removed=true;
        Unsafe.getUnsafe().putOrderedLong(e,ENTRY_OWNER,-1L);
      }
    }
 else     if (e.ex != null) {
      LOG.info().$("String_Node_Str").$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}
Program: 30965
Project: 30965
Buggy source:
@SuppressWarnings("String_Node_Str") private <T>void createWriter(long thread,String name,Entry e,JournalMetadata<T> metadata) throws JournalException {
  try {
    JournalMetadata<T> mo=getConfiguration().readMetadata(metadata.getName());
    if (mo != null && !mo.isCompatible(metadata,false)) {
      throw new JournalMetadataException(mo,metadata);
    }
    if (closed) {
      return;
    }
    JournalWriter<T> w=new JournalWriter<>(metadata,new File(getConfiguration().getJournalBase(),name));
    w.setCloseInterceptor(this);
    LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    e.writer=w;
    notifyListener(thread,name,FactoryEventListener.EV_CREATE);
  }
 catch (  JournalException ex) {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$("String_Node_Str").$(ex).$();
    e.ex=ex;
    notifyListener(thread,name,FactoryEventListener.EV_CREATE_EX);
    throw ex;
  }
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private <T>JournalWriter<T> createWriter(long thread,String name,Entry e,JournalMetadata<T> metadata) throws JournalException {
  try {
    JournalMetadata<T> mo=getConfiguration().readMetadata(metadata.getName());
    if (mo != null && !mo.isCompatible(metadata,false)) {
      throw new JournalMetadataException(mo,metadata);
    }
    if (closed) {
      throw FactoryClosedException.INSTANCE;
    }
    JournalWriter<T> w=new JournalWriter<>(metadata,new File(getConfiguration().getJournalBase(),name));
    w.setCloseInterceptor(this);
    LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    e.writer=w;
    notifyListener(thread,name,FactoryEventListener.EV_CREATE);
    return w;
  }
 catch (  JournalException ex) {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$("String_Node_Str").$(ex).$();
    e.ex=ex;
    notifyListener(thread,name,FactoryEventListener.EV_CREATE_EX);
    throw ex;
  }
}
Program: 30967
Project: 30967
Buggy source:
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  Entry e=entries.get(name);
  if (e != null) {
    long threadId=Thread.currentThread().getId();
    if (e.owner == threadId) {
      if (e.writer.isCommitOnClose()) {
        try {
          e.writer.commit();
        }
 catch (        JournalException ex) {
          throw new JournalRuntimeException(ex);
        }
      }
      LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
      e.lastReleaseTime=System.currentTimeMillis();
      if (closed || e.writer.isInError()) {
        LOG.info().$("String_Node_Str").$(name).$('\'').$();
        e.writer.setCloseInterceptor(null);
        e.writer=null;
        entries.remove(name);
        return true;
      }
      e.owner=-1L;
    }
 else {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    }
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
    journal.setCloseInterceptor(null);
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  Entry e=entries.get(name);
  if (e != null) {
    if (e.owner != -1) {
      if (e.writer.isCommitOnClose()) {
        try {
          e.writer.commit();
        }
 catch (        JournalException ex) {
          throw new JournalRuntimeException(ex);
        }
      }
      LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
      e.lastReleaseTime=System.currentTimeMillis();
      if (closed || e.writer.isInError()) {
        LOG.info().$("String_Node_Str").$(name).$('\'').$();
        e.writer.setCloseInterceptor(null);
        e.writer=null;
        entries.remove(name);
        return true;
      }
      e.owner=-1L;
    }
 else {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    }
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
    journal.setCloseInterceptor(null);
    return true;
  }
  return false;
}
Program: 30968
Project: 30968
Buggy source:
@Test public void testInvalidColumnName() throws Exception {
  File base=factoryContainer.getFactory().getConfiguration().getJournalBase();
  File dir=new File(base,"String_Node_Str");
  Assert.assertFalse(dir.exists());
  try {
    getWriterFactory().writer(new JournalStructure("String_Node_Str").$sym("String_Node_Str").index().$sym("String_Node_Str").index().$sym("String_Node_Str").index().$());
    Assert.fail();
  }
 catch (  JournalException ignore) {
  }
  Assert.assertTrue(dir.exists());
  Assert.assertTrue(Files.delete(dir));
}

Fixed version (ground truth):
@Test public void testInvalidColumnName() throws Exception {
  File base=factoryContainer.getFactory().getConfiguration().getJournalBase();
  File dir=new File(base,"String_Node_Str");
  Assert.assertFalse(dir.exists());
  try {
    getWriterFactory().writer(new JournalStructure("String_Node_Str").$sym("String_Node_Str").index().$sym("String_Node_Str").index().$sym("String_Node_Str").index().$());
    Assert.fail();
  }
 catch (  JournalException ignore) {
  }
  factoryContainer.getFactory().expire();
  Assert.assertTrue(dir.exists());
  Assert.assertTrue(Files.delete(dir));
}
Program: 30969
Project: 30969
Buggy source:
@After public void tearDown() throws Exception {
  origin.close();
  slave.close();
  master.close();
  masterReader.close();
  journalDeltaProducer.free();
  journalDeltaConsumer.free();
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  origin.close();
  slave.close();
  master.close();
  masterReader.close();
  journalDeltaProducer.free();
  journalDeltaConsumer.free();
  super.tearDown();
}
Program: 30970
Project: 30970
Buggy source:
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyWriterCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}
Program: 30971
Project: 30971
Buggy source:
@After public void tearDown() throws Exception {
  bw.close();
  aw.close();
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  bw.close();
  aw.close();
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyWriterCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}
Program: 30972
Project: 30972
Buggy source:
@After public void tearDown() throws Exception {
  aw.close();
  bw.close();
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  aw.close();
  bw.close();
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyWriterCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}
Program: 30973
Project: 30973
Buggy source:
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyWriterCount());
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
}
Program: 30974
Project: 30974
Buggy source:
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyWriterCount());
}
Program: 30975
Project: 30975
Buggy source:
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}

Fixed version (ground truth):
@After public void tearDown() throws Exception {
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyWriterCount());
  Assert.assertEquals(0,factoryContainer.getFactory().getBusyReaderCount());
}
Program: 30976
Project: 30976
Buggy source:
public static void main(String[] args) throws JournalException, IOException, JournalNetworkException, NumericException {
  final String pathToDatabase=args[0];
  final int instance=Numbers.parseInt(args[1]);
  final JournalConfiguration configuration=new JournalConfigurationBuilder(){
{
      $(Price.class).$ts();
    }
  }
.build(pathToDatabase);
  final WriterFactoryImpl writerFactory=new WriterFactoryImpl(configuration);
  final ReaderFactoryImpl readerFactory=new ReaderFactoryImpl(configuration);
  final JournalWriter<Price> writer=writerFactory.writer(new JournalKey<>(Price.class,null,PartitionBy.DEFAULT,1000000000));
  final WorkerController wc=new WorkerController(writer);
  final ClusterController cc=new ClusterController(new ServerConfig(){
{
      addNode(new ServerNode(1,"String_Node_Str"));
      addNode(new ServerNode(2,"String_Node_Str"));
    }
  }
,new ClientConfig(),writerFactory,readerFactory,instance,new ArrayList<JournalWriter>(){
{
      add(writer);
    }
  }
,wc);
  cc.start();
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      cc.halt();
    }
  }
);
}

Fixed version (ground truth):
public static void main(String[] args) throws JournalException, IOException, JournalNetworkException, NumericException {
  final String pathToDatabase=args[0];
  final int instance=Numbers.parseInt(args[1]);
  final JournalConfiguration configuration=new JournalConfigurationBuilder(){
{
      $(Price.class).$ts();
    }
  }
.build(pathToDatabase);
  final MegaFactory factory=new MegaFactory(configuration,1000,1);
  final JournalWriter<Price> writer=factory.writer(new JournalKey<>(Price.class,null,PartitionBy.DEFAULT,1000000000));
  final WorkerController wc=new WorkerController(writer);
  final ClusterController cc=new ClusterController(new ServerConfig(){
{
      addNode(new ServerNode(1,"String_Node_Str"));
      addNode(new ServerNode(2,"String_Node_Str"));
    }
  }
,new ClientConfig(),factory,instance,new ArrayList<JournalWriter>(){
{
      add(writer);
    }
  }
,wc);
  cc.start();
  Runtime.getRuntime().addShutdownHook(new Thread(){
    @Override public void run(){
      cc.halt();
    }
  }
);
}
Program: 30978
Project: 30978
Buggy source:
public void run(){
  System.out.println(new Date() + "String_Node_Str");
}

Fixed version (ground truth):
public void run(){
  System.out.println(new Date() + "String_Node_Str");
  server.halt();
  factory.close();
}
Program: 30979
Project: 30979
Buggy source:
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  if (journal instanceof R) {
    Entry e=entries.get(name);
    if (e == null) {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
      return true;
    }
    long thread=Thread.currentThread().getId();
    R r=(R)journal;
    if (Unsafe.arrayGet(r.entry.allocations,r.index) == thread) {
      if (closed == TRUE) {
        Unsafe.arrayPut(r.entry.readers,r.index,null);
        return true;
      }
      Unsafe.arrayPut(r.entry.releaseTimes,r.index,System.currentTimeMillis());
      Unsafe.arrayPutOrdered(r.entry.allocations,r.index,UNALLOCATED);
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
      return false;
    }
    LOG.error().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(r.entry.index).$(',').$(r.index).$();
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$();
  }
  return true;
}

Fixed version (ground truth):
@Override public boolean canClose(Journal journal){
  String name=journal.getName();
  if (journal instanceof R) {
    Entry e=entries.get(name);
    if (e == null) {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
      return true;
    }
    long thread=Thread.currentThread().getId();
    R r=(R)journal;
    if (Unsafe.arrayGet(r.entry.allocations,r.index) != UNALLOCATED) {
      if (closed == TRUE) {
        Unsafe.arrayPut(r.entry.readers,r.index,null);
        return true;
      }
      Unsafe.arrayPut(r.entry.releaseTimes,r.index,System.currentTimeMillis());
      Unsafe.arrayPutOrdered(r.entry.allocations,r.index,UNALLOCATED);
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
      return false;
    }
    LOG.error().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(r.entry.index).$(',').$(r.index).$();
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$();
  }
  return true;
}
Program: 30980
Project: 30980
Buggy source:
@Override public final <T>Journal<T> reader(Class<T> clazz,String name,int recordHint) throws JournalException {
  return reader(new JournalKey<>(clazz,name,PartitionBy.DEFAULT,recordHint));
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public <T>Journal<T> reader(JournalMetadata<T> metadata) throws JournalException {
  if (closed == TRUE) {
    LOG.info().$("String_Node_Str");
    throw FactoryClosedException.INSTANCE;
  }
  String name=metadata.getName();
  Entry e=entries.get(name);
  long thread=Thread.currentThread().getId();
  if (e == null) {
    LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
    e=new Entry(0);
    Entry other=entries.putIfAbsent(name,e);
    if (other != null) {
      e=other;
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
    }
 else {
      if (getConfiguration().exists(name) != JournalConfiguration.EXISTS) {
        LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
        throw JournalDoesNotExistException.INSTANCE;
      }
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$('\'').$();
    }
  }
  long lockOwner=e.lockOwner;
  if (lockOwner != UNLOCKED) {
    LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(lockOwner).$();
    throw JournalLockedException.INSTANCE;
  }
  do {
    for (int i=0; i < ENTRY_SIZE; i++) {
      if (Unsafe.cas(e.allocations,i,UNALLOCATED,thread)) {
        LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(e.index).$(',').$(i).$();
        R r=Unsafe.arrayGet(e.readers,i);
        if (r == null) {
          r=new R(e,i,metadata,new File(getConfiguration().getJournalBase(),metadata.getName()));
          if (closed == TRUE) {
            return r;
          }
          Unsafe.arrayPut(e.readers,i,r);
          r.setCloseInterceptor(this);
        }
 else {
          r.refresh();
        }
        if (closed == TRUE) {
          Unsafe.arrayPut(e.readers,i,null);
          r.setCloseInterceptor(null);
        }
        return r;
      }
    }
    LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(e.index + 1).$();
    if (Unsafe.getUnsafe().compareAndSwapInt(e,NEXT_STATUS,0,1)) {
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(e.index + 1).$();
      e.next=new Entry(e.index + 1);
    }
    e=e.next;
  }
 while (e != null && e.index < maxSegments);
  LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(this.maxSegments).$(')').$();
  throw FactoryFullException.INSTANCE;
}
Program: 30983
Project: 30983
Buggy source:
@Override public void run(){
  Rnd rnd=new Rnd();
  workerTimes.add(System.currentTimeMillis());
  for (int i=0; i < iterations; i++) {
    JournalMetadata<?> metadata=meta[rnd.nextPositiveInt() % readerCount];
    try (Journal<?> ignored=rf.reader(metadata)){
      if (metadata == meta[readerCount - 1] && barrier.getNumberWaiting() > 0) {
        barrier.await();
      }
      LockSupport.parkNanos(1L);
    }
 catch (    JournalLockedException ignored) {
    }
catch (    Exception e) {
      e.printStackTrace();
      errors.incrementAndGet();
    }
  }
  workerTimes.add(System.currentTimeMillis());
  halt.countDown();
}

Fixed version (ground truth):
@Override public void run(){
  Rnd rnd=new Rnd();
  workerTimes.add(System.currentTimeMillis());
  for (int i=0; i < iterations; i++) {
    JournalMetadata<?> metadata=meta[rnd.nextPositiveInt() % readerCount];
    try (Journal<?> ignored=rf.reader(metadata)){
      if (metadata == meta[readerCount - 1] && barrier.getNumberWaiting() > 0) {
        barrier.await();
      }
      LockSupport.parkNanos(10L);
    }
 catch (    JournalLockedException ignored) {
    }
catch (    Exception e) {
      e.printStackTrace();
      errors.incrementAndGet();
    }
  }
  workerTimes.add(System.currentTimeMillis());
  halt.countDown();
}
Program: 30984
Project: 30984
Buggy source:
@AfterClass public static void tearDown2() throws Exception {
  server.halt();
}

Fixed version (ground truth):
@AfterClass public static void tearDown2() throws Exception {
  server.halt();
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyReaderCount());
  Assert.assertEquals(0,FACTORY_CONTAINER.getFactory().getBusyWriterCount());
}
Program: 30986
Project: 30986
Buggy source:
@SuppressWarnings("String_Node_Str") public static void copyNonBlocking(ReadableByteChannel channel,ByteBuffer to,final int retryCount) throws DisconnectedChannelException, SlowReadableChannelException, EndOfChannelException {
  int r=to.remaining();
  int target=r;
  int retriesRemaining=retryCount;
  OUT:   while (target > 0) {
    int result;
    try {
      result=channel.read(to);
    }
 catch (    IOException e) {
      throw DisconnectedChannelException.INSTANCE;
    }
    if (result > 0) {
      target-=result;
      continue;
    }
switch (result) {
case Net.ERETRY:
      if (target < r) {
        break OUT;
      }
    if (--retriesRemaining < 0) {
      throw SlowReadableChannelException.INSTANCE;
    }
  break;
case Net.EPEERDISCONNECT:
throw EndOfChannelException.INSTANCE;
default :
throw DisconnectedChannelException.INSTANCE;
}
}
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") public static void copyNonBlocking(NetworkChannel channel,ByteBuffer to,final int retryCount) throws DisconnectedChannelException, SlowReadableChannelException, EndOfChannelException {
  int r=to.remaining();
  int target=r;
  int retriesRemaining=retryCount;
  OUT:   while (target > 0) {
    int result;
    try {
      result=channel.read(to);
    }
 catch (    IOException e) {
      throw DisconnectedChannelException.INSTANCE;
    }
    if (result > 0) {
      target-=result;
      continue;
    }
switch (result) {
case Net.ERETRY:
      if (target < r) {
        break OUT;
      }
    if (--retriesRemaining < 0) {
      throw SlowReadableChannelException.INSTANCE;
    }
  break;
case Net.EPEERDISCONNECT:
throw EndOfChannelException.INSTANCE;
default :
throw DisconnectedChannelException.INSTANCE;
}
}
}
Program: 30987
Project: 30987
Buggy source:
private void disconnect(C context,int disconnectReason){
  LOG.info().$("String_Node_Str").$(context.getFd()).$("String_Node_Str").$(DisconnectReason.nameOf(disconnectReason)).$();
  context.close();
  connectionCount--;
}

Fixed version (ground truth):
private void disconnect(C context,int disconnectReason){
  LOG.info().$("String_Node_Str").$ip(context.getIp()).$("String_Node_Str").$(DisconnectReason.nameOf(disconnectReason)).$(']').$();
  context.close();
  connectionCount--;
}
Program: 30988
Project: 30988
Buggy source:
@Override protected boolean runSerially(){
  boolean useful=false;
  final int n=epoll.poll();
  int watermark=pending.size();
  final long timestamp=clock.getTicks();
  int offset=0;
  if (n > 0) {
    for (int i=0; i < n; i++) {
      epoll.setOffset(offset);
      offset+=Epoll.SIZEOF_EVENT;
      long id=epoll.getData();
      if (id == 0) {
        accept(timestamp);
      }
 else {
        int row=pending.binarySearch(id);
        if (row < 0) {
          LOG.error().$("String_Node_Str").$(id).$();
          continue;
        }
        final C context=pending.get(row);
        long cursor=ioSequence.nextBully();
        Event<C> evt=ioQueue.get(cursor);
        evt.context=context;
        evt.channelStatus=(epoll.getEvent() & Epoll.EPOLLIN) > 0 ? ChannelStatus.READ : ChannelStatus.WRITE;
        ioSequence.done(cursor);
        LOG.debug().$("String_Node_Str").$(id).$("String_Node_Str").$(context.getFd()).$();
        pending.deleteRow(row);
        watermark--;
      }
    }
    if (watermark < pending.size()) {
      enqueuePending(watermark);
    }
    useful=true;
  }
  long deadline=timestamp - timeout;
  if (pending.size() > 0 && pending.get(0,M_TIMESTAMP) < deadline) {
    processIdleConnections(deadline);
    useful=true;
  }
  return processRegistrations(timestamp) || useful;
}

Fixed version (ground truth):
@Override protected boolean runSerially(){
  boolean useful=false;
  final int n=epoll.poll();
  int watermark=pending.size();
  final long timestamp=clock.getTicks();
  int offset=0;
  if (n > 0) {
    for (int i=0; i < n; i++) {
      epoll.setOffset(offset);
      offset+=Epoll.SIZEOF_EVENT;
      long id=epoll.getData();
      if (id == 0) {
        accept(timestamp);
      }
 else {
        int row=pending.binarySearch(id);
        if (row < 0) {
          LOG.error().$("String_Node_Str").$(id).$();
          continue;
        }
        final C context=pending.get(row);
        long cursor=ioSequence.nextBully();
        Event<C> evt=ioQueue.get(cursor);
        evt.context=context;
        evt.channelStatus=(epoll.getEvent() & Epoll.EPOLLIN) > 0 ? ChannelStatus.READ : ChannelStatus.WRITE;
        ioSequence.done(cursor);
        LOG.debug().$("String_Node_Str").$(id).$("String_Node_Str").$(context.getFd()).$("String_Node_Str").$(evt.channelStatus).$();
        pending.deleteRow(row);
        watermark--;
      }
    }
    if (watermark < pending.size()) {
      enqueuePending(watermark);
    }
    useful=true;
  }
  long deadline=timestamp - timeout;
  if (pending.size() > 0 && pending.get(0,M_TIMESTAMP) < deadline) {
    processIdleConnections(deadline);
    useful=true;
  }
  return processRegistrations(timestamp) || useful;
}
Program: 30989
Project: 30989
Buggy source:
private boolean processRegistrations(long timestamp){
  long cursor;
  boolean useful=false;
  int offset=0;
  while ((cursor=interestSubSequence.next()) > -1) {
    useful=true;
    Event<C> evt=interestQueue.get(cursor);
    C context=evt.context;
    int channelStatus=evt.channelStatus;
    interestSubSequence.done(cursor);
    int fd=(int)context.getFd();
    LOG.debug().$("String_Node_Str").$(fd).$("String_Node_Str").$(channelStatus).$();
    epoll.setOffset(offset);
    offset+=Epoll.SIZEOF_EVENT;
    final long id=fdid++;
switch (channelStatus) {
case ChannelStatus.READ:
      epoll.control(fd,id,Epoll.EPOLL_CTL_MOD,Epoll.EPOLLIN);
    break;
case ChannelStatus.WRITE:
  epoll.control(fd,id,Epoll.EPOLL_CTL_MOD,Epoll.EPOLLOUT);
break;
case ChannelStatus.DISCONNECTED:
disconnect(context,DisconnectReason.SILLY);
continue;
case ChannelStatus.EOF:
disconnect(context,DisconnectReason.PEER);
continue;
default :
break;
}
int r=pending.addRow();
pending.set(r,M_TIMESTAMP,timestamp);
pending.set(r,M_FD,fd);
pending.set(r,M_ID,id);
pending.set(r,context);
}
return useful;
}

Fixed version (ground truth):
private boolean processRegistrations(long timestamp){
  long cursor;
  boolean useful=false;
  int offset=0;
  while ((cursor=interestSubSequence.next()) > -1) {
    useful=true;
    Event<C> evt=interestQueue.get(cursor);
    C context=evt.context;
    int channelStatus=evt.channelStatus;
    interestSubSequence.done(cursor);
    int fd=(int)context.getFd();
    final long id=fdid++;
    LOG.debug().$("String_Node_Str").$(fd).$("String_Node_Str").$(channelStatus).$("String_Node_Str").$(id).$();
    epoll.setOffset(offset);
    offset+=Epoll.SIZEOF_EVENT;
switch (channelStatus) {
case ChannelStatus.READ:
      epoll.control(fd,id,Epoll.EPOLL_CTL_MOD,Epoll.EPOLLIN);
    break;
case ChannelStatus.WRITE:
  epoll.control(fd,id,Epoll.EPOLL_CTL_MOD,Epoll.EPOLLOUT);
break;
case ChannelStatus.DISCONNECTED:
disconnect(context,DisconnectReason.SILLY);
continue;
case ChannelStatus.EOF:
disconnect(context,DisconnectReason.PEER);
continue;
default :
break;
}
int r=pending.addRow();
pending.set(r,M_TIMESTAMP,timestamp);
pending.set(r,M_FD,fd);
pending.set(r,M_ID,id);
pending.set(r,context);
}
return useful;
}
Program: 30990
Project: 30990
Buggy source:
private void disconnect(C context,int disconnectReason){
  LOG.info().$("String_Node_Str").$(context.getFd()).$("String_Node_Str").$(DisconnectReason.nameOf(disconnectReason)).$();
  context.close();
  connectionCount--;
}

Fixed version (ground truth):
private void disconnect(C context,int disconnectReason){
  LOG.info().$("String_Node_Str").$ip(context.getIp()).$("String_Node_Str").$(DisconnectReason.nameOf(disconnectReason)).$(']').$();
  context.close();
  connectionCount--;
}
Program: 30991
Project: 30991
Buggy source:
@Override public int read(ByteBuffer dst) throws IOException {
  int read=Net.recv(fd,ByteBuffers.getAddress(dst) + dst.position(),dst.remaining());
  if (read > 0) {
    dst.position(dst.position() + read);
  }
  return read;
}

Fixed version (ground truth):
@Override public int read(ByteBuffer dst) throws IOException {
  int read=Net.recv(fd,ByteBuffers.getAddress(dst) + dst.position(),dst.remaining());
  if (read > 0) {
    dst.position(dst.position() + read);
    if (consecutiveBadReadCount > 0) {
      consecutiveBadReadCount=0;
    }
  }
 else {
    consecutiveBadReadCount++;
  }
  return read;
}
Program: 30992
Project: 30992
Buggy source:
public NetworkChannelImpl(long fd){
  this.fd=fd;
}

Fixed version (ground truth):
public NetworkChannelImpl(long fd){
  this.fd=fd;
  this.ip=Net.getPeerIP(fd);
}