nus-yam/ex-repair huggingface dataset:
Program: 52260
Project: 52260
Buggy source:
private void setReadLocation(long value){
  buffer.writeOrderedLong(readLocationOffset,value);
}

Fixed version (ground truth):
private void setReadLocation(long value){
  readLocationAtomic.set(value);
}
Program: 52261
Project: 52261
Buggy source:
private boolean casMagicOffset(long expected,long value){
  if (Jvm.vmSupportsCS8())   return bytes.compareAndSwapLong(MAGIC_OFFSET,expected,value);
synchronized (bytes) {
    if (bytes.readVolatileLong(MAGIC_OFFSET) == expected) {
      bytes.writeOrderedLong(MAGIC_OFFSET,value);
      return true;
    }
    return false;
  }
}

Fixed version (ground truth):
private boolean casMagicOffset(long expected,long value){
synchronized (bytes) {
    if (bytes.readVolatileLong(MAGIC_OFFSET) == expected) {
      bytes.writeOrderedLong(MAGIC_OFFSET,value);
      return true;
    }
    return false;
  }
}
Program: 52262
Project: 52262
Buggy source:
private void buildHeader(){
  bytes.position(HEADER_OFFSET);
  wire.writeMetaData(() -> wire.write(MetaDataKey.header).writeMarshallable(header.init(Compression.NONE)));
  if (!bytes.compareAndSwapLong(MAGIC_OFFSET,BUILDING,QUEUE_CREATED))   throw new AssertionError("String_Node_Str");
}

Fixed version (ground truth):
private void buildHeader(){
  bytes.position(HEADER_OFFSET);
  wire.writeMetaData(() -> wire.write(MetaDataKey.header).writeMarshallable(header.init(Compression.NONE)));
  if (!casMagicOffset(BUILDING,QUEUE_CREATED))   throw new AssertionError("String_Node_Str");
}
Program: 52263
Project: 52263
Buggy source:
private void initialiseHeader() throws IOException {
  if (bytes.compareAndSwapLong(MAGIC_OFFSET,UNINITIALISED,BUILDING)) {
    buildHeader();
  }
  readHeader();
}

Fixed version (ground truth):
private void initialiseHeader() throws IOException {
  if (casMagicOffset(UNINITIALISED,BUILDING)) {
    buildHeader();
  }
  readHeader();
}
Program: 52264
Project: 52264
Buggy source:
private boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  if (Jvm.VMSupportsCS8())   return buffer.compareAndSwapLong(writeLocationOffset,expectedValue,newValue);
synchronized (this) {
    if (expectedValue == getWriteLocation()) {
      setWriteLocation(newValue);
      return true;
    }
    return false;
  }
}

Fixed version (ground truth):
private boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  if (Jvm.vmSupportsCS8())   return buffer.compareAndSwapLong(writeLocationOffset,expectedValue,newValue);
synchronized (this) {
    if (expectedValue == getWriteLocation()) {
      setWriteLocation(newValue);
      return true;
    }
    return false;
  }
}
Program: 52265
Project: 52265
Buggy source:
private void readSome(Chronicle chronicle) throws IOException {
  ExcerptTailer tailer=chronicle.createTailer();
  StringBuilder sb=new StringBuilder();
  Function<WireIn,WireIn> reader=wire -> wire.read().text(sb);
  for (int i=0; i < RUNS; i++) {
    assertTrue(tailer.readDocument(reader));
  }
}

Fixed version (ground truth):
private void readSome(Chronicle chronicle) throws IOException {
  ExcerptTailer tailer=chronicle.createTailer();
  StringBuilder sb=new StringBuilder();
  Function<WireIn,WireIn> reader=wire -> wire.read(TestKey.test).text(sb);
  for (int i=0; i < RUNS; i++) {
    assertTrue(tailer.readDocument(reader));
  }
}
Program: 52266
Project: 52266
Buggy source:
@Test public void testCreateAppender() throws Exception {
  for (int t=0; t < 10; t++) {
    String name="String_Node_Str" + System.nanoTime() + "String_Node_Str";
    new File(name).deleteOnExit();
    Chronicle chronicle=new ChronicleQueueBuilder(name).build();
    long start=System.nanoTime();
    writeSome(chronicle);
    long mid=System.nanoTime();
    readSome(chronicle);
    long end=System.nanoTime();
    System.out.printf("String_Node_Str",(mid - start) / RUNS,(end - mid) / RUNS);
  }
}

Fixed version (ground truth):
@Test public void testCreateAppender() throws Exception {
  for (int r=0; r < 2; r++) {
    for (int t=1; t <= 12; t++) {
      List<Future<?>> futureList=new ArrayList<>();
      long start=System.nanoTime();
      for (int j=0; j < 4; j++) {
        String name="String_Node_Str" + start + "String_Node_Str"+ j+ "String_Node_Str";
        new File(name).deleteOnExit();
        Chronicle chronicle=new ChronicleQueueBuilder(name).build();
        futureList.add(ForkJoinPool.commonPool().submit(() -> {
          writeSome(chronicle);
          return null;
        }
));
      }
      for (      Future<?> future : futureList) {
        future.get();
      }
      futureList.clear();
      long mid=System.nanoTime();
      for (int j=0; j < 4; j++) {
        String name="String_Node_Str" + start + "String_Node_Str"+ j+ "String_Node_Str";
        new File(name).deleteOnExit();
        Chronicle chronicle=new ChronicleQueueBuilder(name).build();
        futureList.add(ForkJoinPool.commonPool().submit(() -> {
          readSome(chronicle);
          return null;
        }
));
      }
      for (      Future<?> future : futureList) {
        future.get();
      }
      long end=System.nanoTime();
      System.out.printf("String_Node_Str",t,t * RUNS * 1e3 / (mid - start),t * RUNS * 1e3 / (end - mid));
    }
  }
}
Program: 52267
Project: 52267
Buggy source:
private void writeSome(Chronicle chronicle) throws IOException {
  ExcerptAppender appender=chronicle.createAppender();
  for (int i=0; i < RUNS; i++) {
    appender.writeDocument(wire -> wire.write().text("String_Node_Str"));
  }
}

