nus-yam/ex-repair huggingface dataset:
Program: 30993
Project: 30993
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: 30994
Project: 30994
Buggy source:
@Override public void close(){
  if (open.compareAndSet(true,false)) {
    LOG.debug().$("String_Node_Str").$(channel.getFd()).$();
    Misc.free(map);
    Misc.free(channel);
    Misc.free(request);
    Misc.free(response);
    LOG.debug().$("String_Node_Str").$(channel.getFd()).$();
  }
}

Fixed version (ground truth):
@Override public void close(){
  if (open.compareAndSet(true,false)) {
    LOG.debug().$("String_Node_Str").$ip(channel.getIp()).$();
    Misc.free(map);
    Misc.free(channel);
    Misc.free(request);
    Misc.free(response);
    LOG.debug().$("String_Node_Str").$ip(channel.getIp()).$();
  }
}
Program: 30995
Project: 30995
Buggy source:
private static void logAccess(IOContext context){
  ACCESS.xinfo().$ip(Net.getPeerIP(context.channel.getFd())).$("String_Node_Str").$("String_Node_Str").$("String_Node_Str").$ts(System.currentTimeMillis()).$("String_Node_Str").$('"').$(context.request.getMethodLine()).$('"').$(' ').$(context.getResponseCode()).$(' ').$(context.channel.getTotalWrittenAndReset()).$();
}

Fixed version (ground truth):
private static void logAccess(IOContext context){
  ACCESS.xinfo().$ip(context.channel.getIp()).$("String_Node_Str").$("String_Node_Str").$("String_Node_Str").$ts(System.currentTimeMillis()).$("String_Node_Str").$('"').$(context.request.getMethodLine()).$('"').$(' ').$(context.getResponseCode()).$(' ').$(context.channel.getTotalWrittenAndReset()).$();
}
Program: 30996
Project: 30996
Buggy source:
public Request(NetworkChannel channel,ServerConfiguration configuration){
  this.channel=channel;
  this.hb=new RequestHeaderBuffer(configuration.getHttpBufReqHeader(),pool);
  this.in=ByteBuffer.allocateDirect(Numbers.ceilPow2(configuration.getHttpBufReqContent()));
  this.inAddr=ByteBuffers.getAddress(in);
  this.multipartParser=new MultipartParser(configuration.getHttpBufReqMultipart(),pool);
  this.soRcvSmall=configuration.getHttpSoRcvSmall();
  this.soRcvLarge=configuration.getHttpSoRcvLarge();
  this.soRetries=configuration.getHttpSoRetries();
}

Fixed version (ground truth):
public Request(NetworkChannel channel,ServerConfiguration configuration){
  this.channel=channel;
  this.hb=new RequestHeaderBuffer(configuration.getHttpBufReqHeader(),pool);
  this.in=ByteBuffer.allocateDirect(Numbers.ceilPow2(configuration.getHttpBufReqContent()));
  this.inAddr=ByteBuffers.getAddress(in);
  this.multipartParser=new MultipartParser(configuration.getHttpBufReqMultipart(),pool);
  this.soRcvSmall=configuration.getHttpSoRcvSmall();
  this.soRcvLarge=configuration.getHttpSoRcvLarge();
  this.soRetries=configuration.getHttpSoRetries();
  this.soConsecutiveBadReadLimit=configuration.getHttpSoConsecutiveBadReadLimit();
}
Program: 30997
Project: 30997
Buggy source:
private void drainChannel() throws IOException {
  in.clear();
  ByteBuffers.copyNonBlocking(channel,in,soRetries);
  in.flip();
}

Fixed version (ground truth):
private void drainChannel() throws IOException {
  try {
    in.clear();
    ByteBuffers.copyNonBlocking(channel,in,soRetries);
    in.flip();
  }
 catch (  SlowReadableChannelException e) {
    if (channel.getConsecutiveBadReadCount() > soConsecutiveBadReadLimit) {
      LOG.error().$("String_Node_Str").$();
      throw DisconnectedChannelException.INSTANCE;
    }
    throw e;
  }
}
Program: 30999
Project: 30999
Buggy source:
@Override public void handle(IOContext context) throws IOException {
  ExportHandlerContext ctx=localContext.get(context);
  if (ctx == null) {
    localContext.set(context,ctx=new ExportHandlerContext(context.channel.getFd(),context.getServerConfiguration().getDbCyclesBeforeCancel()));
  }
  ChunkedResponse r=context.chunkedResponse();
  if (ctx.parseUrl(r,context.request)) {
    ctx.compileQuery(r,factory,cacheMisses,cacheHits);
    resume(context);
  }
}

