nus-yam/ex-repair huggingface dataset:
Program: 52207
Project: 52207
Buggy source:
@Override public boolean readBytes(@NotNull ReadBytesMarshallable marshallable) throws IOException {
  if (this.store == null) {
    long lastCycle=this.toStart ? queue.firstCycle() : queue.lastCycle();
    if (lastCycle == -1) {
      return false;
    }
    cycle(lastCycle);
  }
  long position=store.read(wire,marshallable);
  if (position > 0) {
    this.index++;
    return true;
  }
 else   if (position < 0) {
    cycle(Math.abs(position));
    return readBytes(marshallable);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean readBytes(@NotNull ReadBytesMarshallable marshallable) throws IOException {
  if (this.store == null) {
    throw new IllegalStateException("String_Node_Str");
  }
  long position=store.read(wire,marshallable);
  if (position > 0) {
    this.index++;
    return true;
  }
 else   if (position < 0) {
    cycle(Math.abs(position));
    return readBytes(marshallable);
  }
  return false;
}
Program: 52208
Project: 52208
Buggy source:
public synchronized void release(WireStore store){
  store.release();
  if (store.refCount() <= 0) {
    stores.remove(new RollDetails(store.cycle(),store.epoc()));
  }
}

Fixed version (ground truth):
public synchronized void release(WireStore store){
  store.release();
  if (store.refCount() <= 0) {
    stores.remove(new RollDetails(store.cycle(),store.epoch()));
  }
}
Program: 52209
Project: 52209
Buggy source:
@Override public boolean moveToIndex(long index) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug(SingleChronicleQueueStore.IndexOffset.toBinaryString(index));
    LOG.debug(SingleChronicleQueueStore.IndexOffset.toScale());
  }
  final long expectedCycle=ChronicleQueue.cycle(index);
  if (expectedCycle != cycle)   cycle(expectedCycle);
  cycle=expectedCycle;
  final long position=this.store.moveToIndex(wire,subIndex(index));
  if (position == -1)   return false;
  final Bytes<?> readContext=wire.bytes();
  readContext.readPosition(position);
  readContext.readLimit(readContext.capacity());
  this.index=index - 1;
  return true;
}

Fixed version (ground truth):
@Override public boolean moveToIndex(long index) throws IOException {
  if (LOG.isDebugEnabled()) {
    LOG.debug(SingleChronicleQueueStore.IndexOffset.toBinaryString(index));
    LOG.debug(SingleChronicleQueueStore.IndexOffset.toScale());
  }
  final long expectedCycle=ChronicleQueue.cycle(index);
  if (expectedCycle != cycle)   cycle(expectedCycle);
  cycle=expectedCycle;
  final long subIndex=subIndex(index);
  final long position=this.store.moveToIndex(wire,index);
  if (position == -1)   return false;
  final Bytes<?> readContext=wire.bytes();
  readContext.readPosition(position);
  readContext.readLimit(readContext.capacity());
  this.index=ChronicleQueue.index(cycle,subIndex - 1);
  return true;
}
Program: 52210
Project: 52210
Buggy source:
@NotNull @Override public ExcerptTailer toStart() throws IOException {
  final long index=queue.firstIndex();
  if (index == -1)   return this;
  LOG.info("String_Node_Str" + ChronicleQueue.subIndex(index) + "String_Node_Str"+ ChronicleQueue.cycle(index));
  if (!moveToIndex(index))   throw new IllegalStateException("String_Node_Str");
  return this;
}

Fixed version (ground truth):
@NotNull @Override public ExcerptTailer toStart() throws IOException {
  final long index=queue.firstIndex();
  if (index == -1)   return this;
  LOG.info("String_Node_Str" + ChronicleQueue.subIndex(index) + "String_Node_Str"+ ChronicleQueue.cycle(index));
  if (!moveToIndex(index))   throw new IllegalStateException("String_Node_Str" + cycle);
  return this;
}
Program: 52211
Project: 52211
Buggy source:
@ForceInline private WireStore store() throws IOException {
  if (this.cycle != queue.cycle()) {
    long nextCycle=queue.cycle();
    if (this.store != null) {
      this.store.appendRollMeta(wire,nextCycle);
      this.queue.release(this.store);
    }
    this.cycle=nextCycle;
    this.store=queue.storeForCycle(this.cycle,epoch);
  }
  return this.store;
}

Fixed version (ground truth):
@ForceInline private WireStore store() throws IOException {
  if (this.cycle != queue.cycle()) {
    long nextCycle=queue.cycle();
    if (this.store != null) {
      this.store.appendRollMeta(wire,nextCycle);
      this.queue.release(this.store);
    }
    this.cycle=nextCycle;
    this.store=queue.storeForCycle(this.cycle,epoch);
    this.wire=this.queue().wireType().apply(store.mappedBytes());
  }
  return this.store;
}
Program: 52212
Project: 52212
Buggy source:
private StoreTailer cycle(long cycle) throws IOException {
  if (this.cycle != cycle) {
    if (null != this.store) {
      this.queue.release(this.store);
    }
    this.cycle=cycle;
    this.index=-1;
    this.store=this.queue.storeForCycle(cycle,queue.epoch());
    wire=queue.wireType().apply(store.mappedBytes());
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + ((MappedBytes)wire.bytes()).mappedFile().file().getAbsolutePath());
  }
  return this;
}