Fixed version (ground truth):
private void writeSome(Chronicle chronicle) throws IOException {
  ExcerptAppender appender=chronicle.createAppender();
  for (int i=0; i < RUNS; i++) {
    appender.writeDocument(wire -> wire.write(TestKey.test).text("String_Node_Str"));
  }
}
Program: 52268
Project: 52268
Buggy source:
@Override public String toDebugString(long limit){
  return wrappedCommon.toDebugString(limit);
}

Fixed version (ground truth):
@Override public String toDebugString(){
  return wrappedCommon.toDebugString();
}
Program: 52269
Project: 52269
Buggy source:
public boolean nextIndex(){
  checkNotClosed();
  if (index < 0) {
    toStart();
    if (index < 0)     return false;
  }
  long nextIndex=index + 1;
  while (true) {
    boolean found=index(nextIndex);
    if (found) {
      return true;
    }
    int cycle=(int)(nextIndex / builder.entriesPerCycle());
    if (cycle >= cycle()) {
      return false;
    }
    nextIndex=(cycle + 1) * builder.entriesPerCycle();
  }
}

Fixed version (ground truth):
public boolean nextIndex(){
  checkNotClosed();
  if (index < 0) {
    toStart();
    if (index < 0)     return false;
  }
  long nextIndex=index + 1;
  while (true) {
    boolean found=index(nextIndex);
    if (found) {
      index=nextIndex;
      return true;
    }
    int cycle=(int)(nextIndex / builder.entriesPerCycle());
    if (cycle >= cycle()) {
      return false;
    }
    nextIndex=(cycle + 1) * builder.entriesPerCycle();
  }
}
Program: 52270
Project: 52270
Buggy source:
@Override public void finish(){
  super.finish();
  int length=~(int)(positionAddr - startAddr);
  NativeBytes.UNSAFE.putOrderedInt(null,startAddr - 4,length);
  int offset=(int)(startAddr - dataBytes.address());
  long dataOffset=dataBytes.index() * config.dataBlockSize() + offset;
  long indexValue=((long)appenderThreadId << INDEX_DATA_OFFSET_BITS) + dataOffset;
  lastWrittenIndex=indexValue;
  try {
    if (!VanillaIndexCache.append(indexBytes,indexValue,nextSynchronous)) {
      if (indexBytes != null) {
        indexBytes.release();
        indexBytes=null;
      }
      indexBytes=indexCache.append(appenderCycle,indexValue,nextSynchronous);
    }
  }
 catch (  IOException e) {
    throw new AssertionError(e);
  }
  dataBytes.positionAddr(positionAddr);
  dataBytes.alignPositionAddr(4);
  if (nextSynchronous) {
    dataBytes.force();
  }
}

Fixed version (ground truth):
@Override public void finish(){
  super.finish();
  int length=~(int)(positionAddr - startAddr);
  NativeBytes.UNSAFE.putOrderedInt(null,startAddr - 4,length);
  int offset=(int)(startAddr - dataBytes.address());
  long dataOffset=dataBytes.index() * config.dataBlockSize() + offset;
  long indexValue=((long)appenderThreadId << INDEX_DATA_OFFSET_BITS) + dataOffset;
  try {
    long position=VanillaIndexCache.append(indexBytes,indexValue,nextSynchronous);
    if (position < 0) {
      if (indexBytes != null) {
        indexBytes.release();
        indexBytes=null;
      }
      indexBytes=indexCache.append(appenderCycle,indexValue,nextSynchronous,positionArr);
      setLastWrittenIndex(indexFrom(appenderCycle,positionArr[0]));
    }
 else {
      setLastWrittenIndex(indexFrom(appenderCycle,position));
    }
  }
 catch (  IOException e) {
    throw new AssertionError(e);
  }
  setIndex(lastWrittenIndex() + 1);
  dataBytes.positionAddr(positionAddr);
  dataBytes.alignPositionAddr(4);
  if (nextSynchronous) {
    dataBytes.force();
  }
}
Program: 52271
Project: 52271
Buggy source:
/** 
 * Return the last index written by the appender. This may not be the actual last index in the Chronicle which can be found from lastIndex().
 */
@Override public long lastWrittenIndex(){
  return VanillaChronicle.this.lastWrittenIndex();
}

Fixed version (ground truth):
/** 
 * Return the last index written by the appender. This may not be the actual last index in the Chronicle which can be found from lastIndex().
 */
@Override public long lastWrittenIndex(){
  return lastWrittenIndex;
}
Program: 52272
Project: 52272
Buggy source:
public static boolean append(final VanillaMappedBytes bytes,final long indexValue,final boolean synchronous){
  if (bytes != null) {
    boolean endOfFile=false;
    while (!endOfFile) {
      final long position=bytes.position();
      endOfFile=(bytes.limit() - position) < 8;
      if (!endOfFile) {
        if (bytes.compareAndSwapLong(position,0L,indexValue)) {
          if (synchronous) {
            bytes.force();
          }
          return true;
        }
        bytes.position(position + 8);
      }
    }
  }
  return false;
}

Fixed version (ground truth):
public static long append(final VanillaMappedBytes bytes,final long indexValue,final boolean synchronous){
  if (bytes != null) {
    boolean endOfFile=false;
    while (!endOfFile) {
      final long position=bytes.position();
      endOfFile=(bytes.limit() - position) < 8;
      if (!endOfFile) {
        if (bytes.compareAndSwapLong(position,0L,indexValue)) {
          if (synchronous) {
            bytes.force();
          }
          return position;
        }
        bytes.position(position + 8);
      }
    }
  }
  return -1;
}
Program: 52273
Project: 52273
Buggy source:
@Override public Void call() throws Exception {
  long counter=startValue;
  while (counter < endValue) {
    final VanillaMappedBytes vmb=cache.append(cycle,counter,false);
    if (vmb != null) {
      vmb.release();
    }
    counter++;
  }
  return null;
}