Fixed version (ground truth):
@Override public void handle(IOContext context) throws IOException {
  ExportHandlerContext ctx=localContext.get(context);
  if (ctx == null) {
    localContext.set(context,ctx=new ExportHandlerContext(context.getFd(),context.getServerConfiguration().getDbCyclesBeforeCancel()));
  }
  ChunkedResponse r=context.chunkedResponse();
  if (ctx.parseUrl(r,context.request)) {
    ctx.compileQuery(r,factory,cacheMisses,cacheHits);
    resume(context);
  }
}
Program: 31000
Project: 31000
Buggy source:
@Override public void handle(IOContext context) throws IOException {
  QueryHandlerContext ctx=localContext.get(context);
  if (ctx == null) {
    localContext.set(context,ctx=new QueryHandlerContext(context.channel.getFd(),context.getServerConfiguration().getDbCyclesBeforeCancel()));
  }
  ChunkedResponse r=context.chunkedResponse();
  if (ctx.parseUrl(r,context.request)) {
    ctx.compileQuery(r,factory,cacheMisses,cacheHits);
    resume(context);
  }
}

Fixed version (ground truth):
@Override public void handle(IOContext context) throws IOException {
  QueryHandlerContext ctx=localContext.get(context);
  if (ctx == null) {
    localContext.set(context,ctx=new QueryHandlerContext(context.getFd(),context.getServerConfiguration().getDbCyclesBeforeCancel()));
  }
  ChunkedResponse r=context.chunkedResponse();
  if (ctx.parseUrl(r,context.request)) {
    ctx.compileQuery(r,factory,cacheMisses,cacheHits);
    resume(context);
  }
}
Program: 31002
Project: 31002
Buggy source:
public void run(){
  System.out.println(new Date() + "String_Node_Str");
  server.halt();
  factory.close();
}

Fixed version (ground truth):
public void run(){
  System.out.println(new Date() + "String_Node_Str");
  server.halt();
  factoryEventLogger.close();
  factory.close();
}
Program: 31003
Project: 31003
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.arrayGetVolatile(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;
}

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.arrayGetVolatile(r.entry.allocations,r.index) != FactoryConstants.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,FactoryConstants.UNALLOCATED);
      LOG.info().$("String_Node_Str").$(thread).$("String_Node_Str").$(name).$("String_Node_Str").$(r.entry.index).$(',').$(r.index).$(')').$();
      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: 31004
Project: 31004
Buggy source:
public Entry(int index){
  this.index=index;
  Arrays.fill(allocations,UNALLOCATED);
  Arrays.fill(releaseTimes,System.currentTimeMillis());
}

Fixed version (ground truth):
public Entry(int index){
  this.index=index;
  Arrays.fill(allocations,FactoryConstants.UNALLOCATED);
  Arrays.fill(releaseTimes,System.currentTimeMillis());
}
Program: 31005
Project: 31005
Buggy source:
public void unlock(String name){
  Entry e=entries.get(name);
  if (e == null) {
    return;
  }
  long thread=Thread.currentThread().getId();
  if (e.lockOwner == thread) {
    entries.remove(name);
  }
}

Fixed version (ground truth):
public void unlock(String name){
  Entry e=entries.get(name);
  if (e == null) {
    LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
    return;
  }
  long thread=Thread.currentThread().getId();
  if (e.lockOwner == thread) {
    entries.remove(name);
  }
  LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
}
Program: 31006
Project: 31006
Buggy source:
public int getBusyCount(){
  int count=0;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (Unsafe.arrayGetVolatile(e.allocations,i) != UNALLOCATED && Unsafe.arrayGet(e.readers,i) != null) {
          count++;
        }
      }
      e=e.next;
    }
 while (e != null);
  }
  return count;
}

Fixed version (ground truth):
public int getBusyCount(){
  int count=0;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (Unsafe.arrayGetVolatile(e.allocations,i) != FactoryConstants.UNALLOCATED && Unsafe.arrayGet(e.readers,i) != null) {
          count++;
        }
      }
      e=e.next;
    }
 while (e != null);
  }
  return count;
}
Program: 31008
Project: 31008
Buggy source:
@Override protected boolean releaseAll(long deadline){
  long thread=Thread.currentThread().getId();
  boolean removed=false;
  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.arrayGetVolatile(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)) {
              removed=true;
              r.setCloseInterceptor(null);
              try {
                r.close();
                LOG.info().$("String_Node_Str").$(r.getName()).$("String_Node_Str").$();
              }
 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);
  }
  return removed;
}