Fixed version (ground truth):
private StoreTailer cycle(long cycle) throws IOException {
  if (this.cycle != cycle) {
    if (null != this.store) {
      this.queue.release(this.store);
    }
    this.cycle=cycle;
    this.index=-1;
    this.store=this.queue.storeForCycle(cycle,queue.epoch());
    wire=queue.wireType().apply(store.mappedBytes());
    moveToIndex(ChronicleQueue.index(cycle,0));
    if (LOG.isDebugEnabled())     LOG.debug("String_Node_Str" + ((MappedBytes)wire.bytes()).mappedFile().file().getAbsolutePath());
  }
  return this;
}
Program: 52213
Project: 52213
Buggy source:
@Override public boolean readDocument(@NotNull ReadMarshallable reader) throws IOException {
  if (this.store == null) {
    final long index=queue.firstIndex();
    if (index == -1) {
      return false;
    }
    moveToIndex(index);
  }
  long position=store.read(wire,reader);
  if (position > 0) {
    this.index++;
    return true;
  }
 else   if (position < 0) {
    cycle(Math.abs(position));
    return readDocument(reader);
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean readDocument(@NotNull ReadMarshallable reader) throws IOException {
  if (this.store == null) {
    final long index=queue.firstIndex();
    if (index == -1) {
      return false;
    }
    moveToIndex(index);
  }
  long position=store.read(wire,reader);
  if (position > 0) {
    this.index++;
    return true;
  }
 else   if (position < 0) {
    cycle(Math.abs(position));
    wire.bytes().readPosition(0);
    wire.bytes().readLimit(store.writePosition());
    return readDocument(reader);
  }
  return false;
}
Program: 52215
Project: 52215
Buggy source:
/** 
 * @return creates a new instance of mapped bytes, because, for example the tailer and appendercan be at diffent locations.
 */
@Override public MappedBytes mappedBytes(){
  return new MappedBytes(mappedFile);
}

Fixed version (ground truth):
/** 
 * @return creates a new instance of mapped bytes, because, for example the tailer and appendercan be at diffent locations.
 */
@Override public MappedBytes mappedBytes(){
  final MappedBytes mappedBytes=new MappedBytes(mappedFile);
  mappedBytes.writePosition(bounds.getWritePosition());
  mappedBytes.readPosition(bounds.getReadPosition());
  return mappedBytes;
}
Program: 52216
Project: 52216
Buggy source:
private long writeWireMarshallable(@NotNull Wire wire,long position,int size,@NotNull final WriteMarshallable marshallable) throws IOException {
  final long positionDataWritten=Wires.writeData(wire,marshallable);
  final Bytes<?> context=wire.bytes();
  bounds.setWritePositionIfGreater(context.writePosition());
  final long index=indexing.incrementLastIndex();
  indexing.storeIndexLocation(context,positionDataWritten,index);
  return index;
}

Fixed version (ground truth):
private long writeWireMarshallable(@NotNull Wire wire,long position,int size,@NotNull final WriteMarshallable marshallable) throws IOException {
  final long positionDataWritten=Wires.writeData(wire,marshallable);
  bounds.setWritePositionIfGreater(wire.bytes().writePosition());
  final long index=indexing.incrementLastIndex();
  indexing.storeIndexLocation(wire.bytes(),positionDataWritten,index);
  System.out.println("String_Node_Str" + positionDataWritten + "String_Node_Str"+ cycle()+ "String_Node_Str"+ index);
  return index;
}
Program: 52217
Project: 52217
Buggy source:
private LongArrayValues array(WireIn w,LongArrayValues using){
  w.read(() -> "String_Node_Str").int64array(using,this,(o1,o2) -> {
  }
);
  return using;
}

Fixed version (ground truth):
private LongArrayValues array(WireIn w,LongArrayValues using){
  final StringBuilder sb=Wires.acquireStringBuilder();
  final ValueIn valueIn=w.readEventName(sb);
  if (!"String_Node_Str".contentEquals(sb))   throw new IllegalStateException("String_Node_Str");
  valueIn.int64array(using,this,(o1,o2) -> {
  }
);
  return using;
}
Program: 52218
Project: 52218
Buggy source:
/** 
 * atomically gets or creates the address of the first index the index is create and another except into the queue, however this except is treated as meta data and does not increment the last index, in otherword it is not possible to access this except by calling index(), it effectively invisible to the end-user
 * @param writeContext used to write and index if it does not exist
 * @return the position of the index
 */
long indexToIndex(@Nullable final Bytes writeContext){
  for (; ; ) {
    long index2Index=this.index2Index.getVolatileValue();
    if (index2Index == NOT_READY)     continue;
    if (index2Index != NOT_INITIALIZED)     return index2Index;
    if (!this.index2Index.compareAndSwapValue(NOT_INITIALIZED,NOT_READY))     continue;
    if (writeContext == null)     return -1;
    final long index=newIndex(writeContext);
    this.index2Index.setOrderedValue(index);
    return index;
  }
}

Fixed version (ground truth):
/** 
 * atomically gets or creates the address of the first index the index is create and another except into the queue, however this except is treated as meta data and does not increment the last index, in otherword it is not possible to access this except by calling index(), it effectively invisible to the end-user
 * @param writeContext used to write and index if it does not exist
 * @return the position of the index
 */
long indexToIndex(@Nullable final Bytes writeContext){
  for (; ; ) {
    long index2Index=this.index2Index.getVolatileValue();
    if (index2Index == NOT_READY)     continue;
    if (index2Index != NOT_INITIALIZED)     return index2Index;
    if (!this.index2Index.compareAndSwapValue(NOT_INITIALIZED,NOT_READY))     continue;
    if (writeContext == null)     return -1;
    final long index=newIndex(writeContext);
    System.out.println("String_Node_Str" + index);
    this.index2Index.setOrderedValue(index);
    return index;
  }
}
Program: 52219
Project: 52219
Buggy source:
public long nextCycleMetaPosition(){
  return this.nextCycleMetaPosition.getVolatileValue();
}

Fixed version (ground truth):
public Roll nextCycleMetaPosition(long position){
  this.nextCycleMetaPosition.setOrderedValue(position);
  return this;
}
Program: 52220
Project: 52220
Buggy source:
Indexing(@NotNull WireType wireType,final MappedBytes mappedBytes){
  this.index2Index=wireType.newLongReference().get();
  this.firstIndex=wireType.newLongReference().get();
  this.lastIndex=wireType.newLongReference().get();
  final Bytes b=Bytes.elasticByteBuffer();
  templateIndex=wireType.apply(b);
  templateIndex.writeDocument(true,w -> w.write(() -> "String_Node_Str").int64array(NUMBER_OF_ENTRIES_IN_EACH_INDEX));
  this.wireType=wireType;
  this.longArray=withInitial(wireType.newLongArrayReference());
  this.indexContext=mappedBytes;
}

Fixed version (ground truth):
Indexing(@NotNull WireType wireType,final MappedBytes mappedBytes){
  this.index2Index=wireType.newLongReference().get();
  this.firstIndex=wireType.newLongReference().get();
  this.lastIndex=wireType.newLongReference().get();
  if (wireType == WireType.TEXT)   templateIndex=TEXT_TEMPLATE;
 else   if (wireType == WireType.BINARY)   templateIndex=BINARY_TEMPLATE;
 else {
    throw new UnsupportedOperationException("String_Node_Str");
  }
  this.wireType=wireType;
  this.longArray=withInitial(wireType.newLongArrayReference());
  this.indexContext=mappedBytes;
}
Program: 52221
Project: 52221
Buggy source:
@Ignore("String_Node_Str") @Test public void testAppendAndReadWithRolling2() throws IOException {
  final File dir=getTmpDir();
  final ChronicleQueue queue=new SingleChronicleQueueBuilder(dir).wireType(this.wireType).rollCycle(RollCycles.SECONDS).epoch(System.currentTimeMillis()).build();
  for (int i=0; i < 10; i++) {
    final int n=i;
    final ExcerptAppender appender=queue.createAppender();
    appender.writeDocument(w -> w.write(TestKey.test).int32(n));
    Jvm.pause(500);
  }
  final ExcerptTailer tailer=queue.createTailer().toStart();
  for (int i=0; i < 10; i++) {
    final int n=i;
    final boolean condition=tailer.readDocument(new ReadMarshallable(){
      @Override public void readMarshallable(      @NotNull WireIn r) throws IORuntimeException {
        assertEquals(n,r.read(TestKey.test).int32());
      }
    }
);
    assertTrue(condition);
  }
}

Fixed version (ground truth):
@Ignore("String_Node_Str") @Test public void testAppendAndReadWithRolling2() throws IOException {
  final File dir=getTmpDir();
  final ChronicleQueue queue=new SingleChronicleQueueBuilder(dir).wireType(this.wireType).rollCycle(RollCycles.SECONDS).epoch(1452701442361L).build();
  final ExcerptAppender appender=queue.createAppender();
  for (int i=0; i < 10; i++) {
    final int n=i;
    appender.writeDocument(w -> w.write(TestKey.test).int32(n));
    Jvm.pause(500);
  }
  final ExcerptTailer tailer=queue.createTailer().toStart();
  for (int i=0; i < 10; i++) {
    final int n=i;
    final boolean condition=tailer.readDocument(new ReadMarshallable(){
      @Override public void readMarshallable(      @NotNull WireIn r) throws IORuntimeException {
        assertEquals(n,r.read(TestKey.test).int32());
        System.out.println("String_Node_Str" + n);
      }
    }
);
    assertTrue(condition);
  }
}
Program: 52222
Project: 52222
Buggy source:
@Test public void testReadAtIndex() throws Exception {
  final File file=File.createTempFile("String_Node_Str","String_Node_Str");
  file.deleteOnExit();
  try {
    final ChronicleQueue chronicle=new SingleChronicleQueueBuilder(getTmpDir()).wireType(this.wireType).build();
    final ExcerptAppender appender=chronicle.createAppender();
    long lastIndex=-1;
    for (int i=0; i < 100; i++) {
      final int j=i;
      final long index=appender.writeDocument(wire -> wire.write(() -> "String_Node_Str").text("String_Node_Str" + j));
      lastIndex=index;
    }
    final long cycle=cycle(lastIndex);
    final ExcerptTailer tailer=chronicle.createTailer();
    StringBuilder sb=new StringBuilder();
    for (    int i : new int[]{65}) {
      tailer.moveToIndex(index(cycle,i));
      tailer.readDocument(wire -> wire.read(() -> "String_Node_Str").text(sb));
      Assert.assertEquals("String_Node_Str" + i,sb.toString());
    }
  }
  finally {
    file.delete();
  }
}

Fixed version (ground truth):
@Test public void testReadAtIndex() throws Exception {
  final File file=File.createTempFile("String_Node_Str","String_Node_Str");
  file.deleteOnExit();
  try {
    final ChronicleQueue chronicle=new SingleChronicleQueueBuilder(getTmpDir()).wireType(this.wireType).build();
    final ExcerptAppender appender=chronicle.createAppender();
    long lastIndex=-1;
    for (int i=0; i < 100; i++) {
      final int j=i;
      final long index=appender.writeDocument(wire -> wire.write(() -> "String_Node_Str").text("String_Node_Str" + j));
      lastIndex=index;
    }
    final long cycle=cycle(lastIndex);
    final ExcerptTailer tailer=chronicle.createTailer();
    StringBuilder sb=new StringBuilder();
    for (    int i : new int[]{0,64,65,66}) {
      tailer.moveToIndex(index(cycle,i));
      tailer.readDocument(wire -> wire.read(() -> "String_Node_Str").text(sb));
      Assert.assertEquals("String_Node_Str" + i,sb.toString());
    }
  }
  finally {
    file.delete();
  }
}
Program: 52223
Project: 52223
Buggy source:
@Override public void readMarshallable(@NotNull WireIn r) throws IORuntimeException {
  assertEquals(n,r.read(TestKey.test).int32());
}

Fixed version (ground truth):
@Override public void readMarshallable(@NotNull WireIn r) throws IORuntimeException {
  assertEquals(n,r.read(TestKey.test).int32());
  System.out.println("String_Node_Str" + n);
}
Program: 52224
Project: 52224
Buggy source:
protected WireStore newStore(final long cycle){
  try {
    final String cycleFormat=this.dateCache.formatFor(cycle);
    final File cycleFile=new File(this.builder.path(),cycleFormat + "String_Node_Str");
    if (!cycleFile.getParentFile().exists()) {
      cycleFile.mkdirs();
    }
    return WiredFile.<WireStore>build(cycleFile,file -> MappedFile.mappedFile(file,builder.blockSize(),builder.blockSize()),builder.wireType(),() -> new SingleChronicleQueueStore(builder.rollCycle()),ws -> ws.delegate().install(ws.mappedFile(),ws.headerLength(),ws.headerCreated(),cycle,builder,ws.wireSupplier(),ws.mappedFile())).delegate();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
protected WireStore newStore(final long cycle){
  try {
    final String cycleFormat=this.dateCache.formatFor(cycle);
    final File cycleFile=new File(this.builder.path(),cycleFormat + "String_Node_Str");
    File parentFile=cycleFile.getParentFile();
    if (parentFile != null & !parentFile.exists()) {
      parentFile.mkdirs();
    }
    return WiredFile.<WireStore>build(cycleFile,file -> MappedFile.mappedFile(file,builder.blockSize(),builder.blockSize()),builder.wireType(),() -> new SingleChronicleQueueStore(builder.rollCycle()),ws -> ws.delegate().install(ws.mappedFile(),ws.headerLength(),ws.headerCreated(),cycle,builder,ws.wireSupplier(),ws.mappedFile())).delegate();
  }
 catch (  IOException e) {
    throw new RuntimeException(e);
  }
}
Program: 52225
Project: 52225
Buggy source:
private boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  return bytesStore.compareAndSwapLong(writeLocationOffset,expectedValue,newValue);
}

Fixed version (ground truth):
private boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  boolean success=writeLocationOffsetAtomic.compareAndSet(expectedValue,newValue);
  return success;
}
Program: 52226
Project: 52226
Buggy source:
/** 
 * sets the point at which you should not write any additional bits
 */
private void setWriteUpTo(long value){
  bytesStore.writeOrderedLong(writeUpToOffset,value);
}

Fixed version (ground truth):
/** 
 * sets the point at which you should not write any additional bits
 */
private void setWriteUpTo(long value){
  writeUpToOffsetAtomic.set(value);
}
Program: 52227
Project: 52227
Buggy source:
private long getWriteLocation(){
  return bytesStore.readVolatileLong(writeLocationOffset);
}

Fixed version (ground truth):
private long getWriteLocation(){
  return writeLocationOffsetAtomic.get();
}
Program: 52228
Project: 52228
Buggy source:
private long getReadLocation(){
  return bytesStore.readVolatileLong(readLocationOffset);
}

Fixed version (ground truth):
private long getReadLocation(){
  return readLocationOffsetAtomic.get();
}
Program: 52229
Project: 52229
Buggy source:
private long read(@NotNull ReadBytesMarshallable readBytesMarshallable,long offset,long len){
  offset%=capacity();
  long endOffSet=nextOffset(offset,len);
  if (endOffSet >= offset) {
    bytes.write(byteStore,offset,len);
    readBytesMarshallable.readMarshallable(bytes);
    return endOffSet;
  }
  final long firstChunkLen=capacity() - offset;
  bytes.write(byteStore,offset,firstChunkLen);
  bytes.write(byteStore,0,len - firstChunkLen);
  readBytesMarshallable.readMarshallable(bytes);
  return endOffSet;
}

Fixed version (ground truth):
private long read(@NotNull ReadBytesMarshallable readBytesMarshallable,long offset,long len){
  offset%=capacity();
  long endOffSet=nextOffset(offset,len);
  if (endOffSet >= offset) {
    bytes.write(byteStore,offset,len);
    readBytesMarshallable.readMarshallable(bytes);
    return endOffSet;
  }
  final long firstChunkLen=capacity() - offset;
  final long l=bytes.writeLimit();
  bytes.writeLimit(bytes.writePosition() + firstChunkLen);
  bytes.write(byteStore,offset,firstChunkLen);
  bytes.writeLimit(l);
  bytes.write(byteStore,0,len - firstChunkLen);
  readBytesMarshallable.readMarshallable(bytes);
  return endOffSet;
}
Program: 52230
Project: 52230
Buggy source:
/** 
 * @return the point at which you should not write any additional bits
 */
private long getWriteUpTo(){
  return bytesStore.readVolatileLong(writeUpToOffset);
}

Fixed version (ground truth):
/** 
 * @return the point at which you should not write any additional bits
 */
private long getWriteUpTo(){
  return writeUpToOffsetAtomic.get();
}
Program: 52231
Project: 52231
Buggy source:
private void setReadLocation(long value){
  bytesStore.writeOrderedLong(readLocationOffset,value);
}

Fixed version (ground truth):
private void setReadLocation(long value){
  readLocationOffsetAtomic.set(value);
}
Program: 52232
Project: 52232
Buggy source:
public void clear(long size){
  setWriteUpTo(size);
  setReadLocation(0);
  bytesStore.writeOrderedLong(writeLocationOffset,0);
}

Fixed version (ground truth):
public synchronized void clear(long size){
  writeLocationOffsetAtomic.set(0);
  readLocationOffsetAtomic.set(0);
  writeUpToOffsetAtomic.set(size);
}
Program: 52233
Project: 52233
Buggy source:
public BytesRingBuffer(@NotNull final BytesStore byteStore){
  capacity=byteStore.writeLimit();
  if (byteStore.writeRemaining() <= 24) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
  }
  this.header=new Header(byteStore,capacity - 24);
  this.bytes=new RingBuffer(byteStore,0,capacity - 24);
  this.header.setWriteUpTo(capacity);
}

Fixed version (ground truth):
public BytesRingBuffer(@NotNull final BytesStore byteStore){
  capacity=byteStore.writeLimit() - 24;
  if (byteStore.writeRemaining() <= 24) {
    throw new IllegalStateException("String_Node_Str" + "String_Node_Str");
  }
  this.header=new Header(byteStore,byteStore.writeLimit());
  this.bytes=new RingBuffer(byteStore,0,capacity);
  this.header.setWriteUpTo(capacity);
  byteStore.writeLong(0,0);
}
Program: 52234
Project: 52234
Buggy source:
private Consumer(){
  this.input=new byte[]{};
  this.inputBuffer=wrap(ByteBuffer.wrap(input));
}

Fixed version (ground truth):
private Consumer(){
  this.input=new byte[]{};
  this.inputBuffer=wrap(ByteBuffer.wrap(input)).bytesForRead();
}
Program: 52235
Project: 52235
Buggy source:
@NotNull @Override public Bytes provide(final long maxSize){
  if (maxSize < inputBuffer.capacity())   return inputBuffer.clear();
  if (maxSize > Integer.MAX_VALUE) {
    throw new IllegalStateException(ERR_MSG);
  }
  this.input=new byte[(int)maxSize];
  this.inputBuffer=wrap(ByteBuffer.wrap(input));
  this.output=new byte[(int)maxSize];
  this.outputBuffer=wrap(ByteBuffer.wrap(output));
  return inputBuffer;
}

Fixed version (ground truth):
@NotNull @Override public Bytes provide(final long maxSize){
  if (maxSize < inputBuffer.capacity())   return inputBuffer.clear();
  if (maxSize > Integer.MAX_VALUE) {
    throw new IllegalStateException(ERR_MSG);
  }
  this.input=new byte[(int)maxSize];
  this.inputBuffer=wrap(ByteBuffer.wrap(input)).bytesForRead();
  this.output=new byte[(int)maxSize];
  this.outputBuffer=wrap(ByteBuffer.wrap(output)).bytesForWrite();
  return inputBuffer;
}
Program: 52236
Project: 52236
Buggy source:
@Test public void testFormat(){
  VanillaDateCache dc=new VanillaDateCache("String_Node_Str",86400000);
  String str=dc.formatFor(16067);
  assertEquals("String_Node_Str",str);
  String str1=dc.formatFor(1);
  assertEquals("String_Node_Str",str1);
}

Fixed version (ground truth):
@Test public void testFormat(){
  VanillaDateCache dc=new VanillaDateCache("String_Node_Str",86400000,GMT);
  String str=dc.formatFor(16067);
  assertEquals("String_Node_Str",str);
  String str1=dc.formatFor(1);
  assertEquals("String_Node_Str",str1);
}
Program: 52237
Project: 52237
Buggy source:
@Test public void testFormatMillis(){
  String format="String_Node_Str";
  SimpleDateFormat sdf=new SimpleDateFormat(format);
  sdf.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
  VanillaDateCache dc=new VanillaDateCache(format,1000);
  int now=(int)(System.currentTimeMillis() / 1000);
  for (int i=0; i < 10000; i++) {
    int now2=now + i;
    String str2=sdf.format(new Date(now2 * 1000L));
    String str=dc.formatFor(now2);
    assertEquals("String_Node_Str" + i,str2,str);
  }
}

Fixed version (ground truth):
@Test public void testFormatMillis(){
  String format="String_Node_Str";
  SimpleDateFormat sdf=new SimpleDateFormat(format);
  sdf.setTimeZone(TimeZone.getTimeZone("String_Node_Str"));
  VanillaDateCache dc=new VanillaDateCache(format,1000,GMT);
  int now=(int)(System.currentTimeMillis() / 1000);
  for (int i=0; i < 10000; i++) {
    int now2=now + i;
    String str2=sdf.format(new Date(now2 * 1000L));
    String str=dc.formatFor(now2);
    assertEquals("String_Node_Str" + i,str2,str);
  }
}
Program: 52238
Project: 52238
Buggy source:
@Test(timeout=31000) public void testDataCacheTimeout() throws IOException {
  final String baseDir=getTestPath();
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(10000).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 7);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    for (int j=0; j < 5; j++) {
      int runs=2000;
      for (int i=0; i < runs; i++) {
        VanillaMappedBytes buffer=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),i,true);
        File file=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),i,true);
        buffer.release();
        buffer.release();
        buffer.close();
        assertTrue(file.delete());
      }
    }
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test(timeout=31000) public void testDataCacheTimeout() throws IOException {
  final String baseDir=getTestPath();
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(10000).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 7);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    for (int j=0; j < 5; j++) {
      int runs=2000;
      for (int i=0; i < runs; i++) {
        VanillaMappedBytes buffer=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),i,true);
        File file=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),i,true);
        buffer.release();
        buffer.release();
        buffer.close();
        assertTrue(file.delete());
      }
    }
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}
Program: 52240
Project: 52240
Buggy source:
@Test public void testDataForPerf() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 7);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    File file=null;
    VanillaMappedBytes buffer=null;
    for (int j=0; j < 5; j++) {
      long start=System.nanoTime();
      int runs=10000;
      for (int i=0; i < runs; i++) {
        buffer=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),i,true);
        buffer.writeLong(0,0x12345678);
        file=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),i,true);
        assertEquals(128 << 10,file.length());
        assertEquals(0x12345678L,buffer.readLong(0));
        buffer.release();
        buffer.release();
        buffer.close();
        assertTrue(file.delete());
      }
      long time=System.nanoTime() - start;
      System.out.printf("String_Node_Str",time / runs / 1000);
      dataCache.checkCounts(0,0);
    }
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test public void testDataForPerf() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
  final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 7);
  try {
    int cycle=(int)(System.currentTimeMillis() / 1000);
    File file=null;
    VanillaMappedBytes buffer=null;
    for (int j=0; j < 5; j++) {
      long start=System.nanoTime();
      int runs=10000;
      for (int i=0; i < runs; i++) {
        buffer=dataCache.dataFor(cycle,AffinitySupport.getThreadId(),i,true);
        buffer.writeLong(0,0x12345678);
        file=dataCache.fileFor(cycle,AffinitySupport.getThreadId(),i,true);
        assertEquals(128 << 10,file.length());
        assertEquals(0x12345678L,buffer.readLong(0));
        buffer.release();
        buffer.release();
        buffer.close();
        assertTrue(file.delete());
      }
      long time=System.nanoTime() - start;
      System.out.printf("String_Node_Str",time / runs / 1000);
      dataCache.checkCounts(0,0);
    }
  }
  finally {
    dataCache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}