Fixed version (ground truth):
@Override public Void call() throws Exception {
  long counter=startValue;
  while (counter < endValue) {
    final VanillaMappedBytes vmb=cache.append(cycle,counter,false,new long[1]);
    if (vmb != null) {
      vmb.release();
    }
    counter++;
  }
  return null;
}
Program: 52274
Project: 52274
Buggy source:
private Callable<Void> createAppendTask(final VanillaIndexCache cache,final int cycle,final long startValue,final long endValue){
  return new Callable<Void>(){
    @Override public Void call() throws Exception {
      long counter=startValue;
      while (counter < endValue) {
        final VanillaMappedBytes vmb=cache.append(cycle,counter,false);
        if (vmb != null) {
          vmb.release();
        }
        counter++;
      }
      return null;
    }
  }
;
}

Fixed version (ground truth):
private Callable<Void> createAppendTask(final VanillaIndexCache cache,final int cycle,final long startValue,final long endValue){
  return new Callable<Void>(){
    @Override public Void call() throws Exception {
      long counter=startValue;
      while (counter < endValue) {
        final VanillaMappedBytes vmb=cache.append(cycle,counter,false,new long[1]);
        if (vmb != null) {
          vmb.release();
        }
        counter++;
      }
      return null;
    }
  }
;
}
Program: 52275
Project: 52275
Buggy source:
@Override public void finish(){
  super.finish();
  if (dataBytes != null) {
    int length=~(int)(positionAddr - startAddr);
    NativeBytes.UNSAFE.putOrderedInt(null,startAddr - 4,length);
    long indexValue=((long)appenderThreadId << INDEX_DATA_OFFSET_BITS) + dataOffset;
    try {
      long position=VanillaIndexCache.append(indexBytes,indexValue,nextSynchronous);
      if (position < 0) {
        if (indexBytes != null) {
          indexBytes.release();
          indexBytes=null;
        }
        indexBytes=indexCache.append(appenderCycle,indexValue,nextSynchronous,positionArr);
        setLastWrittenIndex(indexFrom(appenderCycle,positionArr[0]));
      }
 else {
        setLastWrittenIndex(indexFrom(appenderCycle,position));
      }
    }
 catch (    IOException e) {
      throw new AssertionError(e);
    }
    setIndex(lastWrittenIndex() + 1);
    dataBytes.positionAddr(positionAddr);
    dataBytes.alignPositionAddr(4);
    if (nextSynchronous) {
      dataBytes.force();
    }
  }
}

Fixed version (ground truth):
@Override public void finish(){
  super.finish();
  if (dataBytes == null)   return;
  int length=~(int)(positionAddr - startAddr);
  NativeBytes.UNSAFE.putOrderedInt(null,startAddr - 4,length);
  int offset=(int)(startAddr - dataBytes.address());
  long dataOffset=dataBytes.index() * config.dataBlockSize() + offset;
  long indexValue=((long)appenderThreadId << INDEX_DATA_OFFSET_BITS) + dataOffset;
  try {
    long position=VanillaIndexCache.append(indexBytes,indexValue,nextSynchronous);
    if (position < 0) {
      if (indexBytes != null) {
        indexBytes.release();
        indexBytes=null;
      }
      indexBytes=indexCache.append(appenderCycle,indexValue,nextSynchronous,positionArr);
      setLastWrittenIndex(indexFrom(appenderCycle,positionArr[0]));
    }
 else {
      setLastWrittenIndex(indexFrom(appenderCycle,position));
    }
  }
 catch (  IOException e) {
    throw new AssertionError(e);
  }
  setIndex(lastWrittenIndex() + 1);
  dataBytes.positionAddr(positionAddr);
  dataBytes.alignPositionAddr(4);
  if (nextSynchronous) {
    dataBytes.force();
  }
}
Program: 52276
Project: 52276
Buggy source:
public VanillaFile(String basePath,String cycleStr,String name,int indexCount,long size,boolean forAppend) throws IOException {
  logger=Logger.getLogger(VanillaFile.class.getName() + "String_Node_Str" + name);
  File dir=new File(basePath,cycleStr);
  this.indexCount=indexCount;
  if (!dir.isDirectory()) {
    boolean created=dir.mkdirs();
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + dir + "String_Node_Str"+ created);
  }
  file=new File(dir,name);
  if (file.exists()) {
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + file);
  }
 else   if (forAppend) {
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + file);
  }
 else {
    throw new FileNotFoundException(file.getAbsolutePath());
  }
  fc=new RandomAccessFile(file,"String_Node_Str").getChannel();
  map=fc.map(FileChannel.MapMode.READ_WRITE,0,size);
  map.order(ByteOrder.nativeOrder());
  baseAddr=((DirectBuffer)map).address();
  bytes=new NativeBytes(null,baseAddr,baseAddr + size,usage);
}

Fixed version (ground truth):
public VanillaFile(String basePath,String cycleStr,String name,int indexCount,long size,boolean forAppend) throws IOException {
  logger=Logger.getLogger(VanillaFile.class.getName() + "String_Node_Str" + name);
  File dir=new File(basePath,cycleStr);
  this.indexCount=indexCount;
  if (!forAppend) {
    File f=new File(dir,name);
    if (!f.exists()) {
      throw new FileNotFoundException(f.getAbsolutePath());
    }
  }
  if (!dir.isDirectory()) {
    boolean created=dir.mkdirs();
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + dir + "String_Node_Str"+ created);
  }
  file=new File(dir,name);
  if (file.exists()) {
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + file);
  }
 else   if (forAppend) {
    if (logger.isLoggable(Level.FINE))     logger.fine("String_Node_Str" + file);
  }
 else {
    throw new FileNotFoundException(file.getAbsolutePath());
  }
  fc=new RandomAccessFile(file,"String_Node_Str").getChannel();
  map=fc.map(FileChannel.MapMode.READ_WRITE,0,size);
  map.order(ByteOrder.nativeOrder());
  baseAddr=((DirectBuffer)map).address();
  bytes=new NativeBytes(null,baseAddr,baseAddr + size,usage);
}
Program: 52279
Project: 52279
Buggy source:
@Test public void testReplication() throws IOException {
  int RUNS=100;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str"),0);
  int localPort=chronicle.getLocalPort();
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str"),"String_Node_Str",localPort);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      tailer.nextIndex();
      assertTrue("String_Node_Str" + i + "String_Node_Str"+ tailer.remaining(),tailer.remaining() > 0);
      assertEquals("String_Node_Str" + i,value,tailer.parseLong());
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.clear();
  }
}