Fixed version (ground truth):
@Override protected boolean releaseAll(long deadline){
  long thread=Thread.currentThread().getId();
  boolean removed=false;
  int closeReason=deadline < Long.MAX_VALUE ? FactoryConstants.CR_IDLE : FactoryConstants.CR_POOL_CLOSE;
  for (  Map.Entry<String,Entry> me : entries.entrySet()) {
    Entry e=me.getValue();
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (deadline > Unsafe.arrayGetVolatile(e.releaseTimes,i) && Unsafe.arrayGet(e.readers,i) != null) {
          if (Unsafe.cas(e.allocations,i,FactoryConstants.UNALLOCATED,thread)) {
            if (deadline > Unsafe.arrayGet(e.releaseTimes,i)) {
              removed=true;
              closeReader(e,i,closeReason);
            }
            Unsafe.arrayPutOrdered(e.allocations,i,FactoryConstants.UNALLOCATED);
          }
        }
      }
      e=e.next;
    }
 while (e != null);
  }
  return removed;
}
Program: 31009
Project: 31009
Buggy source:
public void lock(String name) throws JournalException {
  Entry e=entries.get(name);
  if (e == null) {
    return;
  }
  long thread=Thread.currentThread().getId();
  if (Unsafe.getUnsafe().compareAndSwapLong(e,LOCK_OWNER,UNLOCKED,thread) || Unsafe.getUnsafe().compareAndSwapLong(e,LOCK_OWNER,thread,thread)) {
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (Unsafe.cas(e.allocations,i,UNALLOCATED,thread)) {
          R r=Unsafe.arrayGet(e.readers,i);
          if (r != null) {
            r.setCloseInterceptor(null);
            r.close();
            Unsafe.arrayPut(e.readers,i,null);
          }
        }
 else         if (Unsafe.arrayGet(e.readers,i) != null) {
          throw RetryLockException.INSTANCE;
        }
      }
      e=e.next;
    }
 while (e != null);
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.lockOwner).$();
    throw JournalLockedException.INSTANCE;
  }
}

Fixed version (ground truth):
public void lock(String name) throws JournalException {
  Entry e=entries.get(name);
  if (e == null) {
    LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
    return;
  }
  long thread=Thread.currentThread().getId();
  if (Unsafe.getUnsafe().compareAndSwapLong(e,LOCK_OWNER,UNLOCKED,thread) || Unsafe.getUnsafe().compareAndSwapLong(e,LOCK_OWNER,thread,thread)) {
    do {
      for (int i=0; i < ENTRY_SIZE; i++) {
        if (Unsafe.cas(e.allocations,i,FactoryConstants.UNALLOCATED,thread)) {
          closeReader(e,i,FactoryConstants.CR_NAME_LOCK);
        }
 else         if (Unsafe.arrayGet(e.allocations,i) != thread || Unsafe.arrayGet(e.readers,i) != null) {
          LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$(e.lockOwner).$();
          throw RetryLockException.INSTANCE;
        }
      }
      e=e.next;
    }
 while (e != null);
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.lockOwner).$();
    throw JournalLockedException.INSTANCE;
  }
  LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
}
Program: 31010
Project: 31010
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,name,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX);
      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,name,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX);
  }
  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,name,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,name,e,FactoryEventListener.EV_CLOSE,FactoryEventListener.EV_CLOSE_EX,FactoryConstants.CR_POOL_CLOSE);
  }
  e.owner=-1L;
  throw ex;
}
Program: 31011
Project: 31011
Buggy source:
private void notifyListener(long thread,String name,int event){
  if (eventListener != null) {
    eventListener.onEvent(FactoryEventListener.SRC_WRITER,thread,name,event);
  }
}

Fixed version (ground truth):
private void notifyListener(long thread,String name,short event){
  if (eventListener != null) {
    eventListener.onEvent(FactoryEventListener.SRC_WRITER,thread,name,event);
  }
}
Program: 31012
Project: 31012
Buggy source:
@Override protected boolean releaseAll(long deadline){
  long threadId=Thread.currentThread().getId();
  boolean removed=false;
  notifyListener(threadId,null,FactoryEventListener.EV_RELEASE_ALL);
  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)) {
        closeWriter(threadId,me.getKey(),e,FactoryEventListener.EV_EXPIRE,FactoryEventListener.EV_EXPIRE_EX);
        iterator.remove();
        removed=true;
        Unsafe.getUnsafe().putOrderedLong(e,ENTRY_OWNER,-1L);
      }
    }
 else     if (e.ex != null) {
      LOG.info().$("String_Node_Str").$(me.getKey()).$('\'').$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}

Fixed version (ground truth):
@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<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)) {
        closeWriter(threadId,me.getKey(),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").$(me.getKey()).$('\'').$();
      iterator.remove();
      removed=true;
    }
  }
  return removed;
}
Program: 31013
Project: 31013
Buggy source:
private void closeWriter(long thread,String name,Entry e,int ev,int evex){
  LOG.info().$("String_Node_Str").$(name).$('\'').$();
  JournalWriter w=e.writer;
  if (w != null) {
    w.setCloseInterceptor(null);
    try {
      w.close();
      e.writer=null;
      notifyListener(thread,name,ev);
    }
 catch (    Throwable e1) {
      notifyListener(thread,name,evex);
      LOG.error().$("String_Node_Str").$(w.getName()).$("String_Node_Str").$(e1.getMessage()).$();
    }
  }
}