Program: 52241
Project: 52241
Buggy source:
@Test public void testFindNextDataCount() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  try {
    final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
    final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
    final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 6);
    int cycle=(int)(System.currentTimeMillis() / 1000);
    final int threadId=AffinitySupport.getThreadId();
    assertEquals(0,dataCache.findNextDataCount(cycle,threadId));
    VanillaMappedBytes vanillaBuffer1=dataCache.dataFor(cycle,threadId,1,true);
    vanillaBuffer1.release();
    VanillaMappedBytes vanillaBuffer2=dataCache.dataFor(cycle,threadId,2,true);
    vanillaBuffer2.release();
    VanillaMappedBytes vanillaBuffer4=dataCache.dataFor(cycle,threadId,4,true);
    vanillaBuffer4.release();
    dataCache.checkCounts(1,1);
    dataCache.close();
    final VanillaDataCache dataCache2=new VanillaDataCache(builder,dateCache,10 + 6);
    assertEquals(5,dataCache2.findNextDataCount(cycle,threadId));
    dataCache.checkCounts(1,1);
    dataCache2.close();
  }
  finally {
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test public void testFindNextDataCount() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  try {
    final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).dataCacheCapacity(32).cleanupOnClose(false);
    final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
    final VanillaDataCache dataCache=new VanillaDataCache(builder,dateCache,10 + 6);
    int cycle=(int)(System.currentTimeMillis() / 1000);
    final int threadId=AffinitySupport.getThreadId();
    assertEquals(0,dataCache.findNextDataCount(cycle,threadId));
    VanillaMappedBytes vanillaBuffer1=dataCache.dataFor(cycle,threadId,1,true);
    vanillaBuffer1.release();
    VanillaMappedBytes vanillaBuffer2=dataCache.dataFor(cycle,threadId,2,true);
    vanillaBuffer2.release();
    VanillaMappedBytes vanillaBuffer4=dataCache.dataFor(cycle,threadId,4,true);
    vanillaBuffer4.release();
    dataCache.checkCounts(1,1);
    dataCache.close();
    final VanillaDataCache dataCache2=new VanillaDataCache(builder,dateCache,10 + 6);
    assertEquals(5,dataCache2.findNextDataCount(cycle,threadId));
    dataCache.checkCounts(1,1);
    dataCache2.close();
  }
  finally {
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}
Program: 52243
Project: 52243
Buggy source:
@Test public void testConcurrentAppend() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).indexCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
  final VanillaIndexCache cache=new VanillaIndexCache(builder,dateCache,5,FileLifecycleListener.FileLifecycleListeners.CONSOLE);
  final int cycle=(int)(System.currentTimeMillis() / 1000);
  final int numberOfTasks=2;
  final int countPerTask=1000;
  try {
    final List<Callable<Void>> tasks=new ArrayList<>();
    long nextValue=countPerTask;
    for (int i=0; i < numberOfTasks; i++) {
      final long endValue=nextValue + countPerTask;
      tasks.add(createAppendTask(cache,cycle,nextValue,endValue));
      nextValue=endValue;
    }
    TestTaskExecutionUtil.executeConcurrentTasks(tasks,30000L);
    final Set<Long> indexValues=readAllIndexValues(cache,cycle);
    final Set<Long> rangeSet=createRangeSet(countPerTask,nextValue);
    assertEquals(rangeSet,indexValues);
    cache.checkCounts(1,1);
  }
  finally {
    cache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test public void testConcurrentAppend() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).indexCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
  final VanillaIndexCache cache=new VanillaIndexCache(builder,dateCache,5,FileLifecycleListener.FileLifecycleListeners.CONSOLE);
  final int cycle=(int)(System.currentTimeMillis() / 1000);
  final int numberOfTasks=2;
  final int countPerTask=1000;
  try {
    final List<Callable<Void>> tasks=new ArrayList<>();
    long nextValue=countPerTask;
    for (int i=0; i < numberOfTasks; i++) {
      final long endValue=nextValue + countPerTask;
      tasks.add(createAppendTask(cache,cycle,nextValue,endValue));
      nextValue=endValue;
    }
    TestTaskExecutionUtil.executeConcurrentTasks(tasks,30000L);
    final Set<Long> indexValues=readAllIndexValues(cache,cycle);
    final Set<Long> rangeSet=createRangeSet(countPerTask,nextValue);
    assertEquals(rangeSet,indexValues);
    cache.checkCounts(1,1);
  }
  finally {
    cache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}
