nus-yam/ex-repair huggingface dataset:
Program: 155239
Project: 155239
Buggy source:
/** 
 * Executes a groovy script (with arguments) defined in   {@code line}. 
 * @param line the line which defines the groovy script with arguments.
 * @param session the {@link Session} to include as argument in groovy.
 * @param out the {@link Output} to include as argument in groovy.
 * @throws ShellException if the execution of a groovy script fails.
 */
public void execute(String line,Session session,Output out) throws ShellException {
  this.ensureDependenciesAreInClasspath();
  if (line == null || line.trim().length() == 0) {
    throw new ShellException("String_Node_Str");
  }
  List<String> pathList=this.getEnvPaths(session);
  String[] paths=pathList.toArray(new String[pathList.size()]);
  Object interpreter=this.newInterpreter(paths);
  Map<String,Object> properties=new HashMap<String,Object>();
  properties.put("String_Node_Str",out);
  properties.put("String_Node_Str",session);
  this.runScripts(interpreter,properties,line,paths);
}

Fixed version (ground truth):
/** 
 * Executes a groovy script (with arguments) defined in   {@code line}. 
 * @param line the line which defines the groovy script with arguments.
 * @param session the {@link Session} to include as argument in groovy.
 * @param out the {@link Output} to include as argument in groovy.
 * @throws ShellException if the execution of a groovy script fails.
 */
public void execute(String line,Session session,Output out) throws ShellException {
  this.ensureDependenciesAreInClasspath();
  if (line == null || line.trim().length() == 0) {
    return;
  }
  List<String> pathList=this.getEnvPaths(session);
  String[] paths=pathList.toArray(new String[pathList.size()]);
  Object interpreter=this.newInterpreter(paths);
  Map<String,Object> properties=new HashMap<String,Object>();
  properties.put("String_Node_Str",out);
  properties.put("String_Node_Str",session);
  this.runScripts(interpreter,properties,line,paths);
}
Program: 155240
Project: 155240
Buggy source:
protected abstract String getDefaultPaths();

Fixed version (ground truth):
protected String getDefaultPaths(){
  return "String_Node_Str" + File.separator + "String_Node_Str";
}
Program: 155241
Project: 155241
Buggy source:
private List<String> getEnvPaths(Session session) throws ShellException {
  try {
    List<String> list=new ArrayList<String>();
    collectPaths(list,(String)session.get(PATH_STRING));
    collectPaths(list,DEFAULT_PATHS);
    return list;
  }
 catch (  RemoteException e) {
    throw new ShellException(e);
  }
}

Fixed version (ground truth):
private List<String> getEnvPaths(Session session) throws ShellException {
  try {
    List<String> list=new ArrayList<String>();
    collectPaths(list,(String)session.get(getPathKey()));
    collectPaths(list,getDefaultPaths());
    return list;
  }
 catch (  RemoteException e) {
    throw new ShellException(e);
  }
}
Program: 155242
Project: 155242
Buggy source:
public Object getArray(int blockId){
}

Fixed version (ground truth):
public Object getArray(int blockId){
  byte bArray[]=get(blockId);
  return getRightArray(bArray);
}
Program: 155243
Project: 155243
Buggy source:
public Object getStringFor(PropertyRecord propRecord,ReadFromBuffer buffer){
  int recordToFind=(int)propRecord.getPropBlock();
  Iterator<DynamicRecord> records=propRecord.getValueRecords().iterator();
  List<char[]> charList=new LinkedList<char[]>();
  int totalSize=0;
  while (recordToFind != Record.NO_NEXT_BLOCK.intValue() && records.hasNext()) {
    DynamicRecord record=records.next();
    if (record.inUse() && record.getId() == recordToFind) {
      if (record.isLight()) {
        stringPropertyStore.makeHeavy(record,buffer);
      }
      if (!record.isCharData()) {
        ByteBuffer buf=ByteBuffer.wrap(record.getData());
        char[] chars=new char[record.getData().length / 2];
        totalSize+=chars.length;
        buf.asCharBuffer().get(chars);
        charList.add(chars);
      }
 else {
        charList.add(record.getDataAsChar());
      }
      recordToFind=record.getNextBlock();
      records=propRecord.getValueRecords().iterator();
    }
  }
  StringBuffer buf=new StringBuffer();
  for (  char[] str : charList) {
    buf.append(str);
  }
  return buf.toString();
}

Fixed version (ground truth):
public Object getStringFor(PropertyRecord propRecord,ReadFromBuffer buffer){
  int recordToFind=(int)propRecord.getPropBlock();
  Iterator<DynamicRecord> records=propRecord.getValueRecords().iterator();
  List<char[]> charList=new LinkedList<char[]>();
  int totalSize=0;
  while (recordToFind != Record.NO_NEXT_BLOCK.intValue() && records.hasNext()) {
    DynamicRecord record=records.next();
    if (record.getId() == recordToFind) {
      if (record.isLight()) {
        stringPropertyStore.makeHeavy(record,buffer);
      }
      if (!record.isCharData()) {
        ByteBuffer buf=ByteBuffer.wrap(record.getData());
        char[] chars=new char[record.getData().length / 2];
        totalSize+=chars.length;
        buf.asCharBuffer().get(chars);
        charList.add(chars);
      }
 else {
        charList.add(record.getDataAsChar());
      }
      recordToFind=record.getNextBlock();
      records=propRecord.getValueRecords().iterator();
    }
  }
  StringBuffer buf=new StringBuffer();
  for (  char[] str : charList) {
    buf.append(str);
  }
  return buf.toString();
}
Program: 155244
Project: 155244
Buggy source:
public Object getArrayFor(PropertyRecord propertyRecord,ReadFromBuffer buffer){
  return arrayPropertyStore.getArray((int)propertyRecord.getPropBlock());
}