Fixed version (ground truth):
private void closeWriter(long thread,String name,Entry e,short ev,short evex,int reason){
  JournalWriter w=e.writer;
  if (w != null) {
    w.setCloseInterceptor(null);
    try {
      w.close();
      e.writer=null;
      LOG.info().$("String_Node_Str").$(name).$('\'').$(FactoryConstants.closeReasonText(reason)).$();
      notifyListener(thread,name,ev);
    }
 catch (    Throwable e1) {
      notifyListener(thread,name,evex);
      LOG.error().$("String_Node_Str").$(w.getName()).$("String_Node_Str").$(e1.getMessage()).$();
    }
  }
}
Program: 31014
Project: 31014
Buggy source:
public void lock(String name) throws JournalException {
  if (closed) {
    LOG.info().$("String_Node_Str").$();
    throw FactoryClosedException.INSTANCE;
  }
  long thread=Thread.currentThread().getId();
  Entry e=entries.get(name);
  if (e == null) {
    e=new Entry();
    if (entries.putIfAbsent(name,e) == null) {
      notifyListener(thread,name,FactoryEventListener.EV_LOCK_SUCCESS);
      e.locked=true;
      return;
    }
 else {
      e=entries.get(name);
    }
  }
  if (e != null) {
    if ((Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,thread) || Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,thread,thread))) {
      LOG.info().$("String_Node_Str").$(e.owner).$("String_Node_Str").$(name).$();
      closeWriter(thread,name,e,FactoryEventListener.EV_LOCK_CLOSE,FactoryEventListener.EV_LOCK_CLOSE_EX);
      e.locked=true;
      notifyListener(thread,name,FactoryEventListener.EV_LOCK_SUCCESS);
      return;
    }
 else {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    }
  }
  notifyListener(thread,name,FactoryEventListener.EV_LOCK_BUSY);
  throw WriterBusyException.INSTANCE;
}

Fixed version (ground truth):
public void lock(String name) throws JournalException {
  if (closed) {
    LOG.info().$("String_Node_Str").$();
    throw FactoryClosedException.INSTANCE;
  }
  long thread=Thread.currentThread().getId();
  Entry e=entries.get(name);
  if (e == null) {
    e=new Entry();
    if (entries.putIfAbsent(name,e) == null) {
      notifyListener(thread,name,FactoryEventListener.EV_LOCK_SUCCESS);
      e.locked=true;
      return;
    }
 else {
      e=entries.get(name);
    }
  }
  if (e != null) {
    if ((Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,thread) || Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,thread,thread))) {
      LOG.info().$("String_Node_Str").$(e.owner).$("String_Node_Str").$(name).$();
      closeWriter(thread,name,e,FactoryEventListener.EV_LOCK_CLOSE,FactoryEventListener.EV_LOCK_CLOSE_EX,FactoryConstants.CR_NAME_LOCK);
      e.locked=true;
      notifyListener(thread,name,FactoryEventListener.EV_LOCK_SUCCESS);
      return;
    }
 else {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    }
  }
  notifyListener(thread,name,FactoryEventListener.EV_LOCK_BUSY);
  throw WriterBusyException.INSTANCE;
}
Program: 31015
Project: 31015
Buggy source:
public static long parseTime24(CharSequence seq,int lo,int lim) throws NumericException {
  int p=lo;
  if (p + 2 > lim) {
    throw NumericException.INSTANCE;
  }
  int hour=Numbers.parseInt(seq,p,p+=2);
  int sec=0;
  int min=0;
  int mil=0;
  checkRange(hour,0,23);
  if (p < lim && seq.charAt(p) == ':') {
    checkChar(seq,p++,lim,':');
    if (p + 2 > lim) {
      throw NumericException.INSTANCE;
    }
    min=Numbers.parseInt(seq,p,p+=2);
    checkRange(min,0,59);
    if (p < lim && seq.charAt(p) == ':') {
      checkChar(seq,p++,lim,':');
      if (p + 2 > lim) {
        throw NumericException.INSTANCE;
      }
      sec=Numbers.parseInt(seq,p,p+=2);
      checkRange(sec,0,59);
      if (p < lim && seq.charAt(p) == '.') {
        if (p + 4 > lim) {
          throw NumericException.INSTANCE;
        }
        mil=Numbers.parseInt(seq,++p,p+=3);
        checkRange(mil,0,999);
      }
    }
  }
  if (p < lim) {
    checkChar(seq,p,lim,'Z');
  }
  return hour * HOUR_MILLIS + min * MINUTE_MILLIS + sec * SECOND_MILLIS + mil;
}