Program: 52244
Project: 52244
Buggy source:
@Test public void testLastIndexFile() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).indexCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000);
  final VanillaIndexCache cache=new VanillaIndexCache(builder,dateCache,10 + 3,FileLifecycleListener.FileLifecycleListeners.CONSOLE);
  final int cycle=(int)(System.currentTimeMillis() / 1000);
  try {
    assertEquals(0,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer0=cache.indexFor(cycle,0,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,0,dateCache).getName());
    vanillaBuffer0.release();
    assertEquals(0,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer1=cache.indexFor(cycle,1,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,1,dateCache).getName());
    vanillaBuffer1.release();
    assertEquals(1,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer3=cache.indexFor(cycle,3,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,3,dateCache).getName());
    vanillaBuffer3.release();
    assertEquals(3,cache.lastIndexFile(cycle));
    cache.checkCounts(1,1);
  }
  finally {
    cache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}

Fixed version (ground truth):
@Test public void testLastIndexFile() throws IOException {
  final String baseDir=getTestPath();
  assertNotNull(baseDir);
  final ChronicleQueueBuilder.VanillaChronicleQueueBuilder builder=ChronicleQueueBuilder.vanilla(baseDir).indexCacheCapacity(32).cleanupOnClose(false);
  final VanillaDateCache dateCache=new VanillaDateCache("String_Node_Str",1000,GMT);
  final VanillaIndexCache cache=new VanillaIndexCache(builder,dateCache,10 + 3,FileLifecycleListener.FileLifecycleListeners.CONSOLE);
  final int cycle=(int)(System.currentTimeMillis() / 1000);
  try {
    assertEquals(0,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer0=cache.indexFor(cycle,0,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,0,dateCache).getName());
    vanillaBuffer0.release();
    assertEquals(0,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer1=cache.indexFor(cycle,1,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,1,dateCache).getName());
    vanillaBuffer1.release();
    assertEquals(1,cache.lastIndexFile(cycle));
    final VanillaMappedBytes vanillaBuffer3=cache.indexFor(cycle,3,true);
    assertEquals("String_Node_Str",VanillaChronicleUtils.fileFor(baseDir,cycle,3,dateCache).getName());
    vanillaBuffer3.release();
    assertEquals(3,cache.lastIndexFile(cycle));
    cache.checkCounts(1,1);
  }
  finally {
    cache.close();
    IOTools.deleteDir(baseDir);
    assertFalse(new File(baseDir).exists());
  }
}
Program: 52245
Project: 52245
Buggy source:
protected synchronized ExcerptCommon createAppender0() throws IOException {
  if (this.excerpt != null) {
    throw new IllegalStateException("String_Node_Str");
  }
  return this.excerpt=new StatelessExcerpAppender();
}