Fixed version (ground truth):
@Test public void testReplication() throws IOException {
  int RUNS=100;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str"),0);
  int localPort=chronicle.getLocalPort();
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str"),"String_Node_Str",localPort);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      boolean nextIndex=tailer.nextIndex();
      long val=tailer.parseLong();
      System.out.println(val);
      assertEquals("String_Node_Str" + i,value,val);
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.close();
    chronicle2.clear();
    chronicle.clear();
  }
}
Program: 52280
Project: 52280
Buggy source:
@Test public void testReplicationWithRolling() throws Exception {
  int RUNS=500;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleConfig config=new VanillaChronicleConfig();
  config.cycleLength(1000);
  config.cycleFormat("String_Node_Str");
  config.entriesPerCycle(1L << 20);
  config.indexBlockSize(16L << 10);
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str",config),0);
  int localPort=chronicle.getLocalPort();
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str",config),"String_Node_Str",localPort);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      Thread.sleep(10);
      tailer.nextIndex();
      assertEquals("String_Node_Str" + i,value,tailer.parseLong());
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.clear();
  }
}

Fixed version (ground truth):
@Test public void testReplicationWithRolling() throws Exception {
  int RUNS=500;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleConfig config=new VanillaChronicleConfig();
  config.cycleLength(1000);
  config.cycleFormat("String_Node_Str");
  config.entriesPerCycle(1L << 20);
  config.indexBlockSize(16L << 10);
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str",config),0);
  int localPort=chronicle.getLocalPort();
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str",config),"String_Node_Str",localPort);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      Thread.sleep(10);
      tailer.nextIndex();
      assertEquals("String_Node_Str" + i,value,tailer.parseLong());
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.close();
    chronicle2.clear();
    chronicle.clear();
  }
}
Program: 52281
Project: 52281
Buggy source:
@Test public void testReplicationWithRolling2() throws Exception {
  int RUNS=100;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleConfig config=new VanillaChronicleConfig();
  config.cycleLength(1000);
  config.cycleFormat("String_Node_Str");
  config.entriesPerCycle(1L << 20);
  config.indexBlockSize(16L << 10);
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str",config),55555);
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str",config),"String_Node_Str",55555);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      Thread.sleep(100);
      tailer.nextIndex();
      long val=tailer.parseLong();
      assertEquals("String_Node_Str" + i,value,val);
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.clear();
  }
}

Fixed version (ground truth):
@Test public void testReplicationWithRolling2() throws Exception {
  int RUNS=100;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  VanillaChronicleConfig config=new VanillaChronicleConfig();
  config.cycleLength(1000);
  config.cycleFormat("String_Node_Str");
  config.entriesPerCycle(1L << 20);
  config.indexBlockSize(16L << 10);
  VanillaChronicleSource chronicle=new VanillaChronicleSource(new VanillaChronicle(basePath + "String_Node_Str",config),55555);
  VanillaChronicleSink chronicle2=new VanillaChronicleSink(new VanillaChronicle(basePath + "String_Node_Str",config),"String_Node_Str",55555);
  try {
    ExcerptAppender appender=chronicle.createAppender();
    ExcerptTailer tailer=chronicle2.createTailer();
    for (int i=0; i < RUNS; i++) {
      appender.startExcerpt();
      long value=1000000000 + i;
      appender.append(value).append(' ');
      appender.finish();
      Thread.sleep(100);
      tailer.nextIndex();
      long val=tailer.parseLong();
      assertEquals("String_Node_Str" + i,value,val);
      assertEquals("String_Node_Str" + i,0,tailer.remaining());
      tailer.finish();
    }
  }
  finally {
    chronicle2.close();
    chronicle.close();
    chronicle2.clear();
    chronicle.clear();
  }
}
Program: 52282
Project: 52282
Buggy source:
@Override public void report(@NotNull MetaData metaData,SmallReport smallReport){
  if (metaData.sourceId != gwId)   return;
  int count=reportCount.getAndIncrement();
  if (!throughputTest) {
    times[Math.abs(count)]=(metaData.inReadTimestamp - metaData.inWriteTimestamp);
  }
}

Fixed version (ground truth):
@Override public void report(@NotNull MetaData metaData,SmallReport smallReport){
  if (metaData.sourceId != gwId)   return;
  int count=reportCount.getAndIncrement();
  if (!throughputTest) {
    times[Math.abs(count)]=(metaData.outReadTimestamp - metaData.inWriteTimestamp);
  }
}
Program: 52284
Project: 52284
Buggy source:
private long findTheLastIndex0(){
  long size=indexFileCache.size();
  if (size <= 0) {
    return -1;
  }
  int indexBlockSize=config.indexBlockSize();
  for (long block=size / indexBlockSize; block >= 0; block--) {
    MappedByteBuffer mbb=indexFileCache.acquireBuffer(block,false);
    if (block > 0 && mbb.getLong(0) == 0) {
      continue;
    }
    int cacheLineSize=config.cacheLineSize();
    for (int pos=0; pos < indexBlockSize; pos+=cacheLineSize) {
      if (mbb.getLong(pos + cacheLineSize) == 0) {
        int pos2=8;
        for (pos2=8; pos2 < cacheLineSize - 4; pos+=4) {
          if (mbb.getInt(pos + pos2) == 0)           break;
        }
        return (block * indexBlockSize + pos) / cacheLineSize * (cacheLineSize / 4 - 2) + pos / 4 - 1;
      }
    }
    return (block + 1) * indexBlockSize / cacheLineSize * (cacheLineSize / 4 - 2);
  }
  return -1;
}