Fixed version (ground truth):
public static long parseTime24(CharSequence seq) throws NumericException {
  int lim=seq.length();
  int p=0;
  if (p + 2 > lim) {
    throw NumericException.INSTANCE;
  }
  int hour=Numbers.parseInt(seq,p,p+=2);
  int sec=0;
  int min=0;
  int mil=0;
  checkRange(hour,0,23);
  if (p < lim && seq.charAt(p) == ':') {
    checkChar(seq,p++,lim,':');
    if (p + 2 > lim) {
      throw NumericException.INSTANCE;
    }
    min=Numbers.parseInt(seq,p,p+=2);
    checkRange(min,0,59);
    if (p < lim && seq.charAt(p) == ':') {
      checkChar(seq,p++,lim,':');
      if (p + 2 > lim) {
        throw NumericException.INSTANCE;
      }
      sec=Numbers.parseInt(seq,p,p+=2);
      checkRange(sec,0,59);
      if (p < lim && seq.charAt(p) == '.') {
        if (p + 4 > lim) {
          throw NumericException.INSTANCE;
        }
        mil=Numbers.parseInt(seq,++p,p+=3);
        checkRange(mil,0,999);
      }
    }
  }
  if (p < lim) {
    checkChar(seq,p,lim,'Z');
  }
  return hour * HOUR_MILLIS + min * MINUTE_MILLIS + sec * SECOND_MILLIS + mil;
}
Program: 31016
Project: 31016
Buggy source:
private static long parseDateTimeFmt3(CharSequence seq,int lo,int lim) throws NumericException {
  int p=lo;
  int day=int0(seq,p,p+=2,lim);
  checkChar(seq,p++,lim,'/');
  int month=int0(seq,p,p+=2,lim);
  checkRange(month,1,12);
  checkChar(seq,p++,lim,'/');
  int year=int0(seq,p,p + 4,lim);
  boolean l=isLeapYear(year);
  checkRange(day,1,getDaysPerMonth(month,l));
  return yearMillis(year,l) + monthOfYearMillis(month,l) + (day - 1) * DAY_MILLIS;
}

Fixed version (ground truth):
public static long parseDateTimeFmt3(CharSequence seq) throws NumericException {
  int lim=seq.length();
  int p=0;
  int day=int0(seq,p,p+=2,lim);
  checkChar(seq,p++,lim,'/');
  int month=int0(seq,p,p+=2,lim);
  checkRange(month,1,12);
  checkChar(seq,p++,lim,'/');
  int year=int0(seq,p,p + 4,lim);
  boolean l=isLeapYear(year);
  checkRange(day,1,getDaysPerMonth(month,l));
  return yearMillis(year,l) + monthOfYearMillis(month,l) + (day - 1) * DAY_MILLIS;
}
Program: 31017
Project: 31017
Buggy source:
public SSOCredentialProvider(String serviceName){
  if (Os.type != Os.WINDOWS) {
    throw new RuntimeException("String_Node_Str");
  }
  this.serviceName=serviceName;
}

Fixed version (ground truth):
public SSOCredentialProvider(String serviceName){
  this.serviceName=serviceName;
}
Program: 31018
Project: 31018
Buggy source:
@Override public byte[] createToken() throws Exception {
  return Os.generateKerberosToken(serviceName);
}

Fixed version (ground truth):
@Override public byte[] createToken() throws Exception {
  if (Os.type != Os.WINDOWS) {
    throw new RuntimeException("String_Node_Str");
  }
  return Os.generateKerberosToken(serviceName);
}
Program: 31019
Project: 31019
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 (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,threadId,-1L)) {
      if (closed) {
        if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,threadId)) {
          LOG.info().$("String_Node_Str").$(name).$('\'').$();
          e.writer=null;
          return true;
        }
      }
      LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
      e.lastReleaseTime=System.currentTimeMillis();
    }
 else {
      LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$(e.owner).$();
    }
  }
 else {
    LOG.error().$("String_Node_Str").$(name).$("String_Node_Str").$();
    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) {
    long threadId=Thread.currentThread().getId();
    if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,threadId,-1L)) {
      if (closed) {
        if (Unsafe.getUnsafe().compareAndSwapLong(e,ENTRY_OWNER,-1L,threadId)) {
          LOG.info().$("String_Node_Str").$(name).$('\'').$();
          e.writer.setCloseInterceptor(null);
          e.writer=null;
          return true;
        }
      }
      LOG.info().$("String_Node_Str").$(name).$("String_Node_Str").$();
      e.lastReleaseTime=System.currentTimeMillis();
    }
 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: 31020
Project: 31020
Buggy source:
private boolean releaseAll(long deadline){
  long threadId=Thread.currentThread().getId();
  boolean removed=false;
  LOG.info().$("String_Node_Str").$();
  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()).$('\'').$();
        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;
}
Program: 31022
Project: 31022
Buggy source:
@Test public void testOneThreadGetRelease() throws Exception {
  JournalStructure s=new JournalStructure("String_Node_Str").$date("String_Node_Str").$();
  CachingWriterFactory wf=theFactory.getCachingWriterFactory();
  JournalWriter x;
  JournalWriter y;
  x=wf.writer(s);
  try {
    Assert.assertEquals(0,wf.countFreeWriters());
    Assert.assertNotNull(x);
    Assert.assertTrue(x.isOpen());
    Assert.assertTrue(x == wf.writer(s));
  }
  finally {
    x.close();
  }
  Assert.assertEquals(1,wf.countFreeWriters());
  y=wf.writer(s);
  try {
    Assert.assertNotNull(y);
    Assert.assertTrue(y.isOpen());
    Assert.assertTrue(y == x);
  }
  finally {
    y.close();
  }
  Assert.assertEquals(1,wf.countFreeWriters());
}

