nus-yam/ex-repair huggingface dataset:
Program: 41770
Project: 41770
Buggy source:
/** 
 * Called to free all Connection resources.
 */
protected void shutdown() throws JMSException {
  for (  JmsSession session : this.sessions) {
    session.shutdown();
  }
  if (isConnected() && !failed.get() && !closing.get()) {
    destroyResource(connectionInfo);
  }
  if (clientIdSet) {
    connectionInfo.setClientId(null);
    clientIdSet=false;
  }
  tempDestinations.clear();
  started.set(false);
  connected.set(false);
}

Fixed version (ground truth):
/** 
 * Called to free all Connection resources.
 */
protected void shutdown() throws JMSException {
  for (  JmsSession session : this.sessions) {
    session.shutdown();
  }
  if (isConnected() && !failed.get() && !closing.get()) {
    destroyResource(connectionInfo);
  }
synchronized (this) {
    if (clientIdSet) {
      connectionInfo.setClientId(null);
      clientIdSet=false;
    }
  }
  tempDestinations.clear();
  started.set(false);
  connected.set(false);
}
Program: 41771
Project: 41771
Buggy source:
@Override public byte[] getBytes(String name) throws JMSException {
  Object value=getObject(name);
  if (value == null) {
    return (byte[])value;
  }
 else   if (value instanceof byte[]) {
    byte[] original=(byte[])value;
    byte[] clone=new byte[original.length];
    System.arraycopy(original,0,clone,0,original.length);
    return clone;
  }
 else {
    throw new MessageFormatException("String_Node_Str" + value.getClass().getSimpleName());
  }
}

Fixed version (ground truth):
@Override public byte[] getBytes(String name) throws JMSException {
  Object value=getObject(name);
  if (value == null) {
    return null;
  }
 else   if (value instanceof byte[]) {
    byte[] original=(byte[])value;
    byte[] clone=new byte[original.length];
    System.arraycopy(original,0,clone,0,original.length);
    return clone;
  }
 else {
    throw new MessageFormatException("String_Node_Str" + value.getClass().getSimpleName());
  }
}
Program: 41772
Project: 41772
Buggy source:
@Override protected void doOpen(){
  JmsDestination destination=info.getDestination();
  String destnationName=session.getQualifiedName(destination);
  String sourceAddress=getProducerId().toString();
  Source source=new Source();
  source.setAddress(sourceAddress);
  Target target=new Target();
  target.setAddress(destnationName);
  String senderName=sourceAddress + "String_Node_Str" + destnationName != null ? destnationName : "String_Node_Str";
  endpoint=session.getProtonSession().sender(senderName);
  endpoint.setSource(source);
  endpoint.setTarget(target);
  if (presettle) {
    endpoint.setSenderSettleMode(SenderSettleMode.SETTLED);
  }
 else {
    endpoint.setSenderSettleMode(SenderSettleMode.UNSETTLED);
  }
  endpoint.setReceiverSettleMode(ReceiverSettleMode.FIRST);
}

Fixed version (ground truth):
@Override protected void doOpen(){
  JmsDestination destination=info.getDestination();
  String destnationName=session.getQualifiedName(destination);
  String sourceAddress=getProducerId().toString();
  Source source=new Source();
  source.setAddress(sourceAddress);
  Target target=new Target();
  target.setAddress(destnationName);
  String senderName=sourceAddress + "String_Node_Str" + destnationName;
  endpoint=session.getProtonSession().sender(senderName);
  endpoint.setSource(source);
  endpoint.setTarget(target);
  if (presettle) {
    endpoint.setSenderSettleMode(SenderSettleMode.SETTLED);
  }
 else {
    endpoint.setSenderSettleMode(SenderSettleMode.UNSETTLED);
  }
  endpoint.setReceiverSettleMode(ReceiverSettleMode.FIRST);
}
Program: 41773
Project: 41773
Buggy source:
private Binary getBinaryFromBody(){
  Section body=getAmqpMessage().getBody();
  Binary result=null;
  if (body == null) {
    return result;
  }
  if (body instanceof Data) {
    Binary payload=((Data)body).getValue();
    if (payload != null && payload.getLength() != 0) {
      result=payload;
    }
  }
 else   if (body instanceof AmqpValue) {
    Object value=((AmqpValue)body).getValue();
    if (value == null) {
      return result;
    }
    if (value instanceof Binary) {
      Binary payload=(Binary)value;
      if (payload != null && payload.getLength() != 0) {
        result=payload;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value.getClass().getSimpleName());
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + body.getClass().getSimpleName());
  }
  return result;
}