Fixed version (ground truth):
public Object getArrayFor(PropertyRecord propertyRecord,ReadFromBuffer buffer){
  int recordToFind=(int)propertyRecord.getPropBlock();
  Iterator<DynamicRecord> records=propertyRecord.getValueRecords().iterator();
  List<byte[]> byteList=new LinkedList<byte[]>();
  int totalSize=0;
  while (recordToFind != Record.NO_NEXT_BLOCK.intValue() && records.hasNext()) {
    DynamicRecord record=records.next();
    if (record.getId() == recordToFind) {
      if (record.isLight()) {
        arrayPropertyStore.makeHeavy(record,buffer);
      }
      if (!record.isCharData()) {
        ByteBuffer buf=ByteBuffer.wrap(record.getData());
        byte[] bytes=new byte[record.getData().length];
        totalSize+=bytes.length;
        buf.get(bytes);
        byteList.add(bytes);
      }
 else {
        throw new RuntimeException("String_Node_Str");
      }
      recordToFind=record.getNextBlock();
      records=propertyRecord.getValueRecords().iterator();
    }
  }
  byte[] bArray=new byte[totalSize];
  int offset=0;
  for (  byte[] currentArray : byteList) {
    System.arraycopy(currentArray,0,bArray,offset,currentArray.length);
    offset+=currentArray.length;
  }
  return arrayPropertyStore.getRightArray(bArray);
}
Program: 155245
Project: 155245
Buggy source:
private static String fixJarEntryClassName(String entryName){
  entryName=entryName.replace(File.separatorChar,'.');
  return trimFromClassEnding(entryName);
}

Fixed version (ground truth):
private static String fixJarEntryClassName(String entryName){
  entryName=entryName.replace(File.separatorChar,'.');
  entryName=entryName.replace('/','.');
  return trimFromClassEnding(entryName);
}
Program: 155246
Project: 155246
Buggy source:
public void stop(){
  XaDataSourceManager.getManager().unregisterAllDataSources();
}

Fixed version (ground truth):
public void stop(){
  XaDataSourceManager.getManager().unregisterAllDataSources();
  TxManager.getManager().stop();
}
Program: 155248
Project: 155248
Buggy source:
public void execute(String line,Session session,Output out) throws ShellException {
  this.ensureGroovyIsInClasspath();
  if (line == null || line.trim().length() == 0) {
    throw new ShellException("String_Node_Str");
  }
  List<String> pathList=this.getEnvPaths(session);
  Object groovyScriptEngine=this.newGroovyScriptEngine(pathList.toArray(new String[pathList.size()]));
  Map<String,Object> properties=new HashMap<String,Object>();
  properties.put("String_Node_Str",out);
  properties.put("String_Node_Str",session);
  this.runGroovyScripts(groovyScriptEngine,properties,line);
}

Fixed version (ground truth):
public void execute(String line,Session session,Output out) throws ShellException {
  this.ensureGroovyIsInClasspath();
  if (line == null || line.trim().length() == 0) {
    throw new ShellException("String_Node_Str");
  }
  List<String> pathList=this.getEnvPaths(session);
  Object groovyScriptEngine=this.newGroovyScriptEngine(pathList.toArray(new String[pathList.size()]));
  Map<String,Object> properties=new HashMap<String,Object>();
  properties.put("String_Node_Str",new GshOutput(out));
  properties.put("String_Node_Str",session);
  this.runGroovyScripts(groovyScriptEngine,properties,line);
}
Program: 155249
Project: 155249
Buggy source:
private void runGroovyScript(Object groovyScriptEngine,String scriptName,Object groovyBinding) throws ShellException {
  try {
    Method runMethod=groovyScriptEngine.getClass().getMethod("String_Node_Str",String.class,groovyBinding.getClass());
    runMethod.invoke(groovyScriptEngine,scriptName + "String_Node_Str",groovyBinding);
  }
 catch (  Exception e) {
    throw new ShellException("String_Node_Str" + this.findProperMessage(e),e);
  }
}

Fixed version (ground truth):
private void runGroovyScript(Object groovyScriptEngine,String scriptName,Object groovyBinding) throws ShellException {
  try {
    Method runMethod=groovyScriptEngine.getClass().getMethod("String_Node_Str",String.class,groovyBinding.getClass());
    runMethod.invoke(groovyScriptEngine,scriptName + "String_Node_Str",groovyBinding);
  }
 catch (  Exception e) {
    throw new ShellException("String_Node_Str" + this.findProperMessage(e));
  }
}
Program: 155250
Project: 155250
Buggy source:
private String findProperMessage(Throwable e){
  String message=e.getMessage();
  if ((message == null || message.length() == 0) && e.getCause() != null) {
    message=this.findProperMessage(e.getCause());
  }
  return message;
}

Fixed version (ground truth):
private String findProperMessage(Throwable e){
  String message=e.getMessage();
  if (e.getCause() != null) {
    message=this.findProperMessage(e.getCause());
  }
  return message;
}
Program: 155252
Project: 155252
Buggy source:
/** 
 * Depending on transaction isolation level a lock may be released  as soon as possible or it may be held throughout the whole transaction. Invoking this method will trigger a release lock of   {@link LockType} <CODE>type</CODE> on the <CODE>resource</CODE> when the transaction  commits or rollbacks.
 * @param resource the resource on which the lock is taken
 * @param type type of lock (READ or WRITE)
 * @throws NotInTransactionException
 */
public void addLockToTransaction(Object resource,LockType type) throws NotInTransactionException {
  Thread currentThread=Thread.currentThread();
  List<LockElement> lockElements=lockMap.get(currentThread);
  if (lockElements != null) {
    lockElements.add(new LockElement(resource,type));
  }
 else {
    Transaction tx=null;
    try {
      tx=TransactionFactory.getTransactionManager().getTransaction();
      if (tx == null) {
        if (type == LockType.WRITE) {
          lockManager.releaseWriteLock(resource);
        }
 else         if (type == LockType.READ) {
          lockManager.releaseReadLock(resource);
        }
        throw new NotInTransactionException();
      }
      tx.registerSynchronization(txCommitHook);
    }
 catch (    javax.transaction.SystemException e) {
      throw new NotInTransactionException(e);
    }
catch (    Exception e) {
      throw new NotInTransactionException(e);
    }
    lockElements=new ArrayList<LockElement>();
    lockMap.put(currentThread,lockElements);
    lockElements.add(new LockElement(resource,type));
  }
}