Fixed version (ground truth):
@Test public void testOneThreadGetRelease() throws Exception {
  final JournalMetadata<?> m=theFactory.getConfiguration().buildWithRootLocation(new JournalStructure("String_Node_Str").$date("String_Node_Str").$());
  CachingWriterFactory wf=theFactory.getCachingWriterFactory();
  JournalWriter x;
  JournalWriter y;
  x=wf.writer(m);
  try {
    Assert.assertEquals(0,wf.countFreeWriters());
    Assert.assertNotNull(x);
    Assert.assertTrue(x.isOpen());
    Assert.assertTrue(x == wf.writer(m));
  }
  finally {
    x.close();
  }
  Assert.assertEquals(1,wf.countFreeWriters());
  y=wf.writer(m);
  try {
    Assert.assertNotNull(y);
    Assert.assertTrue(y.isOpen());
    Assert.assertTrue(y == x);
  }
  finally {
    y.close();
  }
  Assert.assertEquals(1,wf.countFreeWriters());
}
Program: 31023
Project: 31023
Buggy source:
@Test public void testTwoThreadsRaceToAllocate() throws Exception {
  final JournalStructure s=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();
  for (int i=0; i < n; i++) {
    new Thread(){
      @Override public void run(){
        try {
          barrier.await();
          try (JournalWriter w=wf.writer(s)){
            if (w != null) {
              writerCount.incrementAndGet();
            }
          }
         }
 catch (        Exception e) {
          e.printStackTrace();
          errors.incrementAndGet();
        }
 finally {
          halt.countDown();
        }
      }
    }
.start();
  }
  halt.await();
  Assert.assertEquals(0,errors.get());
  Assert.assertEquals(1,wf.countFreeWriters());
}

Fixed version (ground truth):
@Test public void testTwoThreadsRaceToAllocate() 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();
  for (int i=0; i < n; i++) {
    new Thread(){
      @Override public void run(){
        try {
          barrier.await();
          try (JournalWriter w=wf.writer(m)){
            if (w != null) {
              writerCount.incrementAndGet();
            }
          }
         }
 catch (        Exception e) {
          e.printStackTrace();
          errors.incrementAndGet();
        }
 finally {
          halt.countDown();
        }
      }
    }
.start();
  }
  halt.await();
  Assert.assertEquals(0,errors.get());
  Assert.assertEquals(1,wf.countFreeWriters());
}
Program: 31024
Project: 31024
Buggy source:
@Test @Ignore public void testAllocateAndClear() throws Exception {
  final JournalStructure s=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(s)){
            if (w != null) {
              writerCount.incrementAndGet();
            }
          }
           if (i == 3) {
            barrier.await();
          }
          LockSupport.parkNanos(100L);
        }
      }
 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.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());
  Assert.assertEquals(1,wf.countFreeWriters());
}
Program: 31025
Project: 31025
Buggy source:
@Override public void run(){
  try {
    barrier.await();
    try (JournalWriter w=wf.writer(s)){
      if (w != null) {
        writerCount.incrementAndGet();
      }
    }
   }
 catch (  Exception e) {
    e.printStackTrace();
    errors.incrementAndGet();
  }
 finally {
    halt.countDown();
  }
}

Fixed version (ground truth):
@Override public void run(){
  try {
    barrier.await();
    try (JournalWriter w=wf.writer(m)){
      if (w != null) {
        writerCount.incrementAndGet();
      }
    }
   }
 catch (  Exception e) {
    e.printStackTrace();
    errors.incrementAndGet();
  }
 finally {
    halt.countDown();
  }
}
Program: 31026
Project: 31026
Buggy source:
public long getTxn(){
  return txLog.getCurrentTxn();
}