Fixed version (ground truth):
private long findTheLastIndex0(){
  long size=indexFileCache.size();
  if (size <= 0) {
    return -1;
  }
  int indexBlockSize=config.indexBlockSize();
  for (long block=size / indexBlockSize; block >= 0; block--) {
    MappedByteBuffer mbb=indexFileCache.acquireBuffer(block,false);
    mbb.order(ByteOrder.nativeOrder());
    if (block > 0 && mbb.getLong(0) == 0) {
      continue;
    }
    int cacheLineSize=config.cacheLineSize();
    for (int pos=0; pos < indexBlockSize; pos+=cacheLineSize) {
      if (pos + cacheLineSize >= indexBlockSize || mbb.getLong(pos + cacheLineSize) == 0) {
        int pos2=8;
        for (pos2=8; pos2 < cacheLineSize; pos2+=4) {
          if (mbb.getInt(pos + pos2) == 0)           break;
        }
        return (block * indexBlockSize + pos) / cacheLineSize * (cacheLineSize / 4 - 2) + pos2 / 4 - 3;
      }
    }
    return (block + 1) * indexBlockSize / cacheLineSize * (cacheLineSize / 4 - 2);
  }
  return -1;
}
Program: 52285
Project: 52285
Buggy source:
public static void main(String... args) throws IOException {
  int zeros=0;
  FileChannel fc;
  try {
    fc=new FileInputStream(args[0]).getChannel();
  }
 catch (  FileNotFoundException e) {
    System.err.println(e);
    return;
  }
  ByteBuffer buffer=ByteBuffer.allocateDirect(4096).order(ByteOrder.nativeOrder());
  while (fc.read(buffer) > 0) {
    for (int i=0; i < buffer.capacity(); i+=4 * 16) {
      long indexStart=buffer.getLong(i);
      if (indexStart == 0 && zeros++ > 2) {
        continue;
      }
      System.out.print(HEX ? Long.toHexString(indexStart) : "String_Node_Str" + indexStart);
      for (int j=i + 8; j < i + 64; j+=4) {
        System.out.print(' ');
        int offset=buffer.getInt(j);
        System.out.print(HEX ? Integer.toHexString(offset) : "String_Node_Str" + offset);
      }
      System.out.println();
    }
    buffer.clear();
  }
  fc.close();
}

Fixed version (ground truth):
public static void main(String... args) throws IOException {
  int zeros=0;
  FileChannel fc;
  try {
    fc=new FileInputStream(args[0]).getChannel();
  }
 catch (  FileNotFoundException e) {
    System.err.println(e);
    return;
  }
  ByteBuffer buffer=ByteBuffer.allocateDirect(4096).order(ByteOrder.nativeOrder());
  while (fc.read(buffer) > 0) {
    for (int i=0; i < buffer.capacity(); i+=4 * 16) {
      long indexStart=buffer.getLong(i);
      if (indexStart == 0 && zeros++ > 2) {
        continue;
      }
      System.out.print(HEX ? Long.toHexString(indexStart) : String.valueOf(indexStart));
      for (int j=i + 8; j < i + 64; j+=4) {
        System.out.print(' ');
        int offset=buffer.getInt(j);
        System.out.print(HEX ? Integer.toHexString(offset) : String.valueOf(offset));
      }
      System.out.println();
    }
    buffer.clear();
  }
  fc.close();
}
Program: 52286
Project: 52286
Buggy source:
@Test @Ignore public void testAppending() throws IOException {
  int counter=0;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  ChronicleTools.deleteDirOnExit(basePath);
  for (int k=0; k < 15; k++) {
    RollingChronicle rc=new RollingChronicle(basePath,ChronicleConfig.TEST);
    ExcerptAppender appender=rc.createAppender();
    assertEquals("String_Node_Str" + k,(long)counter,appender.size());
    for (int i=0; i < 1; i++) {
      appender.startExcerpt(4);
      appender.writeInt(counter++);
      appender.finish();
      assertEquals("String_Node_Str" + k + "String_Node_Str"+ i,(long)counter,appender.size());
    }
    appender.close();
    rc.close();
  }
  RollingChronicle rc=new RollingChronicle(basePath,ChronicleConfig.TEST);
  ExcerptTailer tailer=rc.createTailer();
  for (int i=0; i < counter; i++) {
    assertTrue("String_Node_Str" + i,tailer.nextIndex());
    assertEquals(i,tailer.readInt());
    tailer.finish();
  }
  rc.close();
}

Fixed version (ground truth):
@Test @Ignore public void testAppending() throws IOException {
  int counter=0;
  String basePath=System.getProperty("String_Node_Str") + "String_Node_Str";
  ChronicleTools.deleteDirOnExit(basePath);
  for (int k=0; k < 15; k++) {
    RollingChronicle rc=new RollingChronicle(basePath,ChronicleConfig.TEST);
    ExcerptAppender appender=rc.createAppender();
    assertEquals("String_Node_Str" + k,(long)counter,appender.size());
    for (int i=0; i < ChronicleConfig.TEST.indexFileExcerpts() * 2 / 7; i++) {
      appender.startExcerpt(4);
      appender.writeInt(counter++);
      appender.finish();
      assertEquals("String_Node_Str" + k + "String_Node_Str"+ i,(long)counter,appender.size());
    }
    appender.close();
    rc.close();
  }
  RollingChronicle rc=new RollingChronicle(basePath,ChronicleConfig.TEST);
  ExcerptTailer tailer=rc.createTailer();
  for (int i=0; i < counter; i++) {
    assertTrue("String_Node_Str" + i,tailer.nextIndex());
    assertEquals(i,tailer.readInt());
    tailer.finish();
  }
  rc.close();
}
Program: 52287
Project: 52287
Buggy source:
protected boolean indexForRead(long l){
  if (l < 0) {
    padding=true;
    return false;
  }
  long indexLookup=l / indexEntriesPerBlock;
  indexBuffer=chronicle.indexFileCache.acquireBuffer(indexLookup,true);
  indexStartAddr=((DirectBuffer)indexBuffer).address();
  long indexLookupMod=l % indexEntriesPerBlock;
  int indexLineEntry=(int)(indexLookupMod % indexEntriesPerLine);
  int indexLineStart=(int)(indexLookupMod / indexEntriesPerLine * cacheLineSize);
  int inLine=(indexLineEntry << 2) + 8;
  int dataOffsetEnd=UNSAFE.getInt(indexStartAddr + indexLineStart + inLine);
  indexBaseForLine=UNSAFE.getLong(indexStartAddr + indexLineStart);
  indexPositionAddr=indexStartAddr + indexLineStart + inLine;
  long dataOffsetStart=inLine == 0 ? indexBaseForLine : (indexBaseForLine + Math.abs(UNSAFE.getInt(indexPositionAddr - 4)));
  long dataLookup=dataOffsetStart / dataBlockSize;
  long dataLookupMod=dataOffsetStart % dataBlockSize;
  MappedByteBuffer dataMBB=chronicle.dataFileCache.acquireBuffer(dataLookup,true);
  long dataAddr=((DirectBuffer)dataMBB).address();
  startAddr=positionAddr=dataAddr + dataLookupMod;
  index=l;
  if (dataOffsetEnd > 0) {
    limitAddr=dataAddr + (indexBaseForLine + dataOffsetEnd - dataLookup * dataBlockSize);
    indexPositionAddr+=4;
    padding=false;
    return true;
  }
 else   if (dataOffsetEnd == 0) {
    limitAddr=startAddr;
    padding=false;
    return false;
  }
 else {
    padding=true;
    return false;
  }
}