Fixed version (ground truth):
/** 
 * Depending on transaction isolation level a lock may be released  as soon as possible or it may be held throughout the whole transaction. Invoking this method will trigger a release lock of   {@link LockType} <CODE>type</CODE> on the <CODE>resource</CODE> when the transaction  commits or rollbacks.
 * @param resource the resource on which the lock is taken
 * @param type type of lock (READ or WRITE)
 * @throws NotInTransactionException
 */
public void addLockToTransaction(Object resource,LockType type) throws NotInTransactionException {
  Thread currentThread=Thread.currentThread();
  List<LockElement> lockElements=lockMap.get(currentThread);
  if (lockElements != null) {
    lockElements.add(new LockElement(resource,type));
  }
 else {
    Transaction tx=null;
    try {
      tx=transactionManager.getTransaction();
      if (tx == null) {
        if (type == LockType.WRITE) {
          lockManager.releaseWriteLock(resource);
        }
 else         if (type == LockType.READ) {
          lockManager.releaseReadLock(resource);
        }
        throw new NotInTransactionException();
      }
      tx.registerSynchronization(txCommitHook);
    }
 catch (    javax.transaction.SystemException e) {
      throw new NotInTransactionException(e);
    }
catch (    Exception e) {
      throw new NotInTransactionException(e);
    }
    lockElements=new ArrayList<LockElement>();
    lockMap.put(currentThread,lockElements);
    lockElements.add(new LockElement(resource,type));
  }
}
Program: 155253
Project: 155253
Buggy source:
NodeImpl getNodeForProxy(int nodeId){
  Node node=nodeCache.get(nodeId);
  if (node != null) {
    return (NodeImpl)node;
  }
  node=new NodeImpl(nodeId);
  acquireLock(node,LockType.READ);
  try {
    if (nodeCache.get(nodeId) != null) {
      node=nodeCache.get(nodeId);
      return (NodeImpl)node;
    }
    if (PersistenceManager.getManager().loadLightNode(nodeId) == null) {
      throw new RuntimeException("String_Node_Str" + nodeId + "String_Node_Str");
    }
    nodeCache.add(nodeId,node);
    return (NodeImpl)node;
  }
 catch (  PersistenceException pe) {
    log.severe("String_Node_Str" + nodeId + "String_Node_Str"+ pe);
    throw new RuntimeException("String_Node_Str",pe);
  }
 finally {
    forceReleaseReadLock(node);
  }
}

Fixed version (ground truth):
NodeImpl getNodeForProxy(int nodeId){
  Node node=nodeCache.get(nodeId);
  if (node != null) {
    return (NodeImpl)node;
  }
  node=new NodeImpl(nodeId);
  acquireLock(node,LockType.READ);
  try {
    if (nodeCache.get(nodeId) != null) {
      node=nodeCache.get(nodeId);
      return (NodeImpl)node;
    }
    if (PersistenceManager.getManager().loadLightNode(nodeId) == null) {
      throw new NotFoundException("String_Node_Str" + nodeId + "String_Node_Str");
    }
    nodeCache.add(nodeId,node);
    return (NodeImpl)node;
  }
 catch (  PersistenceException pe) {
    log.severe("String_Node_Str" + nodeId + "String_Node_Str"+ pe);
    throw new RuntimeException("String_Node_Str",pe);
  }
 finally {
    forceReleaseReadLock(node);
  }
}
Program: 155254
Project: 155254
Buggy source:
static PropertyIndex createPropertyIndex(String key){
  int id=IdGenerator.getGenerator().nextId(PropertyIndex.class);
  PropertyIndex index=new PropertyIndex(key,id);
  EventManager em=EventManager.getManager();
  EventData eventData=new EventData(new PropIndexOpData(index));
  if (!em.generateProActiveEvent(Event.PROPERTY_INDEX_CREATE,eventData)) {
    setRollbackOnly();
    throw new CreateException("String_Node_Str" + "String_Node_Str");
  }
  addPropertyIndex(index);
  em.generateReActiveEvent(Event.PROPERTY_INDEX_CREATE,eventData);
  return index;
}

Fixed version (ground truth):
static PropertyIndex createPropertyIndex(String key){
  int id=IdGenerator.getGenerator().nextId(PropertyIndex.class);
  PropertyIndex index=new PropertyIndex(key,id);
  EventManager em=EventManager.getManager();
  EventData eventData=new EventData(new PropIndexOpData(index));
  if (!em.generateProActiveEvent(Event.PROPERTY_INDEX_CREATE,eventData)) {
    setRollbackOnly();
    throw new CreateException("String_Node_Str" + "String_Node_Str");
  }
  Transaction tx=null;
  try {
    tx=transactionManager.getTransaction();
    if (tx == null) {
      throw new NotInTransactionException("String_Node_Str" + index.getKey());
    }
    tx.registerSynchronization(new TxCommitHook(index));
  }
 catch (  javax.transaction.SystemException e) {
    throw new NotInTransactionException(e);
  }
catch (  Exception e) {
    throw new NotInTransactionException(e);
  }
  em.generateReActiveEvent(Event.PROPERTY_INDEX_CREATE,eventData);
  return index;
}
Program: 155255
Project: 155255
Buggy source:
static void addPropertyIndex(PropertyIndex index){
  List<PropertyIndex> list=indexMap.get(index.getKey());
  if (list == null) {
    list=new LinkedList<PropertyIndex>();
    indexMap.put(index.getKey(),list);
  }
  list.add(index);
  idToIndexMap.put(index.getKeyId(),index);
}