Fixed version (ground truth):
protected synchronized ExcerptCommon createAppender0() throws IOException {
  if (this.excerpt != null) {
    throw new IllegalStateException("String_Node_Str");
  }
  return this.excerpt=new StatelessExcerptAppender();
}
Program: 52246
Project: 52246
Buggy source:
@Override public void finish(){
  if (!isFinished()) {
    if (!connection.isOpen()) {
      openConnection();
    }
    try {
      connection.writeAction(commandBuffer,actionType,position());
      connection.writeAllOrEOF(wrapped.buffer());
      if (builder.appendRequireAck()) {
        connection.readUpTo(readBuffer,ChronicleTcp.HEADER_SIZE,-1);
        int recType=readBuffer.getInt();
        long recIndex=readBuffer.getLong();
switch (recType) {
case ChronicleTcp.ACK_LEN:
          this.lastIndex=recIndex;
        break;
case ChronicleTcp.NACK_LEN:
      throw new IllegalStateException("String_Node_Str" + (recIndex == ChronicleTcp.IDX_NOT_SUPPORTED ? "String_Node_Str" : "String_Node_Str"));
default :
    logger.warn("String_Node_Str",recType,recIndex);
}
}
}
 catch (IOException e) {
LOGGER.trace("String_Node_Str",e);
throw new IllegalStateException(e);
}
}
super.finish();
}