Fixed version (ground truth):
private Binary getBinaryFromBody(){
  Section body=getAmqpMessage().getBody();
  Binary result=null;
  if (body == null) {
    return result;
  }
  if (body instanceof Data) {
    Binary payload=((Data)body).getValue();
    if (payload != null && payload.getLength() != 0) {
      result=payload;
    }
  }
 else   if (body instanceof AmqpValue) {
    Object value=((AmqpValue)body).getValue();
    if (value == null) {
      return result;
    }
    if (value instanceof Binary) {
      Binary payload=(Binary)value;
      if (payload.getLength() != 0) {
        result=payload;
      }
    }
 else {
      throw new IllegalStateException("String_Node_Str" + value.getClass().getSimpleName());
    }
  }
 else {
    throw new IllegalStateException("String_Node_Str" + body.getClass().getSimpleName());
  }
  return result;
}
Program: 41774
Project: 41774
Buggy source:
@Override public void setCorrelationId(String correlationId){
  AmqpMessageIdHelper messageIdHelper=AmqpMessageIdHelper.INSTANCE;
  if (correlationId == null) {
    message.setCorrelationId(null);
  }
 else {
    boolean appSpecific=false;
    boolean hasMessageIdPrefix=messageIdHelper.hasMessageIdPrefix(correlationId);
    if (correlationId != null && !hasMessageIdPrefix) {
      appSpecific=true;
    }
    String stripped=messageIdHelper.stripMessageIdPrefix(correlationId);
    if (hasMessageIdPrefix) {
      try {
        Object idObject=messageIdHelper.toIdObject(stripped);
        message.setCorrelationId(idObject);
      }
 catch (      IdConversionException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      message.setCorrelationId(stripped);
    }
    if (appSpecific) {
      setAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID,true);
    }
 else {
      removeAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID);
    }
  }
}

Fixed version (ground truth):
@Override public void setCorrelationId(String correlationId){
  AmqpMessageIdHelper messageIdHelper=AmqpMessageIdHelper.INSTANCE;
  if (correlationId == null) {
    message.setCorrelationId(null);
  }
 else {
    boolean appSpecific=false;
    boolean hasMessageIdPrefix=messageIdHelper.hasMessageIdPrefix(correlationId);
    if (!hasMessageIdPrefix) {
      appSpecific=true;
    }
    String stripped=messageIdHelper.stripMessageIdPrefix(correlationId);
    if (hasMessageIdPrefix) {
      try {
        Object idObject=messageIdHelper.toIdObject(stripped);
        message.setCorrelationId(idObject);
      }
 catch (      IdConversionException e) {
        throw new RuntimeException(e);
      }
    }
 else {
      message.setCorrelationId(stripped);
    }
    if (appSpecific) {
      setAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID,true);
    }
 else {
      removeAnnotation(AmqpMessageSupport.JMS_APP_CORRELATION_ID);
    }
  }
}
Program: 41775
Project: 41775
Buggy source:
/** 
 * Given a key / value mapping, create and return a URI formatted query string that is valid and can be appended to a URI.
 * @param options The Mapping that will create the new Query string.
 * @return a URI formatted query string.
 * @throws URISyntaxException
 */