Fixed version (ground truth):
private static synchronized void addPropertyIndex(PropertyIndex index){
  List<PropertyIndex> list=indexMap.get(index.getKey());
  if (list == null) {
    list=new LinkedList<PropertyIndex>();
    indexMap.put(index.getKey(),list);
  }
  list.add(index);
  idToIndexMap.put(index.getKeyId(),index);
}
Program: 155256
Project: 155256
Buggy source:
public void setInUse(boolean inUse){
  super.setInUse(inUse);
  if (!inUse) {
    data=null;
  }
}

Fixed version (ground truth):
public void setInUse(boolean inUse,int type){
  this.type=type;
  this.setInUse(inUse);
}
Program: 155257
Project: 155257
Buggy source:
void unmap(){
  AccessController.doPrivileged(new PrivilegedAction(){
    public Object run(){
      try {
        Class[] argument=new Class[1];
        argument[0]=MappedByteBuffer.class;
        Method unmapMethod=getFileChannel().getClass().getMethod("String_Node_Str",argument);
        unmapMethod.setAccessible(true);
        unmapMethod.invoke(getFileChannel(),(MappedByteBuffer)buffer.getBuffer());
      }
 catch (      Exception e) {
        e.printStackTrace();
      }
      return null;
    }
  }
);
}

Fixed version (ground truth):
void unmap(){
}
Program: 155258
Project: 155258
Buggy source:
public Object getProperty(String key,Object defaultValue){
  if (key == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  acquireLock(this,LockType.READ);
  try {
    for (    PropertyIndex index : PropertyIndex.index(key)) {
      Property property=null;
      if (propertyMap != null) {
        property=propertyMap.get(index.getKeyId());
      }
      if (property != null) {
        return property.getValue();
      }
      if (ensureFullProperties()) {
        property=propertyMap.get(index.getKeyId());
        if (property != null) {
          return property.getValue();
        }
      }
    }
    if (!PropertyIndex.hasAll()) {
      ensureFullProperties();
      for (      int keyId : propertyMap.keySet()) {
        if (!PropertyIndex.hasIndexFor(keyId)) {
          PropertyIndex indexToCheck=PropertyIndex.getIndexFor(keyId);
          if (indexToCheck.getKey().equals(key)) {
            return propertyMap.get(indexToCheck.getKeyId());
          }
        }
      }
    }
  }
  finally {
    releaseLock(this,LockType.READ);
  }
  return defaultValue;
}

Fixed version (ground truth):
public Object getProperty(String key,Object defaultValue){
  if (key == null) {
    throw new IllegalArgumentException("String_Node_Str");
  }
  acquireLock(this,LockType.READ);
  try {
    for (    PropertyIndex index : PropertyIndex.index(key)) {
      Property property=null;
      if (propertyMap != null) {
        property=propertyMap.get(index.getKeyId());
      }
      if (property != null) {
        return property.getValue();
      }
      if (ensureFullProperties()) {
        property=propertyMap.get(index.getKeyId());
        if (property != null) {
          return property.getValue();
        }
      }
    }
    if (!PropertyIndex.hasAll()) {
      ensureFullProperties();
      for (      int keyId : propertyMap.keySet()) {
        if (!PropertyIndex.hasIndexFor(keyId)) {
          PropertyIndex indexToCheck=PropertyIndex.getIndexFor(keyId);
          if (indexToCheck.getKey().equals(key)) {
            return propertyMap.get(indexToCheck.getKeyId()).getValue();
          }
        }
      }
    }
  }
  finally {
    releaseLock(this,LockType.READ);
  }
  return defaultValue;
}
Program: 155259
Project: 155259
Buggy source:
public Object getProperty(String key,Object defaultValue){
  acquireLock(this,LockType.READ);
  try {
    for (    PropertyIndex index : PropertyIndex.index(key)) {
      Property property=null;
      if (propertyMap != null) {
        property=propertyMap.get(index.getKeyId());
      }
      if (property != null) {
        return property.getValue();
      }
      if (ensureFullRelationship()) {
        property=propertyMap.get(index.getKeyId());
        if (property != null) {
          return property.getValue();
        }
      }
    }
    if (!PropertyIndex.hasAll()) {
      ensureFullRelationship();
      for (      int keyId : propertyMap.keySet()) {
        if (!PropertyIndex.hasIndexFor(keyId)) {
          PropertyIndex indexToCheck=PropertyIndex.getIndexFor(keyId);
          if (indexToCheck.getKey().equals(key)) {
            return propertyMap.get(indexToCheck.getKeyId());
          }
        }
      }
    }
  }
  finally {
    releaseLock(this,LockType.READ);
  }
  return defaultValue;
}

Fixed version (ground truth):
public Object getProperty(String key,Object defaultValue){
  acquireLock(this,LockType.READ);
  try {
    for (    PropertyIndex index : PropertyIndex.index(key)) {
      Property property=null;
      if (propertyMap != null) {
        property=propertyMap.get(index.getKeyId());
      }
      if (property != null) {
        return property.getValue();
      }
      if (ensureFullRelationship()) {
        property=propertyMap.get(index.getKeyId());
        if (property != null) {
          return property.getValue();
        }
      }
    }
    if (!PropertyIndex.hasAll()) {
      ensureFullRelationship();
      for (      int keyId : propertyMap.keySet()) {
        if (!PropertyIndex.hasIndexFor(keyId)) {
          PropertyIndex indexToCheck=PropertyIndex.getIndexFor(keyId);
          if (indexToCheck.getKey().equals(key)) {
            return propertyMap.get(indexToCheck.getKeyId()).getValue();
          }
        }
      }
    }
  }
  finally {
    releaseLock(this,LockType.READ);
  }
  return defaultValue;
}
Program: 155260
Project: 155260
Buggy source:
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.addTest(TestArrayMap.suite());
  return new TestSetup(suite);
}