Fixed version (ground truth):
protected boolean indexForRead(long l){
  if (l < 0) {
    indexBuffer=chronicle.indexFileCache.acquireBuffer(0,true);
    indexStartAddr=((DirectBuffer)indexBuffer).address();
    indexPositionAddr=indexStartAddr;
    index=-1;
    padding=true;
    return false;
  }
  long indexLookup=l / indexEntriesPerBlock;
  indexBuffer=chronicle.indexFileCache.acquireBuffer(indexLookup,true);
  indexStartAddr=((DirectBuffer)indexBuffer).address();
  long indexLookupMod=l % indexEntriesPerBlock;
  int indexLineEntry=(int)(indexLookupMod % indexEntriesPerLine);
  int indexLineStart=(int)(indexLookupMod / indexEntriesPerLine * cacheLineSize);
  int inLine=(indexLineEntry << 2) + 8;
  int dataOffsetEnd=UNSAFE.getInt(indexStartAddr + indexLineStart + inLine);
  indexBaseForLine=UNSAFE.getLong(indexStartAddr + indexLineStart);
  indexPositionAddr=indexStartAddr + indexLineStart + inLine;
  long dataOffsetStart=inLine == 0 ? indexBaseForLine : (indexBaseForLine + Math.abs(UNSAFE.getInt(indexPositionAddr - 4)));
  long dataLookup=dataOffsetStart / dataBlockSize;
  long dataLookupMod=dataOffsetStart % dataBlockSize;
  MappedByteBuffer dataMBB=chronicle.dataFileCache.acquireBuffer(dataLookup,true);
  long dataAddr=((DirectBuffer)dataMBB).address();
  startAddr=positionAddr=dataAddr + dataLookupMod;
  index=l;
  if (dataOffsetEnd > 0) {
    limitAddr=dataAddr + (indexBaseForLine + dataOffsetEnd - dataLookup * dataBlockSize);
    indexPositionAddr+=4;
    padding=false;
    return true;
  }
 else   if (dataOffsetEnd == 0) {
    limitAddr=startAddr;
    padding=false;
    return false;
  }
 else {
    padding=true;
    return false;
  }
}
Program: 52289
Project: 52289
Buggy source:
public static void main(String... ignored) throws IOException {
  ChronicleTools.warmup();
  if (GWMain.WITH_BINDING)   PosixJNAAffinity.INSTANCE.setAffinity(1L << 5);
  String tmp=System.getProperty("String_Node_Str");
  ChronicleConfig config=ChronicleConfig.DEFAULT.clone();
  String pePath=tmp + "String_Node_Str";
  IndexedChronicle pe2gw=new IndexedChronicle(pePath,config);
  ExcerptAppender excerpt=pe2gw.createAppender();
  final Pe2GwWriter pe2GwWriter=new Pe2GwWriter(excerpt);
  Gw2PeEvents listener=new PEEvents(pe2GwWriter);
  Gw2PeReader[] readers=new Gw2PeReader[1];
  IndexedChronicle[] gw2pe=new IndexedChronicle[readers.length];
  for (int i=0; i < readers.length; i++) {
    int sourceId=i + 1;
    String gw2pePath=tmp + "String_Node_Str" + sourceId;
    gw2pe[i]=new IndexedChronicle(gw2pePath,config);
    readers[i]=new Gw2PeReader(sourceId,gw2pe[i].createTailer(),listener);
  }
  long prevProcessed=0, count=0;
  do {
    boolean readOne=false;
    for (    Gw2PeReader reader : readers) {
      readOne|=reader.readOne();
    }
    if (readOne) {
      count=0;
    }
 else     if (count++ > 1000000) {
      long processed=excerpt.index() + 1;
      if (prevProcessed != processed) {
        System.out.printf("String_Node_Str",processed);
        prevProcessed=processed;
      }
    }
  }
 while (true);
}