Fixed version (ground truth):
@Override public void finish(){
  if (!isFinished()) {
    if (!connection.isOpen()) {
      openConnection();
    }
    try {
      connection.writeAction(commandBuffer,actionType,position());
      ByteBuffer buffer=wrapped.buffer();
      buffer.limit((int)wrapped.position());
      connection.writeAllOrEOF(buffer);
      if (builder.appendRequireAck()) {
        connection.readUpTo(readBuffer,ChronicleTcp.HEADER_SIZE,-1);
        int recType=readBuffer.getInt();
        long recIndex=readBuffer.getLong();
switch (recType) {
case ChronicleTcp.ACK_LEN:
          this.lastIndex=recIndex;
        break;
case ChronicleTcp.NACK_LEN:
      throw new IllegalStateException("String_Node_Str" + (recIndex == ChronicleTcp.IDX_NOT_SUPPORTED ? "String_Node_Str" : "String_Node_Str"));
default :
    logger.warn("String_Node_Str",recType,recIndex);
}
}
}
 catch (IOException e) {
LOGGER.trace("String_Node_Str",e);
throw new IllegalStateException(e);
}
}
super.finish();
}
Program: 52247
Project: 52247
Buggy source:
@Override public long appendDocument(@NotNull Bytes buffer){
  long length=buffer.remaining();
  if (length > MAX_LENGTH)   throw new IllegalStateException("String_Node_Str" + length);
  LongValue writeByte=header.writeByte;
  long lastByte=writeByte.getVolatileValue();
  for (; ; ) {
    if (bytes.compareAndSwapInt(lastByte,0,NOT_READY | (int)length)) {
      long lastByte2=lastByte + 4 + buffer.remaining();
      bytes.write(lastByte + 4,buffer);
      long lastIndex=header.lastIndex.addAtomicValue(1);
      writeByte.setOrderedValue(lastByte2);
      bytes.writeOrderedInt(lastByte,(int)length);
      return lastIndex;
    }
    int length2=length30(bytes.readVolatileInt());
    bytes.skip(length2);
    Jvm.checkInterrupted();
  }
}