Fixed version (ground truth):
public long getTxn(){
  if (isOpen()) {
    return txLog.getCurrentTxn();
  }
  throw new IllegalStateException("String_Node_Str");
}
Program: 31028
Project: 31028
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public void goPassive(ServerNode activeNode){
  if (activeNode.getId() != lastActive) {
    lastActive=activeNode.getId();
    haltClient();
    clientConfig.clearNodes();
    clientConfig.addNode(activeNode);
    client=new JournalClient(clientConfig,factory);
    LOG.info().$(thisNode.toString()).$("String_Node_Str").$();
    for (int i=0, sz=writers.size(); i < sz; i++) {
      JournalWriter w=writers.get(i);
      client.subscribe(w.getKey(),w,null);
    }
    try {
      client.start();
      client.setDisconnectCallback(new JournalClient.DisconnectCallback(){
        @Override public void onDisconnect(        int disconnectReason){
switch (disconnectReason) {
case JournalClient.DISCONNECT_INCOMPATIBLE_JOURNAL:
case JournalClient.DISCONNECT_CLIENT_HALT:
            halt();
          break;
default :
        if (running.get()) {
          server.joinCluster(statusListener);
        }
      break;
  }
}
}
);
if (listener != null) {
listener.goPassive(activeNode);
}
}
 catch (JournalNetworkException e) {
LOG.error().$("String_Node_Str").$(e).$();
haltClient();
server.joinCluster(statusListener);
}
}
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public void goPassive(ServerNode activeNode){
  if (activeNode.getId() != lastActive) {
    lastActive=activeNode.getId();
    haltClient();
    clientConfig.clearNodes();
    clientConfig.addNode(activeNode);
    client=new JournalClient(clientConfig,factory,null,clientCallback);
    LOG.info().$(thisNode.toString()).$("String_Node_Str").$();
    for (int i=0, sz=writers.size(); i < sz; i++) {
      JournalWriter w=writers.get(i);
      client.subscribe(w.getKey(),w,null);
    }
    client.start();
    if (listener != null) {
      listener.goPassive(activeNode);
    }
  }
}
Program: 31029
Project: 31029
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public Journal reader(JournalMetadata metadata) throws JournalException {
  return new Journal(metadata,metadata.getKey());
}

Fixed version (ground truth):
@Override public <T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  return new Journal<>(metadata,key);
}
Program: 31030
Project: 31030
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public Journal reader(JournalMetadata metadata) throws JournalException {
  JournalKey key=metadata.getKey();
  String name=key.path();
  Journal result=readers.get(name);
  if (result == null) {
    if (getConfiguration().exists(name) != JournalConfiguration.EXISTS) {
      LOG.error().$("String_Node_Str").$(name).$();
      throw JournalDoesNotExistException.INSTANCE;
    }
    result=new Journal<>(metadata,key);
    result.setCloseListener(this);
    readers.put(name,result);
    journalList.add(result);
  }
  return result;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public <T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  String name=key.path();
  Journal result=readers.get(name);
  if (result == null) {
    if (getConfiguration().exists(name) != JournalConfiguration.EXISTS) {
      LOG.error().$("String_Node_Str").$(name).$();
      throw JournalDoesNotExistException.INSTANCE;
    }
    result=new Journal<>(metadata,key);
    result.setCloseListener(this);
    readers.put(name,result);
    journalList.add(result);
  }
  return result;
}
Program: 31031
Project: 31031
Buggy source:
Journal reader(JournalMetadata metadata) throws JournalException ;

Fixed version (ground truth):
<T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException ;
Program: 31032
Project: 31032
Buggy source:
@SuppressWarnings("String_Node_Str") @Override public Journal reader(JournalMetadata metadata) throws JournalException {
  Journal reader=new Journal(metadata,metadata.getKey());
  journals.add(reader);
  reader.setCloseListener(this);
  return reader;
}

Fixed version (ground truth):
@Override public <T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  Journal<T> reader=new Journal<>(metadata,key);
  journals.add(reader);
  reader.setCloseListener(this);
  return reader;
}
Program: 31033
Project: 31033
Buggy source:
@Override public JournalBulkReader bulkReader(String location) throws JournalException {
  return bulkReader(new JournalKey<>(location));
}

Fixed version (ground truth):
@Override public <T>JournalBulkReader<T> bulkReader(JournalKey<T> key) throws JournalException {
  return new JournalBulkReader<>(getOrCreateMetadata(key),key);
}
Program: 31034
Project: 31034
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public <T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  String name=key.path();
  Journal result=readers.get(name);
  if (result == null) {
    if (getConfiguration().exists(name) != JournalConfiguration.EXISTS) {
      LOG.error().$("String_Node_Str").$(name).$();
      throw JournalDoesNotExistException.INSTANCE;
    }
    result=new Journal<>(metadata,key);
    result.setCloseListener(this);
    readers.put(name,result);
    journalList.add(result);
  }
  return result;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public <T>Journal<T> reader(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  String name=key.path();
  Journal result=readers.get(name);
  if (result == null) {
    if (getConfiguration().exists(name) != JournalConfiguration.EXISTS) {
      LOG.error().$("String_Node_Str").$(name).$();
      throw JournalDoesNotExistException.INSTANCE;
    }
    result=super.reader(metadata,key);
    result.setCloseListener(this);
    readers.put(name,result);
    journalList.add(result);
  }
  return result;
}
Program: 31035
Project: 31035
Buggy source:
@Override @SuppressWarnings("String_Node_Str") public <T>JournalBulkReader<T> bulkReader(JournalKey<T> key) throws JournalException {
  String name=key.path();
  checkBlocked(name);
  JournalBulkReader<T> result=bulkReaders.get(name);
  if (result == null) {
    result=new JournalBulkReader<>(getOrCreateMetadata(key),key);
    result.setCloseListener(this);
    bulkReaders.put(name,result);
    journalList.add(result);
  }
  return result;
}