Fixed version (ground truth):
public static void main(String... ignored) throws IOException {
  ChronicleTools.warmup();
  if (GWMain.WITH_BINDING)   PosixJNAAffinity.INSTANCE.setAffinity(1L << 5);
  String tmp=System.getProperty("String_Node_Str");
  ChronicleConfig config=ChronicleConfig.DEFAULT.clone();
  String pePath=tmp + "String_Node_Str";
  ChronicleTools.deleteDirOnExit(pePath);
  IndexedChronicle pe2gw=new IndexedChronicle(pePath,config);
  ExcerptAppender excerpt=pe2gw.createAppender();
  final Pe2GwWriter pe2GwWriter=new Pe2GwWriter(excerpt);
  Gw2PeEvents listener=new PEEvents(pe2GwWriter);
  Gw2PeReader[] readers=new Gw2PeReader[1];
  IndexedChronicle[] gw2pe=new IndexedChronicle[readers.length];
  for (int i=0; i < readers.length; i++) {
    int sourceId=i + 1;
    String gw2pePath=tmp + "String_Node_Str" + sourceId;
    ChronicleTools.deleteDirOnExit(gw2pePath);
    gw2pe[i]=new IndexedChronicle(gw2pePath,config);
    readers[i]=new Gw2PeReader(sourceId,gw2pe[i].createTailer(),listener);
  }
  long prevProcessed=0, count=0;
  do {
    boolean readOne=false;
    for (    Gw2PeReader reader : readers) {
      readOne|=reader.readOne();
    }
    if (readOne) {
      count=0;
    }
 else     if (count++ > 1000000) {
      long processed=excerpt.index() + 1;
      if (prevProcessed != processed) {
        System.out.printf("String_Node_Str",processed);
        prevProcessed=processed;
      }
    }
  }
 while (true);
}
Program: 52290
Project: 52290
Buggy source:
@Override public void addPaddedEntry(){
  if (index != lastWrittenIndex()) {
    toEnd();
  }
  checkNewIndexLine();
  writePaddedEntry();
  loadNextDataBuffer();
  checkNewIndexLine();
  finished=true;
}

Fixed version (ground truth):
@Override public void addPaddedEntry(){
  if (index != lastWrittenIndex()) {
    toEnd();
  }
  if (index == 322)   Thread.yield();
  checkNewIndexLine();
  writePaddedEntry();
  loadNextDataBuffer();
  checkNewIndexLine();
  finished=true;
}
Program: 52291
Project: 52291
Buggy source:
void checkNewIndexLine2(){
  if ((indexPositionAddr & cacheLineMask) == 8) {
    indexBaseForLine=UNSAFE.getLongVolatile(null,indexPositionAddr - 8);
    setLmitAddr(0);
  }
}

Fixed version (ground truth):
void checkNewIndexLine2(){
}
Program: 52292
Project: 52292
Buggy source:
public boolean nextIndex(){
  return nextIndex0() || nextIndex0();
}

Fixed version (ground truth):
public boolean nextIndex(){
  checkNextLine();
  long offset=UNSAFE.getInt(null,indexPositionAddr);
  if (offset == 0)   offset=UNSAFE.getIntVolatile(null,indexPositionAddr);
  if (offset == 0) {
    return false;
  }
  index++;
  return nextIndex0(offset) || nextIndex1();
}
Program: 52295
Project: 52295
Buggy source:
/** 
 * Create a SimpleConnection object from a GuacamoleConfiguration, obtain an identifier, and place it on the tree, returning the identifier value of the new connection.
 * @param config The GuacamoleConfiguration to use to create the SimpleConnection object.
 * @return The identifier of the connection created in the directory.
 * @throws GuacamoleException If an error occurs adding the object to the tree.
 */
public String create(GuacamoleConfiguration config) throws GuacamoleException {
  String connectionId=Integer.toString(getNextConnectionID());
  String name=QCParser.getName(config);
  Connection connection=new SimpleConnection(name,connectionId,config);
  connection.setParentIdentifier(ROOT_IDENTIFIER);
  add(connection);
  this.rootGroup.addConnectionIdentifier(connectionId);
  return connectionId;
}

Fixed version (ground truth):
/** 
 * Create a SimpleConnection object from a GuacamoleConfiguration, obtain an identifier, and place it on the tree, returning the identifier value of the new connection.
 * @param config The GuacamoleConfiguration to use to create the SimpleConnection object.
 * @return The identifier of the connection created in the directory.
 * @throws GuacamoleException If an error occurs adding the object to the tree.
 */
public String create(GuacamoleConfiguration config) throws GuacamoleException {
  String connectionId=Integer.toString(getNextConnectionID());
  String name=QCParser.getName(config);
  Connection connection=new SimpleConnection(name,connectionId,config);
  connection.setParentIdentifier(QuickConnectUserContext.ROOT_IDENTIFIER);
  add(connection);
  this.rootGroup.addConnectionIdentifier(connectionId);
  return connectionId;
}
Program: 52296
Project: 52296
Buggy source:
/** 
 * Construct a QuickConnectUserContext using the authProvider and the username.
 * @param authProvider The authentication provider module instantiating this this class.
 * @param username The name of the user logging in and using this class.
 */
public QuickConnectUserContext(AuthenticationProvider authProvider,String username){
  this.rootGroup=new QuickConnectionGroup(DEFAULT_ROOT_CONNECTION_GROUP,DEFAULT_ROOT_CONNECTION_GROUP);
  this.self=new SimpleUser(username,Collections.<String>emptyList(),Collections.singleton(DEFAULT_ROOT_CONNECTION_GROUP));
  this.connectionDirectory=new QuickConnectDirectory(this.rootGroup);
  this.authProvider=authProvider;
}

Fixed version (ground truth):
/** 
 * Construct a QuickConnectUserContext using the authProvider and the username.
 * @param authProvider The authentication provider module instantiating this this class.
 * @param username The name of the user logging in and using this class.
 */
public QuickConnectUserContext(AuthenticationProvider authProvider,String username) throws GuacamoleException {
  this.rootGroup=new QuickConnectionGroup(ROOT_IDENTIFIER,ROOT_IDENTIFIER);
  this.connectionDirectory=new QuickConnectDirectory(this.rootGroup);
  this.self=new SimpleUser(username,connectionDirectory.getIdentifiers(),Collections.singleton(ROOT_IDENTIFIER));
  this.authProvider=authProvider;
}
Program: 52297
Project: 52297
Buggy source:
@Override public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException {
  logger.debug("String_Node_Str",authenticatedUser.getCredentials().getUsername());
  return userContext;
}

Fixed version (ground truth):
@Override public UserContext getUserContext(AuthenticatedUser authenticatedUser) throws GuacamoleException {
  logger.debug("String_Node_Str",authenticatedUser.getCredentials().getUsername());
  return new QuickConnectUserContext(this,authenticatedUser.getIdentifier());
}
Program: 52298
Project: 52298
Buggy source:
/** 
 * For QuickConnect, authenticateUser simply returns null because this extension is designed to provide only a connection directory to users that are already authenticated and not any actual authentication.
 * @param credentials Credentials object passed in from Guacamole login.
 * @returns Returns null, which causes the client to move on to the next module.
 */