Fixed version (ground truth):
public static Test suite(){
  TestSuite suite=new TestSuite();
  suite.addTest(TestArrayMap.suite());
  suite.addTest(TestArrayIntSet.suite());
  return new TestSetup(suite);
}
Program: 155261
Project: 155261
Buggy source:
private static void performRequest(String[] args) throws IOException, InstantiationException {
  for (int i=0; i < args.length; i++) {
    if (args[i].equals("String_Node_Str") || args[i].equals("String_Node_Str")) {
      createStore(args[++i]);
    }
 else     if (args[i].equals("String_Node_Str")) {
      Properties properties=new Properties();
      FileInputStream inputStream=new FileInputStream(args[++i]);
      try {
        properties.load(inputStream);
        new NeoStoreXaDataSource(properties).close();
      }
  finally {
        inputStream.close();
      }
    }
 else     if (args[i].equals("String_Node_Str")) {
      fsckStore(args[++i]);
    }
 else {
      usage();
      return;
    }
  }
}

Fixed version (ground truth):
private static void performRequest(String[] args) throws IOException, InstantiationException {
  for (int i=0; i < args.length; i++) {
    if (args[i].equals("String_Node_Str") || args[i].equals("String_Node_Str")) {
      createStore(args[++i]);
    }
 else     if (args[i].equals("String_Node_Str")) {
      Properties properties=new Properties();
      FileInputStream inputStream=new FileInputStream(args[++i]);
      try {
        properties.load(inputStream);
        new NeoStoreXaDataSource(properties).close();
      }
  finally {
        inputStream.close();
      }
    }
 else     if (args[i].equals("String_Node_Str")) {
      dumpRelTypes(args[++i]);
    }
 else     if (args[i].equals("String_Node_Str")) {
      fsckStore(args[++i]);
    }
 else {
      usage();
      return;
    }
  }
}
Program: 155262
Project: 155262
Buggy source:
static void writeDynamicRecord(LogBuffer buffer,DynamicRecord record) throws IOException {
  record.setTransferStartPosition(buffer.getFileChannel(),buffer.getFileChannelPosition() + 8);
  if (record.inUse()) {
    byte inUse=Record.IN_USE.byteValue();
    buffer.putInt(record.getId()).putInt(record.getType()).put(inUse).putInt(record.getPrevBlock()).putInt(record.getLength()).putInt(record.getNextBlock());
    if (!record.isLight()) {
      if (!record.isCharData()) {
        byte[] data=record.getData();
        buffer.put(data);
        record.setTransferCount(13 + data.length);
      }
 else {
        char[] chars=record.getDataAsChar();
        buffer.put(chars);
        record.setTransferCount(13 + chars.length / 2);
      }
    }
 else {
      record.setTransferCount(13);
    }
  }
 else {
    byte inUse=Record.NOT_IN_USE.byteValue();
    buffer.putInt(record.getId()).putInt(record.getType()).put(inUse);
    record.setTransferCount(1);
  }
}

Fixed version (ground truth):
static void writeDynamicRecord(LogBuffer buffer,DynamicRecord record) throws IOException {
  record.setTransferStartPosition(buffer.getFileChannel(),buffer.getFileChannelPosition() + 8);
  if (record.inUse()) {
    byte inUse=Record.IN_USE.byteValue();
    buffer.putInt(record.getId()).putInt(record.getType()).put(inUse).putInt(record.getPrevBlock()).putInt(record.getLength()).putInt(record.getNextBlock());
    if (!record.isLight()) {
      if (!record.isCharData()) {
        byte[] data=record.getData();
        buffer.put(data);
        record.setTransferCount(13 + data.length);
      }
 else {
        char[] chars=record.getDataAsChar();
        buffer.put(chars);
        record.setTransferCount(13 + chars.length * 2);
      }
    }
 else {
      record.setTransferCount(13);
    }
  }
 else {
    byte inUse=Record.NOT_IN_USE.byteValue();
    buffer.putInt(record.getId()).putInt(record.getType()).put(inUse);
    record.setTransferCount(1);
  }
}
Program: 155263
Project: 155263
Buggy source:
private void transferRecord(NodeRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    throw new RuntimeException("String_Node_Str" + count + "String_Node_Str");
  }
}

Fixed version (ground truth):
private boolean transferRecord(NodeRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    return false;
  }
  return true;
}
Program: 155264
Project: 155264
Buggy source:
private void transferRecord(PropertyIndexRecord record) throws IOException {
  int id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    throw new RuntimeException("String_Node_Str" + count + "String_Node_Str");
  }
}

Fixed version (ground truth):
private boolean transferRecord(PropertyIndexRecord record) throws IOException {
  int id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    return false;
  }
  return true;
}
Program: 155265
Project: 155265
Buggy source:
private void transferRecord(PropertyRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    throw new RuntimeException("String_Node_Str" + count + "String_Node_Str");
  }
}

Fixed version (ground truth):
private boolean transferRecord(PropertyRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    return false;
  }
  return true;
}
Program: 155266
Project: 155266
Buggy source:
private void transferRecord(RelationshipRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    throw new RuntimeException("String_Node_Str" + count + "String_Node_Str");
  }
}

Fixed version (ground truth):
private boolean transferRecord(RelationshipRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    return false;
  }
  return true;
}
Program: 155267
Project: 155267
Buggy source:
private void transferRecord(RelationshipTypeRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    throw new RuntimeException("String_Node_Str" + count + "String_Node_Str");
  }
}

Fixed version (ground truth):
private boolean transferRecord(RelationshipTypeRecord record) throws IOException {
  long id=record.getId();
  long count=record.getTransferCount();
  FileChannel fileChannel=getFileChannel();
  fileChannel.position(id * getRecordSize());
  if (count != record.getFromChannel().transferTo(record.getTransferStartPosition(),count,fileChannel)) {
    return false;
  }
  return true;
}
Program: 155268
Project: 155268
Buggy source:
public synchronized void close() throws IOException {
  if (xidIdentMap.size() > 0) {
    log.info("String_Node_Str" + xidIdentMap.size());
    log.info("String_Node_Str" + fileName);
    writeBuffer.force();
    fileChannel.close();
    return;
  }
  writeBuffer.force();
  long truncateAt=writeBuffer.getFileChannelPosition();
  writeBuffer=null;
  fileChannel.truncate(truncateAt);
  fileChannel.close();
  File file=new File(fileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + fileName + "String_Node_Str");
  }
  file.delete();
}