public static String createQueryString(Map<String,? extends Object> options) throws URISyntaxException {
  try {
    if (options.size() > 0) {
      StringBuffer rc=new StringBuffer();
      boolean first=true;
      for (      String key : options.keySet()) {
        if (first) {
          first=false;
        }
 else {
          rc.append("String_Node_Str");
        }
        String value=(String)options.get(key);
        rc.append(URLEncoder.encode(key,"String_Node_Str"));
        rc.append("String_Node_Str");
        rc.append(URLEncoder.encode(value,"String_Node_Str"));
      }
      return rc.toString();
    }
 else {
      return "String_Node_Str";
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw (URISyntaxException)new URISyntaxException(e.toString(),"String_Node_Str").initCause(e);
  }
}

Fixed version (ground truth):
/** 
 * Given a key / value mapping, create and return a URI formatted query string that is valid and can be appended to a URI.
 * @param options The Mapping that will create the new Query string.
 * @return a URI formatted query string.
 * @throws URISyntaxException
 */
public static String createQueryString(Map<String,? extends Object> options) throws URISyntaxException {
  try {
    if (options.size() > 0) {
      StringBuffer rc=new StringBuffer();
      boolean first=true;
      for (      Entry<String,? extends Object> entry : options.entrySet()) {
        if (first) {
          first=false;
        }
 else {
          rc.append("String_Node_Str");
        }
        rc.append(URLEncoder.encode(entry.getKey(),"String_Node_Str"));
        rc.append("String_Node_Str");
        rc.append(URLEncoder.encode((String)entry.getValue(),"String_Node_Str"));
      }
      return rc.toString();
    }
 else {
      return "String_Node_Str";
    }
  }
 catch (  UnsupportedEncodingException e) {
    throw (URISyntaxException)new URISyntaxException(e.toString(),"String_Node_Str").initCause(e);
  }
}
Program: 41776
Project: 41776
Buggy source:
/** 
 * Given a map of properties, filter out only those prefixed with the given value, the values filtered are returned in a new Map instance.
 * @param properties The map of properties to filter.
 * @param optionPrefix The prefix value to use when filtering.
 * @return a filter map with only values that match the given prefix.
 */
public static Map<String,String> filterProperties(Map<String,String> props,String optionPrefix){
  if (props == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashMap<String,String> rc=new HashMap<String,String>(props.size());
  for (Iterator<String> iter=props.keySet().iterator(); iter.hasNext(); ) {
    String name=iter.next();
    if (name.startsWith(optionPrefix)) {
      String value=props.get(name);
      name=name.substring(optionPrefix.length());
      rc.put(name,value);
      iter.remove();
    }
  }
  return rc;
}

Fixed version (ground truth):
/** 
 * Given a map of properties, filter out only those prefixed with the given value, the values filtered are returned in a new Map instance.
 * @param properties The map of properties to filter.
 * @param optionPrefix The prefix value to use when filtering.
 * @return a filter map with only values that match the given prefix.
 */
public static Map<String,String> filterProperties(Map<String,String> props,String optionPrefix){
  if (props == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  HashMap<String,String> rc=new HashMap<String,String>(props.size());
  for (Iterator<Entry<String,String>> iter=props.entrySet().iterator(); iter.hasNext(); ) {
    Entry<String,String> entry=iter.next();
    if (entry.getKey().startsWith(optionPrefix)) {
      String name=entry.getKey().substring(optionPrefix.length());
      rc.put(name,entry.getValue());
      iter.remove();
    }
  }
  return rc;
}
Program: 41777
Project: 41777
Buggy source:
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String toString(Object target,Class stopClass,Map<String,Object> overrideFields){
  LinkedHashMap<String,Object> map=new LinkedHashMap<String,Object>();
  addFields(target,target.getClass(),stopClass,map);
  if (overrideFields != null) {
    for (    String key : overrideFields.keySet()) {
      Object value=overrideFields.get(key);
      map.put(key,value);
    }
  }
  StringBuffer buffer=new StringBuffer(simpleName(target.getClass()));
  buffer.append("String_Node_Str");
  Set<Entry<String,Object>> entrySet=map.entrySet();
  boolean first=true;
  for (  Map.Entry<String,Object> entry : entrySet) {
    Object value=entry.getValue();
    Object key=entry.getKey();
    if (first) {
      first=false;
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append(key);
    buffer.append("String_Node_Str");
    appendToString(buffer,key,value);
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}

Fixed version (ground truth):
@SuppressWarnings({"String_Node_Str","String_Node_Str"}) public static String toString(Object target,Class stopClass,Map<String,Object> overrideFields){
  LinkedHashMap<String,Object> map=new LinkedHashMap<String,Object>();
  addFields(target,target.getClass(),stopClass,map);
  if (overrideFields != null) {
    for (    Entry<String,Object> entry : overrideFields.entrySet()) {
      map.put(entry.getKey(),entry.getValue());
    }
  }
  StringBuffer buffer=new StringBuffer(simpleName(target.getClass()));
  buffer.append("String_Node_Str");
  Set<Entry<String,Object>> entrySet=map.entrySet();
  boolean first=true;
  for (  Map.Entry<String,Object> entry : entrySet) {
    Object value=entry.getValue();
    Object key=entry.getKey();
    if (first) {
      first=false;
    }
 else {
      buffer.append("String_Node_Str");
    }
    buffer.append(key);
    buffer.append("String_Node_Str");
    appendToString(buffer,key,value);
  }
  buffer.append("String_Node_Str");
  return buffer.toString();
}
Program: 41778
Project: 41778
Buggy source:
/** 
 * Creates a new Facade around an incoming AMQP Message for dispatch to the JMS Consumer instance.
 * @param consumer the consumer that received this message.
 * @param message the incoming Message instance that is being wrapped.
 */
@SuppressWarnings("String_Node_Str") public AmqpJmsMessageFacade(AmqpConsumer consumer,Message message){
  this.message=message;
  this.connection=consumer.getConnection();
  this.consumerDestination=consumer.getDestination();
  annotations=message.getMessageAnnotations();
  if (annotations != null) {
    annotationsMap=annotations.getValue();
  }
  if (message.getApplicationProperties() != null) {
    applicationPropertiesMap=message.getApplicationProperties().getValue();
  }
  Long ttl=message.getTtl();
  Long absoluteExpiryTime=getAbsoluteExpiryTime();
  if (absoluteExpiryTime == null && ttl != null) {
    syntheticExpiration=System.currentTimeMillis() + ttl;
  }
}

Fixed version (ground truth):
/** 
 * Creates a new Facade around an incoming AMQP Message for dispatch to the JMS Consumer instance.
 * @param consumer the consumer that received this message.
 * @param message the incoming Message instance that is being wrapped.
 */
@SuppressWarnings("String_Node_Str") public AmqpJmsMessageFacade(AmqpConsumer consumer,Message message){
  this.message=message;
  this.connection=consumer.getConnection();
  this.consumerDestination=consumer.getDestination();
  annotations=message.getMessageAnnotations();
  if (annotations != null) {
    annotationsMap=annotations.getValue();
  }
  if (message.getApplicationProperties() != null) {
    applicationPropertiesMap=message.getApplicationProperties().getValue();
  }
  Long ttl=getTtl();
  Long absoluteExpiryTime=getAbsoluteExpiryTime();
  if (absoluteExpiryTime == null && ttl != null) {
    syntheticExpiration=System.currentTimeMillis() + ttl;
  }
}
Program: 41780
Project: 41780
Buggy source:
/** 
 * Searches for a PacketParserFactory by using the given key. The search first checks the local cache of packet parser factories before moving on to search in the classpath.
 * @param key The name of the PacketParserFactory that should be located.
 * @return a PacketParserFactory instance matching the given key.
 * @throws IOException if an error occurs while locating the factory.
 */
protected static PacketParserFactory findAgentFactory(String key) throws IOException {
  if (key == null) {
    throw new IOException("String_Node_Str" + key + "String_Node_Str");
  }
  PacketParserFactory factory=null;
  if (factory == null) {
    try {
      factory=AGENT_FACTORY_FINDER.newInstance(key);
    }
 catch (    Throwable e) {
      throw new IOException("String_Node_Str" + key + "String_Node_Str",e);
    }
  }
  return factory;
}

Fixed version (ground truth):
/** 
 * Searches for a PacketParserFactory by using the given key. The search first checks the local cache of packet parser factories before moving on to search in the classpath.
 * @param key The name of the PacketParserFactory that should be located.
 * @return a PacketParserFactory instance matching the given key.
 * @throws IOException if an error occurs while locating the factory.
 */
protected static PacketParserFactory findAgentFactory(String key) throws IOException {
  if (key == null) {
    throw new IOException("String_Node_Str");
  }
  PacketParserFactory factory=null;
  if (factory == null) {
    try {
      factory=AGENT_FACTORY_FINDER.newInstance(key);
    }
 catch (    Throwable e) {
      throw new IOException("String_Node_Str" + key + "String_Node_Str",e);
    }
  }
  return factory;
}
Program: 41781
Project: 41781
Buggy source:
/** 
 * Check whether the content-type field of the properties section (if present) in the given message matches the provided string (where null matches if there is no content type rpeesnt.
 * @param contentType content type string to compare against, or null if none
 * @param message the AMQP message object that is being examined.
 * @return true if content type matches
 */
public static boolean isContentType(String contentType,Message message){
  if (contentType == null) {
    return message.getContentType() == null;
  }
 else {
    return contentType.equals(message.getContentType());
  }
}

Fixed version (ground truth):
/** 
 * Check whether the content-type field of the properties section (if present) in the given message matches the provided string (where null matches if there is no content type present.
 * @param contentType content type string to compare against, or null if none
 * @param message the AMQP message object that is being examined.
 * @return true if content type matches
 */
public static boolean isContentType(String contentType,Message message){
  if (contentType == null) {
    return message.getContentType() == null;
  }
 else {
    return contentType.equals(message.getContentType());
  }
}
Program: 41782
Project: 41782
Buggy source:
public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  if (destination == null) {
    return;
  }
  String replyToAddress=destination.getName();
  String typeString=toTypeAnnotation(destination);
  message.setReplyToAddress(replyToAddress);
  if (replyToAddress == null || typeString == null) {
    message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}

Fixed version (ground truth):
public void setReplyToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  String replyToAddress=destination != null ? destination.getName() : null;
  String typeString=toTypeAnnotation(destination);
  message.setReplyToAddress(replyToAddress);
  if (replyToAddress == null || typeString == null) {
    message.removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}
Program: 41783
Project: 41783
Buggy source:
public void setToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  if (destination == null) {
    return;
  }
  String address=destination.getName();
  String typeString=toTypeAnnotation(destination);
  message.setToAddress(address);
  if (address == null || typeString == null) {
    message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}

Fixed version (ground truth):
public void setToAddressFromDestination(AmqpJmsMessageFacade message,JmsDestination destination){
  String address=destination != null ? destination.getName() : null;
  String typeString=toTypeAnnotation(destination);
  message.setToAddress(address);
  if (address == null || typeString == null) {
    message.removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
  }
 else {
    message.setAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME,typeString);
  }
}
Program: 41784
Project: 41784
Buggy source:
@Test public void testSetToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(message,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test public void testSetToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(message,null);
  Mockito.verify(message).setToAddress(null);
  Mockito.verify(message).removeAnnotation(TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
}
Program: 41785
Project: 41785
Buggy source:
@Test public void testSetReplyToAddressFromDestinationWithNullDestinationAndNullMessage(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(null,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test(expected=NullPointerException.class) public void testSetReplyToAddressFromDestinationWithNullDestinationAndNullMessage(){
  helper.setReplyToAddressFromDestination(null,null);
}
Program: 41786
Project: 41786
Buggy source:
@Test public void testSetReplyToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(message,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test public void testSetReplyToAddressFromDestinationWithNullDestination(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setReplyToAddressFromDestination(message,null);
  Mockito.verify(message).setReplyToAddress(null);
  Mockito.verify(message).removeAnnotation(REPLY_TO_TYPE_MSG_ANNOTATION_SYMBOL_NAME);
}
Program: 41787
Project: 41787
Buggy source:
@Test public void testSetToAddressFromDestinationWithNullDestinationAndNullMessage(){
  AmqpJmsMessageFacade message=Mockito.mock(AmqpJmsMessageFacade.class);
  helper.setToAddressFromDestination(null,null);
  Mockito.verifyZeroInteractions(message);
}

Fixed version (ground truth):
@Test(expected=NullPointerException.class) public void testSetToAddressFromDestinationWithNullDestinationAndNullMessage(){
  helper.setToAddressFromDestination(null,null);
}
Program: 41788
Project: 41788
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: 41789
Project: 41789
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: 41790
Project: 41790
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: 41791
Project: 41791
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: 41792
Project: 41792
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: 41793
Project: 41793
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: 41794
Project: 41794
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: 41797
Project: 41797
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: 41798
Project: 41798
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: 41799
Project: 41799
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: 41800
Project: 41800
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: 41802
Project: 41802
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: 41804
Project: 41804
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: 41805
Project: 41805
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();
}