@Override public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
  logger.debug("String_Node_Str");
  GuacamoleConfiguration config=new GuacamoleConfiguration();
  config.setProtocol("String_Node_Str");
  config.setParameter("String_Node_Str","String_Node_Str");
  config.setParameter("String_Node_Str","String_Node_Str");
  quickConnections.put("String_Node_Str",config);
  if (userContext == null)   userContext=new QuickConnectUserContext(this,credentials.getUsername(),quickConnections);
  return null;
}

Fixed version (ground truth):
/** 
 * For QuickConnect, authenticateUser simply returns null because this extension is designed to provide only a connection directory to users that are already authenticated and not any actual authentication.
 * @param credentials Credentials object passed in from Guacamole login.
 * @returns Returns null, which causes the client to move on to the next module.
 */
@Override public AuthenticatedUser authenticateUser(Credentials credentials) throws GuacamoleException {
  logger.debug("String_Node_Str",credentials.getUsername());
  String username=credentials.getUsername();
  if (username == null || username.isEmpty())   throw new GuacamoleInvalidCredentialsException("String_Node_Str",CredentialsInfo.USERNAME_PASSWORD);
  userContext=new QuickConnectUserContext(this,credentials.getUsername());
  return null;
}
Program: 52299
Project: 52299
Buggy source:
@Override public Map<String,GuacamoleConfiguration> getAuthorizedConfigurations(Credentials credentials) throws GuacamoleException {
  logger.debug("String_Node_Str",credentials.getUsername());
  GuacamoleConfiguration config=new GuacamoleConfiguration();
  config.setProtocol("String_Node_Str");
  config.setParameter("String_Node_Str","String_Node_Str");
  config.setParameter("String_Node_Str","String_Node_Str");
  quickConnections.put("String_Node_Str",config);
  if (userContext == null)   userContext=new QuickConnectUserContext(this,credentials.getUsername(),quickConnections);
  return quickConnections;
}

Fixed version (ground truth):
@Override public Map<String,GuacamoleConfiguration> getAuthorizedConfigurations(Credentials credentials) throws GuacamoleException {
  logger.debug("String_Node_Str",credentials.getUsername());
  if (userContext == null)   userContext=new QuickConnectUserContext(this,credentials.getUsername());
  return Collections.<String,GuacamoleConfiguration>emptyMap();
}
Program: 52300
Project: 52300
Buggy source:
@Override public Directory<User> getUserDirectory() throws GuacamoleException {
  return userDirectory;
}

Fixed version (ground truth):
@Override public Directory<User> getUserDirectory() throws GuacamoleException {
  logger.debug("String_Node_Str",userDirectory.getIdentifiers());
  return userDirectory;
}
Program: 52304
Project: 52304
Buggy source:
/** 
 * Returns the maximum number of seconds to wait for LDAP operations
 * @return The maximum number of seconds to wait for LDAP operations as configured in guacamole.properties
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getOperationTimeout() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_OPERATION_TIMEOUT,30);
}

Fixed version (ground truth):
/** 
 * Returns the maximum number of seconds to wait for LDAP operations.
 * @return The maximum number of seconds to wait for LDAP operations as configured in guacamole.properties.
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getOperationTimeout() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_OPERATION_TIMEOUT,30);
}
Program: 52305
Project: 52305
Buggy source:
/** 
 * Returns the maximum number of referral hops to follow.
 * @return The maximum number of referral hops to follow as configured in guacamole.properties
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getMaxReferralHops() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_MAX_REFERRAL_HOPS,5);
}

Fixed version (ground truth):
/** 
 * Returns the maximum number of referral hops to follow.
 * @return The maximum number of referral hops to follow as configured in guacamole.properties.
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public int getMaxReferralHops() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_MAX_REFERRAL_HOPS,5);
}
Program: 52306
Project: 52306
Buggy source:
/** 
 * Returns the boolean value for whether the connection should follow referrals or not.  By default, it will not.
 * @return The boolean value of whether to follow referrals as configured in guacamole.properties
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public boolean getFollowReferrals() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_FOLLOW_REFERRALS,false);
}

Fixed version (ground truth):
/** 
 * Returns the boolean value for whether the connection should follow referrals or not.  By default, it will not.
 * @return The boolean value of whether to follow referrals as configured in guacamole.properties.
 * @throws GuacamoleException If guacamole.properties cannot be parsed.
 */
public boolean getFollowReferrals() throws GuacamoleException {
  return environment.getProperty(LDAPGuacamoleProperties.LDAP_FOLLOW_REFERRALS,false);
}
Program: 52307
Project: 52307
Buggy source:
/** 
 * Creates a ReferralAuthHandler object to handle authentication when following referrals in a LDAP connection, using the provided dn and password.
 * @throws GuacamoleException If exceptions are caught while converting the password from a string into a byte array.
 */
public ReferralAuthHandler(String dn,String password) throws GuacamoleException {
  byte[] passwordBytes;
  try {
    if (password != null)     passwordBytes=password.getBytes("String_Node_Str");
 else     passwordBytes=null;
  }
 catch (  UnsupportedEncodingException e) {
    logger.error("String_Node_Str",e.getMessage());
    logger.debug("String_Node_Str",e);
    throw new GuacamoleException("String_Node_Str");
  }
  ldapAuth=new LDAPAuthProvider(dn,passwordBytes);
}

Fixed version (ground truth):
/** 
 * Creates a ReferralAuthHandler object to handle authentication when following referrals in a LDAP connection, using the provided dn and password.
 */
public ReferralAuthHandler(String dn,String password){
  byte[] passwordBytes;
  try {
    if (password != null)     passwordBytes=password.getBytes("String_Node_Str");
 else     passwordBytes=null;
  }
 catch (  UnsupportedEncodingException e) {
    logger.error("String_Node_Str",e.getMessage());
    logger.debug("String_Node_Str",e);
    throw new UnsupportedOperationException("String_Node_Str",e);
  }
  ldapAuth=new LDAPAuthProvider(dn,passwordBytes);
}