Fixed version (ground truth):
public synchronized void close() throws IOException {
  if (xidIdentMap.size() > 0) {
    log.info("String_Node_Str" + xidIdentMap.size());
    log.info("String_Node_Str" + fileName);
    writeBuffer.force();
    fileChannel.close();
    return;
  }
  writeBuffer.force();
  writeBuffer=null;
  fileChannel.close();
  File file=new File(fileName);
  if (!file.exists()) {
    throw new IOException("String_Node_Str" + fileName + "String_Node_Str");
  }
  try {
    file.delete();
  }
 catch (  Exception e) {
    try {
      Thread.sleep(500);
      file.delete();
    }
 catch (    Throwable t) {
      log.warning("String_Node_Str" + fileName + "String_Node_Str"+ e);
      log.info("String_Node_Str" + "String_Node_Str");
    }
  }
}
Program: 155269
Project: 155269
Buggy source:
public boolean isReadOnly(){
  if (isRecovered()) {
    if (nodeCommands.size() == 0 && propCommands.size() == 0 && relCommands.size() == 0 && relTypeCommands.size() == 0 && propIndexCommands.size() == 0) {
      return true;
    }
    return false;
  }
  if (nodeRecords.size() == 0 && relRecords.size() == 0 && relTypeRecords.size() == 0 && propertyRecords.size() == 0) {
    return true;
  }
  return false;
}

Fixed version (ground truth):
public boolean isReadOnly(){
  if (isRecovered()) {
    if (nodeCommands.size() == 0 && propCommands.size() == 0 && relCommands.size() == 0 && relTypeCommands.size() == 0 && propIndexCommands.size() == 0) {
      return true;
    }
    return false;
  }
  if (nodeRecords.size() == 0 && relRecords.size() == 0 && relTypeRecords.size() == 0 && propertyRecords.size() == 0 && propIndexRecords.size() == 0) {
    return true;
  }
  return false;
}
Program: 155270
Project: 155270
Buggy source:
public void changeProperty(int relId,int propertyId,Object value) throws IOException {
  xaCon.getNeoTransaction().relChangeProperty(propertyId,value);
}

Fixed version (ground truth):
public void changeProperty(int relId,int propertyId,Object value) throws IOException {
  xaCon.getNeoTransaction().relChangeProperty(relId,propertyId,value);
}
Program: 155272
Project: 155272
Buggy source:
void nodeChangeProperty(int propertyId,Object value) throws IOException {
  PropertyRecord propertyRecord=getPropertyRecord(propertyId);
  if (propertyRecord == null) {
    propertyRecord=getPropertyStore().getRecord(propertyId,readFromBuffer);
    addPropertyRecord(propertyRecord);
  }
  if (propertyRecord.isLight()) {
    getPropertyStore().makeHeavy(propertyRecord,readFromBuffer);
  }
  if (propertyRecord.getType() == PropertyType.STRING) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.STRING.intValue());
      }
    }
  }
 else   if (propertyRecord.getType() == PropertyType.ARRAY) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.ARRAY.intValue());
      }
    }
  }
  getPropertyStore().encodeValue(propertyRecord,value);
  addPropertyRecord(propertyRecord);
}

Fixed version (ground truth):
void nodeChangeProperty(int nodeId,int propertyId,Object value) throws IOException {
  PropertyRecord propertyRecord=getPropertyRecord(propertyId);
  if (propertyRecord == null) {
    propertyRecord=getPropertyStore().getRecord(propertyId,readFromBuffer);
    addPropertyRecord(propertyRecord);
  }
  propertyRecord.setNodeId(nodeId);
  if (propertyRecord.isLight()) {
    getPropertyStore().makeHeavy(propertyRecord,readFromBuffer);
  }
  if (propertyRecord.getType() == PropertyType.STRING) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.STRING.intValue());
      }
    }
  }
 else   if (propertyRecord.getType() == PropertyType.ARRAY) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.ARRAY.intValue());
      }
    }
  }
  getPropertyStore().encodeValue(propertyRecord,value);
  addPropertyRecord(propertyRecord);
}
Program: 155274
Project: 155274
Buggy source:
void relChangeProperty(int propertyId,Object value) throws IOException {
  PropertyRecord propertyRecord=getPropertyRecord(propertyId);
  if (propertyRecord == null) {
    propertyRecord=getPropertyStore().getRecord(propertyId,readFromBuffer);
    addPropertyRecord(propertyRecord);
  }
  if (propertyRecord.isLight()) {
    getPropertyStore().makeHeavy(propertyRecord,readFromBuffer);
  }
  if (propertyRecord.getType() == PropertyType.STRING) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.STRING.intValue());
      }
    }
  }
 else   if (propertyRecord.getType() == PropertyType.ARRAY) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.ARRAY.intValue());
      }
    }
  }
  getPropertyStore().encodeValue(propertyRecord,value);
  addPropertyRecord(propertyRecord);
}