Fixed version (ground truth):
@Override public long appendDocument(@NotNull Bytes buffer){
  long length=buffer.remaining();
  if (length > MAX_LENGTH)   throw new IllegalStateException("String_Node_Str" + length);
  LongValue writeByte=header.writeByte();
  long lastByte=writeByte.getVolatileValue();
  for (; ; ) {
    if (bytes.compareAndSwapInt(lastByte,0,NOT_READY | (int)length)) {
      long lastByte2=lastByte + 4 + buffer.remaining();
      bytes.write(lastByte + 4,buffer);
      long lastIndex=header.lastIndex().addAtomicValue(1);
      writeByte.setOrderedValue(lastByte2);
      bytes.writeOrderedInt(lastByte,(int)length);
      return lastIndex;
    }
    int length2=length30(bytes.readVolatileInt());
    bytes.skip(length2);
    try {
      Jvm.checkInterrupted();
    }
 catch (    InterruptedException e) {
      throw new InterruptedRuntimeException(e);
    }
  }
}
Program: 52248
Project: 52248
Buggy source:
private void readHeader() throws IOException {
  waitForTheHeaderToBeBuilt(bytes);
  bytes.position(HEADER_OFFSET);
  wire.readDocument($ -> wire.read().marshallable(header),null);
  firstBytes=bytes.position();
}