Fixed version (ground truth):
@Override @SuppressWarnings("String_Node_Str") public <T>JournalBulkReader<T> bulkReader(JournalKey<T> key) throws JournalException {
  String name=key.path();
  checkBlocked(name);
  JournalBulkReader<T> result=bulkReaders.get(name);
  if (result == null) {
    result=super.bulkReader(key);
    result.setCloseListener(this);
    bulkReaders.put(name,result);
    journalList.add(result);
  }
  return result;
}
Program: 31036
Project: 31036
Buggy source:
@Override public <T>JournalWriter<T> writer(MetadataBuilder<T> b) throws JournalException {
  JournalMetadata<T> metadata=getConfiguration().buildWithRootLocation(b);
  return new JournalWriter<>(metadata,metadata.getKey());
}

Fixed version (ground truth):
@Override public <T>JournalWriter<T> writer(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  return new JournalWriter<>(metadata,key);
}
Program: 31037
Project: 31037
Buggy source:
<T>JournalWriter<T> writer(MetadataBuilder<T> metadata) throws JournalException ;

Fixed version (ground truth):
<T>JournalWriter<T> writer(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException ;
Program: 31038
Project: 31038
Buggy source:
public <T>JournalWriter<T> writer(MetadataBuilder<T> b) throws JournalException {
  JournalWriter<T> writer=super.writer(b);
  journals.add(writer);
  writer.setCloseListener(this);
  return writer;
}

Fixed version (ground truth):
@Override public <T>JournalWriter<T> writer(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  JournalWriter<T> writer=super.writer(metadata,key);
  journals.add(writer);
  writer.setCloseListener(this);
  return writer;
}
Program: 31039
Project: 31039
Buggy source:
@Override public <T>JournalWriter<T> bulkWriter(JournalMetadata<T> metadata) throws JournalException {
  JournalWriter<T> writer=super.bulkWriter(metadata);
  journals.add(writer);
  writer.setCloseListener(this);
  return writer;
}

Fixed version (ground truth):
@Override public <T>JournalBulkWriter<T> bulkWriter(JournalMetadata<T> metadata,JournalKey<T> key) throws JournalException {
  JournalBulkWriter<T> writer=super.bulkWriter(metadata,key);
  journals.add(writer);
  writer.setCloseListener(this);
  return writer;
}
Program: 31040
Project: 31040
Buggy source:
public void closeJournal(CharSequence name){
  Journal j=readers.get(name);
  if (j != null) {
    j.setCloseListener(null);
    j.close();
    readers.remove(name);
  }
  j=bulkReaders.get(name);
  if (j != null) {
    j.setCloseListener(null);
    j.close();
    bulkReaders.remove(name);
  }
  metadata.remove(name);
}

Fixed version (ground truth):
public void closeJournal(CharSequence name){
  Journal j=readers.get(name);
  if (j != null) {
    j.setCloseListener(null);
    j.close();
    readers.remove(name);
  }
  j=bulkReaders.get(name);
  if (j != null) {
    j.setCloseListener(null);
    j.close();
    bulkReaders.remove(name);
  }
}
Program: 31041
Project: 31041
Buggy source:
@Override public void close(){
  if (pool != null) {
    if (!inPool) {
      inPool=true;
      pool.release(this);
    }
  }
 else {
    if (closed.compareAndSet(false,true)) {
      for (int i=0, sz=journalList.size(); i < sz; i++) {
        Journal journal=journalList.getQuick(i);
        journal.setCloseListener(null);
        if (journal.isOpen()) {
          journal.close();
        }
      }
      readers.clear();
      bulkReaders.clear();
    }
  }
}

Fixed version (ground truth):
@Override public void close(){
  if (pool != null) {
    if (!inPool) {
      inPool=true;
      pool.release(this);
    }
  }
 else {
    if (closed.compareAndSet(false,true)) {
      reset();
    }
  }
}
Program: 31042
Project: 31042
Buggy source:
public JournalCachingFactory(JournalConfiguration configuration,JournalFactoryPool pool){
  super(configuration);
  this.pool=pool;
}

Fixed version (ground truth):
JournalCachingFactory(JournalConfiguration configuration,JournalFactoryPool pool){
  super(configuration);
  this.pool=pool;
}
Program: 31043
Project: 31043
Buggy source:
void release(final JournalCachingFactory factory){
  if (running.get() && openCount.get() < capacity) {
    factory.expireOpenFiles();
    pool.push(factory);
    return;
  }
  openCount.decrementAndGet();
  factory.clearPool();
  factory.close();
}

Fixed version (ground truth):
void release(final JournalCachingFactory factory){
  if (running.get() && openCount.get() <= capacity) {
    factory.expireOpenFiles();
    pool.push(factory);
    return;
  }
  openCount.decrementAndGet();
  factory.clearPool();
  factory.close();
}