Fixed version (ground truth):
void relChangeProperty(int relId,int propertyId,Object value) throws IOException {
  PropertyRecord propertyRecord=getPropertyRecord(propertyId);
  if (propertyRecord == null) {
    propertyRecord=getPropertyStore().getRecord(propertyId,readFromBuffer);
    addPropertyRecord(propertyRecord);
  }
  propertyRecord.setRelId(relId);
  if (propertyRecord.isLight()) {
    getPropertyStore().makeHeavy(propertyRecord,readFromBuffer);
  }
  if (propertyRecord.getType() == PropertyType.STRING) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.STRING.intValue());
      }
    }
  }
 else   if (propertyRecord.getType() == PropertyType.ARRAY) {
    for (    DynamicRecord record : propertyRecord.getValueRecords()) {
      if (record.inUse()) {
        record.setInUse(false,PropertyType.ARRAY.intValue());
      }
    }
  }
  getPropertyStore().encodeValue(propertyRecord,value);
  addPropertyRecord(propertyRecord);
}
Program: 155276
Project: 155276
Buggy source:
private void releaseCommands(int param){
  if (param == Status.STATUS_COMMITTED || param == Status.STATUS_ROLLEDBACK) {
    LockReleaser.getManager().releaseLocks();
  }
 else {
switch (param) {
case Status.STATUS_ACTIVE:
      log.severe("String_Node_Str" + "String_Node_Str");
    break;
case Status.STATUS_COMMITTING:
  log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_MARKED_ROLLBACK:
log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_NO_TRANSACTION:
log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_PREPARED:
log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_PREPARING:
log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_ROLLING_BACK:
log.severe("String_Node_Str" + "String_Node_Str");
break;
case Status.STATUS_UNKNOWN:
log.severe("String_Node_Str" + "String_Node_Str");
break;
default :
log.severe("String_Node_Str" + "String_Node_Str" + param + "String_Node_Str");
}
throw new RuntimeException();
}
}

Fixed version (ground truth):
private void releaseCommands(int param){
  LockReleaser.getManager().releaseLocks();
}
Program: 155278
Project: 155278
Buggy source:
synchronized void dumpStack(){
  System.out.println("String_Node_Str" + readCount + "String_Node_Str"+ writeCount);
  System.out.println("String_Node_Str");
  java.util.Iterator itr=waitingThreadList.iterator();
  while (itr.hasNext()) {
    WaitElement we=(WaitElement)itr.next();
    System.out.print("String_Node_Str" + we.element.thread + "String_Node_Str"+ we.element.readCount+ "String_Node_Str"+ we.element.writeCount+ "String_Node_Str"+ we.lockType+ "String_Node_Str");
    if (itr.hasNext()) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.println();
    }
  }
  System.out.println("String_Node_Str");
  itr=threadLockElementMap.values().iterator();
  while (itr.hasNext()) {
    ThreadLockElement tle=(ThreadLockElement)itr.next();
    System.out.println("String_Node_Str" + tle.thread + "String_Node_Str"+ tle.readCount+ "String_Node_Str"+ tle.writeCount+ "String_Node_Str");
  }
}

Fixed version (ground truth):
synchronized void dumpStack(){
  System.out.println("String_Node_Str" + readCount + "String_Node_Str"+ writeCount+ "String_Node_Str"+ resource);
  System.out.println("String_Node_Str");
  java.util.Iterator itr=waitingThreadList.iterator();
  while (itr.hasNext()) {
    WaitElement we=(WaitElement)itr.next();
    System.out.print("String_Node_Str" + we.element.thread + "String_Node_Str"+ we.element.readCount+ "String_Node_Str"+ we.element.writeCount+ "String_Node_Str"+ we.lockType+ "String_Node_Str");
    if (itr.hasNext()) {
      System.out.print("String_Node_Str");
    }
 else {
      System.out.println();
    }
  }
  System.out.println("String_Node_Str");
  itr=threadLockElementMap.values().iterator();
  while (itr.hasNext()) {
    ThreadLockElement tle=(ThreadLockElement)itr.next();
    System.out.println("String_Node_Str" + tle.thread + "String_Node_Str"+ tle.readCount+ "String_Node_Str"+ tle.writeCount+ "String_Node_Str");
  }
}
Program: 155279
Project: 155279
Buggy source:
public void testBrokenDone(){
  try {
    Xid xid=new XidImpl(new byte[4],new byte[4]);
    XAResource xaRes=xaCon.getXaResource();
    xaRes.start(xid,XAResource.TMNOFLAGS);
    int node1=ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    int node2=ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node2);
    int n1prop1=ds.nextId(PropertyStore.class);
    xaCon.getNodeConsumer().addProperty(node1,n1prop1,index("String_Node_Str"),"String_Node_Str");
    xaRes.end(xid,XAResource.TMSUCCESS);
    xaRes.prepare(xid);
    xaRes.commit(xid,false);
    ds=new NeoStoreXaDataSource("String_Node_Str","String_Node_Str");
    xaCon=(NeoStoreXaConnection)ds.getXaConnection();
    xaRes=xaCon.getXaResource();
    assertEquals(1,xaRes.recover(XAResource.TMNOFLAGS).length);
    xaCon.clearAllTransactions();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
public void testBrokenDone(){
  try {
    Xid xid=new XidImpl(new byte[4],new byte[4]);
    XAResource xaRes=xaCon.getXaResource();
    xaRes.start(xid,XAResource.TMNOFLAGS);
    int node1=ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node1);
    int node2=ds.nextId(Node.class);
    xaCon.getNodeConsumer().createNode(node2);
    int n1prop1=ds.nextId(PropertyStore.class);
    xaCon.getNodeConsumer().addProperty(node1,n1prop1,index("String_Node_Str"),"String_Node_Str");
    xaRes.end(xid,XAResource.TMSUCCESS);
    xaRes.prepare(xid);
    copyLogicalLog();
    xaRes.commit(xid,false);
    ds.truncateLogicalLog();
    copyLogicalLog();
    ds.close();
    renameLogicalLog();
    ds=new NeoStoreXaDataSource("String_Node_Str","String_Node_Str");
    xaCon=(NeoStoreXaConnection)ds.getXaConnection();
    xaRes=xaCon.getXaResource();
    assertEquals(1,xaRes.recover(XAResource.TMNOFLAGS).length);
    xaCon.clearAllTransactions();
  }
 catch (  Exception e) {
    e.printStackTrace();
    fail("String_Node_Str" + e);
  }
}
Program: 155280
Project: 155280
Buggy source:
public void testRelationshipChangeProperty(){
  try {
    Integer int1=new Integer(1);
    Integer int2=new Integer(2);
    String string1=new String("String_Node_Str");
    String string2=new String("String_Node_Str");
    Node node1=NodeManager.getManager().createNode();
    Node node2=NodeManager.getManager().createNode();
    Relationship rel1=NodeManager.getManager().createRelationship(node1,node2,MyRelTypes.TEST);
    Relationship rel2=NodeManager.getManager().createRelationship(node2,node1,MyRelTypes.TEST);
    rel1.setProperty(key1,int1);
    rel2.setProperty(key1,string1);
    rel1.setProperty(key2,string2);
    rel2.setProperty(key2,int2);
    try {
      rel1.setProperty(null,null);
      fail("String_Node_Str");
    }
 catch (    IllegalValueException e) {
    }
catch (    NotFoundException e) {
      fail("String_Node_Str");
    }
    try {
      rel2.setProperty(key1,int1);
      fail("String_Node_Str");
    }
 catch (    IllegalValueException e) {
    }
  }
 catch (  IllegalValueException e) {
    fail("String_Node_Str" + e);
  }
catch (  NotFoundException e) {
    fail("String_Node_Str" + e);
  }
}