Fixed version (ground truth):
private void readHeader() throws IOException {
  waitForTheHeaderToBeBuilt(bytes);
  bytes.position(HEADER_OFFSET);
  Consumer<WireIn> nullConsumer=o -> {
  }
;
  Consumer<WireIn> dataConsumer=$ -> {
    wire.read().marshallable(header);
  }
;
  wire.readDocument(dataConsumer,nullConsumer);
  firstBytes=bytes.position();
}
Program: 52250
Project: 52250
Buggy source:
@Override public long lastIndex(){
  long value=header.lastIndex.getVolatileValue();
  if (value == -1)   throw new IllegalStateException("String_Node_Str");
  return value;
}

Fixed version (ground truth):
@Override public long lastIndex(){
  long value=header.lastIndex().getVolatileValue();
  if (value == -1)   throw new IllegalStateException("String_Node_Str");
  return value;
}
Program: 52251
Project: 52251
Buggy source:
/** 
 * @return gets the index2index, or creates it, if it does not exist.
 */
long indexToIndex(){
  for (; ; ) {
    long index2Index=header.index2Index.getVolatileValue();
    if (index2Index == NOT_READY)     continue;
    if (index2Index != UNINITIALISED)     return index2Index;
    if (!header.index2Index.compareAndSwapValue(UNINITIALISED,NOT_READY))     continue;
    long indexToIndex=newIndex();
    header.index2Index.setOrderedValue(indexToIndex);
    return indexToIndex;
  }
}

Fixed version (ground truth):
/** 
 * @return gets the index2index, or creates it, if it does not exist.
 */
long indexToIndex(){
  for (; ; ) {
    long index2Index=header.index2Index().getVolatileValue();
    if (index2Index == NOT_READY)     continue;
    if (index2Index != UNINITIALISED)     return index2Index;
    if (!header.index2Index().compareAndSwapValue(UNINITIALISED,NOT_READY))     continue;
    long indexToIndex=newIndex();
    header.index2Index().setOrderedValue(indexToIndex);
    return indexToIndex;
  }
}
Program: 52253
Project: 52253
Buggy source:
@Override public boolean readDocument(Consumer<WireIn> reader){
  wire.readDocument(null,reader);
  return true;
}

Fixed version (ground truth):
@Override public boolean readDocument(Consumer<WireIn> reader){
  Consumer<WireIn> metaDataConsumer=new Consumer<WireIn>(){
    @Override public void accept(    WireIn wireIn){
    }
  }
;
  wire.readDocument(metaDataConsumer,reader);
  return true;
}
Program: 52254
Project: 52254
Buggy source:
private boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  return buffer.compareAndSwapLong(writeLocationOffset,expectedValue,newValue);
}

Fixed version (ground truth):
private synchronized boolean compareAndSetWriteLocation(long expectedValue,long newValue){
  return writeLocationAtomic.compareAndSet(expectedValue,newValue);
}
Program: 52255
Project: 52255
Buggy source:
/** 
 * Inserts the specified element at the tail of this queue if it is possible to do so immediately without exceeding the queue's capacity,
 * @param bytes the {@code bytes} that you wish to add to the ring buffer
 * @return returning {@code true} upon success and {@code false} if this queue is full.
 */
public boolean offer(@NotNull Bytes bytes) throws InterruptedException {
  try {
    for (; ; ) {
      long writeLocation=this.writeLocation();
      if (Thread.currentThread().isInterrupted())       throw new InterruptedException();
      if (remainingForWrite(writeLocation) < bytes.remaining() + SIZE + FLAG)       return false;
      long len=bytes.remaining();
      long messageLen=SIZE + FLAG + len;
      long offset=writeLocation;
      if (!header.compareAndSetWriteLocation(writeLocation,LOCKED))       continue;
      long flagLoc=offset;
      offset=this.bytes.writeByte(offset,States.BUSY.ordinal());
      if (!header.compareAndSetWriteLocation(-1,writeLocation + messageLen))       continue;
      offset=this.bytes.write(offset,len);
      this.bytes.write(offset,bytes);
      this.bytes.writeByte(flagLoc,States.READY.ordinal());
      return true;
    }
  }
 catch (  IllegalStateException e) {
    return false;
  }
}

Fixed version (ground truth):
/** 
 * Inserts the specified element at the tail of this queue if it is possible to do so immediately without exceeding the queue's capacity,
 * @param bytes the {@code bytes} that you wish to add to the ring buffer
 * @return returning {@code true} upon success and {@code false} if this queue is full.
 */
public boolean offer(@NotNull Bytes bytes) throws InterruptedException {
}
Program: 52256
Project: 52256
Buggy source:
/** 
 * sets the point at which you should not write any additional bits
 */
private void setWriteUpTo(long value){
  buffer.writeOrderedLong(writeUpToOffset,value);
}

Fixed version (ground truth):
/** 
 * sets the point at which you should not write any additional bits
 */
private void setWriteUpTo(long value){
  writeUpToOffsetAtomic.set(value);
}
Program: 52257
Project: 52257
Buggy source:
private long getWriteLocation(){
  return buffer.readVolatileLong(writeLocationOffset);
}

Fixed version (ground truth):
private synchronized long getWriteLocation(){
  return writeLocationAtomic.get();
}
Program: 52258
Project: 52258
Buggy source:
private long getReadLocation(){
  return buffer.readVolatileLong(readLocationOffset);
}

Fixed version (ground truth):
private long getReadLocation(){
  return readLocationAtomic.get();
}
Program: 52259
Project: 52259
Buggy source:
/** 
 * @return the point at which you should not write any additional bits
 */
private long getWriteUpTo(){
  return buffer.readVolatileLong(writeUpToOffset);
}

Fixed version (ground truth):
/** 
 * @return the point at which you should not write any additional bits
 */
private long getWriteUpTo(){
  return writeUpToOffsetAtomic.get();
}