Fixed version (ground truth):
public void testRelationshipChangeProperty(){
  try {
    Integer int1=new Integer(1);
    Integer int2=new Integer(2);
    String string1=new String("String_Node_Str");
    String string2=new String("String_Node_Str");
    Node node1=NodeManager.getManager().createNode();
    Node node2=NodeManager.getManager().createNode();
    Relationship rel1=NodeManager.getManager().createRelationship(node1,node2,MyRelTypes.TEST);
    Relationship rel2=NodeManager.getManager().createRelationship(node2,node1,MyRelTypes.TEST);
    rel1.setProperty(key1,int1);
    rel2.setProperty(key1,string1);
    rel1.setProperty(key2,string2);
    rel2.setProperty(key2,int2);
    try {
      rel1.setProperty(null,null);
      fail("String_Node_Str");
    }
 catch (    IllegalValueException e) {
    }
catch (    NotFoundException e) {
      fail("String_Node_Str");
    }
    rel2.setProperty(key1,int1);
  }
 catch (  IllegalValueException e) {
    fail("String_Node_Str" + e);
  }
catch (  NotFoundException e) {
    fail("String_Node_Str" + e);
  }
}
Program: 155282
Project: 155282
Buggy source:
public void beforeCompletion(){
  getListener().removeThisEvaluator();
  if (deletedNodes != null) {
    Iterator<NodeImpl> itr=deletedNodes.values().iterator();
    while (itr.hasNext()) {
      NodeImpl node=itr.next();
      if (node.hasRelationships()) {
        log.severe("String_Node_Str" + node + "String_Node_Str");
        setRollbackOnly();
      }
    }
  }
}

Fixed version (ground truth):
public void beforeCompletion(){
  getListener().removeThisEvaluator();
  if (getTransactionStatus() == Status.STATUS_MARKED_ROLLBACK) {
    return;
  }
  if (deletedNodes != null) {
    Iterator<NodeImpl> itr=deletedNodes.values().iterator();
    while (itr.hasNext()) {
      NodeImpl node=itr.next();
      if (node.hasRelationships()) {
        log.severe("String_Node_Str" + node + "String_Node_Str");
        StringBuffer buf=new StringBuffer("String_Node_Str");
        int count=0;
        for (        Relationship rel : node.getRelationships()) {
          if (count == 10) {
            buf.append("String_Node_Str");
            break;
          }
          buf.append(rel.getType()).append("String_Node_Str");
        }
        log.severe(buf.toString());
        setRollbackOnly();
      }
    }
  }
}
Program: 155283
Project: 155283
Buggy source:
public void stop(){
  NeoConstraintsListener.getListener().unregisterEventListeners();
  AdaptiveCacheManager.getManager().stop();
}

Fixed version (ground truth):
public void stop(){
  RelationshipTypeHolder rth=RelationshipTypeHolder.getHolder();
  rth.clear();
  NodeManager.getManager().clearCache();
  NeoConstraintsListener.getListener().unregisterEventListeners();
  AdaptiveCacheManager.getManager().stop();
}
Program: 155284
Project: 155284
Buggy source:
@Override public void writeToFile(FileChannel fileChannel,ByteBuffer buffer) throws IOException {
  buffer.clear();
  byte inUse=record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue();
  buffer.put(REL_TYPE_COMMAND);
  buffer.putInt(record.getId()).put(inUse).putInt(record.getTypeBlock());
  Collection<DynamicRecord> typeRecords=record.getTypeRecords();
  buffer.putInt(typeRecords.size());
  buffer.flip();
  fileChannel.write(buffer);
  for (  DynamicRecord typeRecord : typeRecords) {
    writeDynamicRecord(typeRecord,fileChannel,buffer);
  }
}

Fixed version (ground truth):
@Override public void writeToFile(FileChannel fileChannel,ByteBuffer buffer) throws IOException {
  buffer.clear();
  byte inUse=record.inUse() ? Record.IN_USE.byteValue() : Record.NOT_IN_USE.byteValue();
  buffer.put(REL_TYPE_COMMAND);
  buffer.putInt(record.getId()).put(inUse).putInt(record.getTypeBlock());
  Collection<DynamicRecord> typeRecords=record.getTypeRecords();
  buffer.putInt(typeRecords.size());
  for (  DynamicRecord typeRecord : typeRecords) {
    if ((buffer.capacity() - buffer.position()) < typeRecord.getLength()) {
      buffer.flip();
      fileChannel.write(buffer);
      buffer.flip();
    }
    writeDynamicRecord(typeRecord,buffer);
  }
  buffer.flip();
  fileChannel.write(buffer);
}