nus-yam/ex-repair huggingface dataset:
Program: 168538
Project: 168538
Buggy source:
/** 
 * Calculates the combined sizes of the forks of types <code>forkTypes</code> for the selection, including all files in subdirectories. If <code>forkTypes</code> is empty, all forks are included in the calculation.
 * @param selection
 * @param forkTypes
 * @return
 */
private long calculateForkSizeRecursive(FSEntry[] selection,FSForkType... forkTypes){
  long res=0;
  for (  FSEntry curEntry : selection) {
    if (curEntry instanceof FSFile) {
      FSFile curFile=(FSFile)curEntry;
      if (forkTypes.length > 0) {
        for (        FSForkType t : forkTypes) {
          FSFork curFork=curFile.getForkByType(t);
          if (curFork != null)           res+=curFork.getLength();
        }
      }
 else       res+=curFile.getCombinedLength();
    }
 else     if (curEntry instanceof FSFolder) {
      FSFolder curFolder=(FSFolder)curEntry;
      res+=calculateForkSizeRecursive(curFolder.list(),forkTypes);
    }
 else     System.err.println("String_Node_Str" + curEntry.getClass());
  }
  return res;
}

Fixed version (ground truth):
/** 
 * Calculates the combined sizes of the forks of types <code>forkTypes</code> for the selection, including all files in subdirectories. If <code>forkTypes</code> is empty, all forks are included in the calculation.
 * @param selection
 * @param forkTypes
 * @return
 */
private long calculateForkSizeRecursive(FSEntry[] selection,FSForkType... forkTypes){
  long res=0;
  for (  FSEntry curEntry : selection) {
    if (curEntry instanceof FSFile) {
      FSFile curFile=(FSFile)curEntry;
      if (forkTypes.length > 0) {
        for (        FSForkType t : forkTypes) {
          FSFork curFork=curFile.getForkByType(t);
          if (curFork != null) {
            res+=curFork.getLength();
          }
        }
      }
 else {
        res+=curFile.getCombinedLength();
      }
    }
 else     if (curEntry instanceof FSFolder) {
      FSFolder curFolder=(FSFolder)curEntry;
      res+=calculateForkSizeRecursive(curFolder.list(),forkTypes);
    }
 else {
      System.err.println("String_Node_Str" + curEntry.getClass());
    }
  }
  return res;
}
Program: 168542
Project: 168542
Buggy source:
@Override public List<Record<FSEntry>> getFolderContents(List<Record<FSEntry>> folderRecordPath){
  FSEntry lastEntry=folderRecordPath.get(folderRecordPath.size() - 1).getUserObject();
  if (lastEntry instanceof FSFolder) {
    FSEntry[] entryArray=((FSFolder)lastEntry).list();
    ArrayList<Record<FSEntry>> entryList=new ArrayList<Record<FSEntry>>(entryArray.length);
    for (    FSEntry entry : entryArray) {
      Record<FSEntry> rec=new FSEntryRecord(entry);
      entryList.add(rec);
    }
    return entryList;
  }
 else   throw new RuntimeException("String_Node_Str" + lastEntry.getClass());
}

Fixed version (ground truth):
@Override public List<Record<FSEntry>> getFolderContents(List<Record<FSEntry>> folderRecordPath){
  FSEntry lastEntry=folderRecordPath.get(folderRecordPath.size() - 1).getUserObject();
  if (lastEntry instanceof FSFolder) {
    FSEntry[] entryArray=((FSFolder)lastEntry).list();
    ArrayList<Record<FSEntry>> entryList=new ArrayList<Record<FSEntry>>(entryArray.length);
    for (    FSEntry entry : entryArray) {
      Record<FSEntry> rec=new FSEntryRecord(entry);
      entryList.add(rec);
    }
    return entryList;
  }
 else {
    throw new RuntimeException("String_Node_Str" + lastEntry.getClass());
  }
}
Program: 168543
Project: 168543
Buggy source:
private long extractForkToStream(FSFork theFork,OutputStream os,ProgressMonitor pm) throws IOException {
  ReadableRandomAccessStream forkFilter=theFork.getReadableRandomAccessStream();
  final long originalLength=theFork.getLength();
  long bytesToRead=originalLength;
  byte[] buffer=new byte[4096];
  while (bytesToRead > 0) {
    if (pm.cancelSignaled())     break;
    int bytesRead=forkFilter.read(buffer,0,(bytesToRead < buffer.length ? (int)bytesToRead : buffer.length));
    if (bytesRead < 0)     break;
 else {
      pm.addDataProgress(bytesRead);
      os.write(buffer,0,bytesRead);
      bytesToRead-=bytesRead;
    }
  }
  return originalLength - bytesToRead;
}

Fixed version (ground truth):
private long extractForkToStream(FSFork theFork,OutputStream os,ProgressMonitor pm) throws IOException {
  ReadableRandomAccessStream forkFilter=theFork.getReadableRandomAccessStream();
  final long originalLength=theFork.getLength();
  long bytesToRead=originalLength;
  byte[] buffer=new byte[4096];
  while (bytesToRead > 0) {
    if (pm.cancelSignaled()) {
      break;
    }
    int bytesRead=forkFilter.read(buffer,0,(bytesToRead < buffer.length ? (int)bytesToRead : buffer.length));
    if (bytesRead < 0) {
      break;
    }
 else {
      pm.addDataProgress(bytesRead);
      os.write(buffer,0,bytesRead);
      bytesToRead-=bytesRead;
    }
  }
  return originalLength - bytesToRead;
}
Program: 168544
Project: 168544
Buggy source:
@Override public void actionExtractToDir(List<Record<FSEntry>> recordList){
  List<FSEntry> fsEntryList=new ArrayList<FSEntry>(recordList.size());
  for (  Record<FSEntry> rec : recordList)   fsEntryList.add(rec.getUserObject());
  FileSystemBrowserWindow.this.actionExtractToDir(fsEntryList,true,false);
}

Fixed version (ground truth):
@Override public void actionExtractToDir(List<Record<FSEntry>> recordList){
  List<FSEntry> fsEntryList=new ArrayList<FSEntry>(recordList.size());
  for (  Record<FSEntry> rec : recordList) {
    fsEntryList.add(rec.getUserObject());
  }
  FileSystemBrowserWindow.this.actionExtractToDir(fsEntryList,true,false);
}
Program: 168546
Project: 168546
Buggy source:
@Override public void actionGetInfo(List<Record<FSEntry>> recordList){
  if (recordList.size() == 1)   FileSystemBrowserWindow.this.actionGetInfo(recordList.get(0).getUserObject());
 else   if (recordList.size() > 1) {
    JOptionPane.showMessageDialog(FileSystemBrowserWindow.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
  }
}

Fixed version (ground truth):
@Override public void actionGetInfo(List<Record<FSEntry>> recordList){
  if (recordList.size() == 1) {
    FileSystemBrowserWindow.this.actionGetInfo(recordList.get(0).getUserObject());
  }
 else   if (recordList.size() > 1) {
    JOptionPane.showMessageDialog(FileSystemBrowserWindow.this,"String_Node_Str","String_Node_Str",JOptionPane.ERROR_MESSAGE);
  }
}
Program: 168547
Project: 168547
Buggy source:
@Override public String[] parseAddressPath(String targetAddress){
  if (!targetAddress.startsWith("String_Node_Str"))   return null;
 else {
    String remainder=targetAddress.substring(1);
    if (remainder.length() == 0)     return new String[0];
 else {
      String[] res=remainder.split("String_Node_Str");
      return res;
    }
  }
}

Fixed version (ground truth):
@Override public String[] parseAddressPath(String targetAddress){
  if (!targetAddress.startsWith("String_Node_Str")) {
    return null;
  }
 else {
    String remainder=targetAddress.substring(1);
    if (remainder.length() == 0) {
      return new String[0];
    }
 else {
      String[] res=remainder.split("String_Node_Str");
      return res;
    }
  }
}
Program: 168549
Project: 168549
Buggy source:
/** 
 * @{inheritDoc }
 */
@Override public String decode(byte[] data,int off,int len){
  try {
    return decoder.decode(ByteBuffer.wrap(data,off,len)).toString();
  }
 catch (  CharacterCodingException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public String decode(byte[] data,int off,int len){
  try {
    return decoder.decode(ByteBuffer.wrap(data,off,len)).toString();
  }
 catch (  CharacterCodingException e) {
    throw new RuntimeException("String_Node_Str",e);
  }
}
Program: 168550
Project: 168550
Buggy source:
public String getCharsetName(){
  return charsetName;
}

Fixed version (ground truth):
/** 
 * Returns the charset name as it was passed to the constructor.
 * @return the charset name as it was passed to the constructor.
 */
public String getCharsetName(){
  return charsetName;
}
Program: 168551
Project: 168551
Buggy source:
/** 
 * @{inheritDoc }
 */
@Override public boolean isAllocationBlockUsed(long blockNumber) throws IllegalArgumentException {
  if (blockNumber < 0 || blockNumber > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockNumber + "String_Node_Str");
  return super.isAllocationBlockUsed(blockNumber);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isAllocationBlockUsed(long blockNumber) throws IllegalArgumentException {
  if (blockNumber < 0 || blockNumber > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockNumber + "String_Node_Str");
  return super.isAllocationBlockUsed(blockNumber);
}
Program: 168552
Project: 168552
Buggy source:
@Override public CommonHFSExtentDescriptor createExtentDescriptor(long startBlock,long blockCount){
  if (startBlock < 0 || startBlock > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + startBlock + "String_Node_Str");
  if (blockCount < 0 || blockCount > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockCount + "String_Node_Str");
  ExtDescriptor ed=new ExtDescriptor((short)startBlock,(short)blockCount);
  return CommonHFSExtentDescriptor.create(ed);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public CommonHFSExtentDescriptor createExtentDescriptor(long startBlock,long blockCount){
  if (startBlock < 0 || startBlock > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + startBlock + "String_Node_Str");
  if (blockCount < 0 || blockCount > ((long)Short.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockCount + "String_Node_Str");
  ExtDescriptor ed=new ExtDescriptor((short)startBlock,(short)blockCount);
  return CommonHFSExtentDescriptor.create(ed);
}
Program: 168553
Project: 168553
Buggy source:
/** 
 * @{inheritDoc }
 */
@Override public boolean isAllocationBlockUsed(long blockNumber) throws IllegalArgumentException {
  if (blockNumber < 0 || blockNumber > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockNumber + "String_Node_Str");
  return super.isAllocationBlockUsed(blockNumber);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public boolean isAllocationBlockUsed(long blockNumber) throws IllegalArgumentException {
  if (blockNumber < 0 || blockNumber > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockNumber + "String_Node_Str");
  return super.isAllocationBlockUsed(blockNumber);
}
Program: 168554
Project: 168554
Buggy source:
@Override public CommonHFSExtentDescriptor createExtentDescriptor(long startBlock,long blockCount){
  if (startBlock < 0 || startBlock > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + startBlock + "String_Node_Str");
  if (blockCount < 0 || blockCount > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockCount + "String_Node_Str");
  HFSPlusExtentDescriptor hped=new HFSPlusExtentDescriptor((int)startBlock,(int)blockCount);
  return CommonHFSExtentDescriptor.create(hped);
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public CommonHFSExtentDescriptor createExtentDescriptor(long startBlock,long blockCount){
  if (startBlock < 0 || startBlock > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + startBlock + "String_Node_Str");
  if (blockCount < 0 || blockCount > ((long)Integer.MAX_VALUE) * 2)   throw new IllegalArgumentException("String_Node_Str" + blockCount + "String_Node_Str");
  HFSPlusExtentDescriptor hped=new HFSPlusExtentDescriptor((int)startBlock,(int)blockCount);
  return CommonHFSExtentDescriptor.create(hped);
}
Program: 168555
Project: 168555
Buggy source:
@Override public String getLinkTargetString(){
  byte[] b=Util.readFully(fsHandler.getReadableDataForkStream(linkRecord));
  return Util.readString(b,"String_Node_Str");
}

Fixed version (ground truth):
@Override public String getLinkTargetString(){
  return getLinkTargetPosixPath();
}
Program: 168556
Project: 168556
Buggy source:
@Override public FSEntry getLinkTarget(){
  return fsHandler.getEntry(fsHandler.lookupParentFolder(linkRecord).getInternalCatalogFolderRecord(),getLinkTargetPath(fsHandler,linkRecord));
}

Fixed version (ground truth):
@Override public FSEntry getLinkTarget(){
  return fsHandler.getEntryByPosixPath(getLinkTargetPosixPath(),fsHandler.lookupParentFolder(linkRecord));
}
Program: 168557
Project: 168557
Buggy source:
public RecordTypeEntry(RecordType recordType){
  this.recordType=recordType;
switch (recordType) {
case FILE:
    displayString="String_Node_Str";
  break;
case FOLDER:
displayString="String_Node_Str";
break;
case FILE_LINK:
displayString="String_Node_Str";
break;
case FOLDER_LINK:
displayString="String_Node_Str";
break;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + recordType + "String_Node_Str");
}
}

Fixed version (ground truth):
public RecordTypeEntry(RecordType recordType){
  this.recordType=recordType;
switch (recordType) {
case FILE:
    displayString="String_Node_Str";
  break;
case FOLDER:
displayString="String_Node_Str";
break;
case FILE_LINK:
displayString="String_Node_Str";
break;
case FOLDER_LINK:
displayString="String_Node_Str";
break;
case BROKEN_LINK:
displayString="String_Node_Str";
break;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + recordType + "String_Node_Str");
}
}
Program: 168558
Project: 168558
Buggy source:
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,final int row,final int column){
  if (value instanceof RecordContainer) {
    final Component objectComponent=objectRenderer.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
    final JLabel jl=theOne;
    Record rec=((RecordContainer)value).getRecord(genericPlaceholder);
    if (rec.getType() == RecordType.FOLDER || rec.getType() == RecordType.FOLDER_LINK)     jl.setIcon(folderIcon);
 else     if (rec.getType() == RecordType.FILE || rec.getType() == RecordType.FILE_LINK)     jl.setIcon(documentIcon);
 else     jl.setIcon(emptyIcon);
    jl.setVisible(true);
    Component c=new Component(){
{
        jl.setSize(jl.getPreferredSize());
        jl.setLocation(0,0);
        objectComponent.setSize(objectComponent.getPreferredSize());
        objectComponent.setLocation(jl.getWidth(),0);
        setSize(jl.getWidth() + objectComponent.getWidth(),Math.max(jl.getHeight(),objectComponent.getHeight()));
      }
      @Override public void paint(      Graphics g){
        jl.paint(g);
        int translatex=jl.getWidth();
        g.translate(translatex,0);
        objectComponent.paint(g);
        g.translate(-translatex,0);
      }
    }
;
    return c;
  }
 else   if (column == 1) {
    theTwo.setText(value.toString());
    return theTwo;
  }
 else {
    return objectRenderer.getTableCellRendererComponent(table,value,false,false,row,column);
  }
}

Fixed version (ground truth):
@Override public Component getTableCellRendererComponent(JTable table,Object value,boolean isSelected,boolean hasFocus,final int row,final int column){
  if (value instanceof RecordContainer) {
    final Component objectComponent=objectRenderer.getTableCellRendererComponent(table,value,isSelected,hasFocus,row,column);
    final JLabel jl=theOne;
    Record rec=((RecordContainer)value).getRecord(genericPlaceholder);
switch (rec.getType()) {
case FOLDER:
case FOLDER_LINK:
      jl.setIcon(folderIcon);
    break;
case FILE:
case FILE_LINK:
  jl.setIcon(documentIcon);
break;
case BROKEN_LINK:
jl.setIcon(emptyIcon);
break;
default :
throw new RuntimeException("String_Node_Str" + rec.getType());
}
jl.setVisible(true);
Component c=new Component(){
{
jl.setSize(jl.getPreferredSize());
jl.setLocation(0,0);
objectComponent.setSize(objectComponent.getPreferredSize());
objectComponent.setLocation(jl.getWidth(),0);
setSize(jl.getWidth() + objectComponent.getWidth(),Math.max(jl.getHeight(),objectComponent.getHeight()));
}
@Override public void paint(Graphics g){
jl.paint(g);
int translatex=jl.getWidth();
g.translate(translatex,0);
objectComponent.paint(g);
g.translate(-translatex,0);
}
}
;
return c;
}
 else if (column == 1) {
theTwo.setText(value.toString());
return theTwo;
}
 else {
return objectRenderer.getTableCellRendererComponent(table,value,false,false,row,column);
}
}
Program: 168560
Project: 168560
Buggy source:
private int getPriority(){
switch (recordType) {
case FILE:
    return 1;
case FOLDER:
  return 0;
case FILE_LINK:
return 1;
case FOLDER_LINK:
return 0;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + recordType + "String_Node_Str");
}
}

Fixed version (ground truth):
private int getPriority(){
switch (recordType) {
case FILE:
    return 1;
case FOLDER:
  return 0;
case FILE_LINK:
return 1;
case FOLDER_LINK:
return 0;
case BROKEN_LINK:
return 2;
default :
throw new RuntimeException("String_Node_Str" + "String_Node_Str" + recordType + "String_Node_Str");
}
}
Program: 168561
Project: 168561
Buggy source:
public static RecordType entryTypeToRecordType(FSEntry entry,String[] parentDirPath){
  if (entry instanceof FSFile) {
    return RecordType.FILE;
  }
 else   if (entry instanceof FSFolder) {
    return RecordType.FOLDER;
  }
 else   if (entry instanceof FSLink) {
    FSLink fsl=(FSLink)entry;
    FSEntry linkTarget=fsl.getLinkTarget(parentDirPath);
    if (linkTarget == null) {
      return RecordType.FILE;
    }
    if (linkTarget instanceof FSFile) {
      return RecordType.FILE_LINK;
    }
 else     if (linkTarget instanceof FSFolder) {
      return RecordType.FOLDER_LINK;
    }
 else     throw new IllegalArgumentException("String_Node_Str" + entry.getClass());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + entry.getClass());
  }
}

Fixed version (ground truth):
public static RecordType entryTypeToRecordType(FSEntry entry,String[] parentDirPath){
  if (entry instanceof FSFile) {
    return RecordType.FILE;
  }
 else   if (entry instanceof FSFolder) {
    return RecordType.FOLDER;
  }
 else   if (entry instanceof FSLink) {
    FSLink fsl=(FSLink)entry;
    FSEntry linkTarget=fsl.getLinkTarget(parentDirPath);
    if (linkTarget == null) {
      return RecordType.BROKEN_LINK;
    }
    if (linkTarget instanceof FSFile) {
      return RecordType.FILE_LINK;
    }
 else     if (linkTarget instanceof FSFolder) {
      return RecordType.FOLDER_LINK;
    }
 else     throw new IllegalArgumentException("String_Node_Str" + entry.getClass());
  }
 else {
    throw new IllegalArgumentException("String_Node_Str" + entry.getClass());
  }
}
Program: 168563
Project: 168563
Buggy source:
/** 
 * Looks up the FSEntry denoted by the supplied POSIX path. Since POSIX paths may be relative, a root folder is needed to resolve the relative path structure. If the POSIX pathname is absolute, the root folder parameter will not be used.
 * @param posixPath the POSIX pathname.
 * @param rootFolder the root folder from which we should start resolvingthe path.
 * @return the FSEntry corresponding to the supplied POSIX path, or <code>null</code> if no such pathname could be found.
 * @throws java.lang.IllegalArgumentException if <code>posixPath</code> isan invalid pathname.
 */
public FSEntry getEntryByPosixPath(final String posixPath,final String... rootFolderPath) throws IllegalArgumentException {
  String[] path=getTruePathFromPosixPath(posixPath,rootFolderPath);
  if (path != null)   return getEntry(path);
 else   return null;
}

Fixed version (ground truth):
/** 
 * Looks up the FSEntry denoted by the supplied POSIX path. Since POSIX paths may be relative, a root folder is needed to resolve the relative path structure. If the POSIX pathname is absolute, the root folder parameter will not be used.
 * @param posixPath the POSIX pathname.
 * @param rootFolder the root folder from which we should start resolvingthe path.
 * @return the FSEntry corresponding to the supplied POSIX path, or <code>null</code> if no such pathname could be found.
 * @throws java.lang.IllegalArgumentException if <code>posixPath</code> isan invalid pathname.
 */
public FSEntry getEntryByPosixPath(final String posixPath,final String... rootFolderPath) throws IllegalArgumentException {
  final String prefix=globalPrefix;
  globalPrefix+="String_Node_Str";
  try {
    System.err.println(prefix + "String_Node_Str" + posixPath+ "String_Node_Str"+ Util.concatenateStrings(rootFolderPath,"String_Node_Str")+ "String_Node_Str");
    String[] path=getTruePathFromPosixPath(posixPath,rootFolderPath);
    if (path != null) {
      System.err.println(prefix + "String_Node_Str" + Util.concatenateStrings(path,"String_Node_Str"));
      return getEntry(path);
    }
 else     return null;
  }
  finally {
    System.err.println(prefix + "String_Node_Str");
    globalPrefix=prefix;
  }
}
Program: 168564
Project: 168564
Buggy source:
/** 
 * {@inheritDoc}
 */
@Override public FSEntry getLinkTarget(String[] parentDir){
  String posixPath=getLinkTargetPosixPath();
  FSEntry res=fsHandler.getEntryByPosixPath(posixPath,parentDir);
  if (res == null) {
    System.err.println("String_Node_Str");
    System.err.println("String_Node_Str" + posixPath + "String_Node_Str");
    System.err.println("String_Node_Str" + Util.concatenateStrings(parentDir,"String_Node_Str") + "String_Node_Str");
  }
  return res;
}

Fixed version (ground truth):
/** 
 * {@inheritDoc}
 */
@Override public FSEntry getLinkTarget(String[] parentDir){
  String prefix=parentFileSystem.globalPrefix;
  parentFileSystem.globalPrefix+="String_Node_Str";
  try {
    System.err.println(prefix + "String_Node_Str" + Util.concatenateStrings(parentDir,"String_Node_Str")+ "String_Node_Str");
    String posixPath=getLinkTargetPosixPath();
    System.err.println(prefix + "String_Node_Str" + posixPath+ "String_Node_Str");
    FSEntry res=fsHandler.getEntryByPosixPath(posixPath,parentDir);
    if (res == null) {
      System.err.println(prefix + "String_Node_Str");
      System.err.println(prefix + "String_Node_Str" + posixPath+ "String_Node_Str");
      System.err.println(prefix + "String_Node_Str" + Util.concatenateStrings(parentDir,"String_Node_Str")+ "String_Node_Str");
    }
    return res;
  }
  finally {
    System.err.println(prefix + "String_Node_Str");
    parentFileSystem.globalPrefix=prefix;
  }
}
Program: 168566
Project: 168566
Buggy source:
public CommonHFSCatalogLeafRecord getRecord(CommonHFSCatalogNodeID parentID,CommonHFSCatalogString nodeName){
  CatalogInitProcedure init=new CatalogInitProcedure();
  final int nodeSize=init.bthr.getNodeSize();
  long currentNodeOffset=init.bthr.getRootNodeNumber() * nodeSize;
  byte[] currentNodeData=new byte[init.bthr.getNodeSize()];
  init.catalogFile.seek(currentNodeOffset);
  init.catalogFile.readFully(currentNodeData);
  CommonBTNodeDescriptor nodeDescriptor=createCommonBTNodeDescriptor(currentNodeData,0);
  while (nodeDescriptor.getNodeType() == NodeType.INDEX) {
    CommonHFSCatalogIndexNode currentNode=catOps.newCatalogIndexNode(currentNodeData,0,nodeSize,init.bthr);
    CommonBTIndexRecord matchingRecord=findLEKey(currentNode,catOps.newCatalogKey(parentID,nodeName,init.bthr));
    currentNodeOffset=matchingRecord.getIndex() * nodeSize;
    init.catalogFile.seek(currentNodeOffset);
    init.catalogFile.readFully(currentNodeData);
    nodeDescriptor=createCommonBTNodeDescriptor(currentNodeData,0);
  }
  if (nodeDescriptor.getNodeType() == NodeType.LEAF) {
    CommonHFSCatalogLeafNode leaf=catOps.newCatalogLeafNode(currentNodeData,0,init.bthr.getNodeSize(),init.bthr);
    CommonHFSCatalogLeafRecord[] recs=leaf.getLeafRecords();
    for (    CommonHFSCatalogLeafRecord rec : recs)     if (rec.getKey().compareTo(catOps.newCatalogKey(parentID,nodeName,init.bthr)) == 0)     return rec;
    return null;
  }
 else   throw new RuntimeException("String_Node_Str" + nodeDescriptor.getNodeType());
}

Fixed version (ground truth):
public CommonHFSCatalogLeafRecord getRecord(CommonHFSCatalogNodeID parentID,CommonHFSCatalogString nodeName){
  CatalogInitProcedure init=new CatalogInitProcedure();
  final int nodeSize=init.bthr.getNodeSize();
  long currentNodeOffset=init.bthr.getRootNodeNumber() * nodeSize;
  byte[] currentNodeData=new byte[init.bthr.getNodeSize()];
  init.catalogFile.seek(currentNodeOffset);
  init.catalogFile.readFully(currentNodeData);
  CommonBTNodeDescriptor nodeDescriptor=createCommonBTNodeDescriptor(currentNodeData,0);
  while (nodeDescriptor.getNodeType() == NodeType.INDEX) {
    CommonHFSCatalogIndexNode currentNode=catOps.newCatalogIndexNode(currentNodeData,0,nodeSize,init.bthr);
    CommonBTIndexRecord matchingRecord=findLEKey(currentNode,catOps.newCatalogKey(parentID,nodeName,init.bthr));
    if (matchingRecord == null)     return null;
    currentNodeOffset=matchingRecord.getIndex() * nodeSize;
    init.catalogFile.seek(currentNodeOffset);
    init.catalogFile.readFully(currentNodeData);
    nodeDescriptor=createCommonBTNodeDescriptor(currentNodeData,0);
  }
  if (nodeDescriptor.getNodeType() == NodeType.LEAF) {
    CommonHFSCatalogLeafNode leaf=catOps.newCatalogLeafNode(currentNodeData,0,init.bthr.getNodeSize(),init.bthr);
    CommonHFSCatalogLeafRecord[] recs=leaf.getLeafRecords();
    for (    CommonHFSCatalogLeafRecord rec : recs)     if (rec.getKey().compareTo(catOps.newCatalogKey(parentID,nodeName,init.bthr)) == 0)     return rec;
    return null;
  }
 else   throw new RuntimeException("String_Node_Str" + nodeDescriptor.getNodeType());
}
Program: 168568
Project: 168568
Buggy source:
private CommonHFSCatalogFolderRecord lookupParentFolderRecord(CommonHFSCatalogLeafRecord childRecord){
  CommonHFSCatalogNodeID parentID=childRecord.getKey().getParentID();
  CommonHFSCatalogLeafRecord parent=view.getRecord(parentID,view.getEmptyString());
  if (parent == null) {
    if (parentID.toLong() == 1)     return null;
 else     throw new RuntimeException("String_Node_Str" + parentID.toLong() + "String_Node_Str");
  }
  if (parent instanceof CommonHFSCatalogFolderThreadRecord) {
    CommonHFSCatalogFolderThread data=((CommonHFSCatalogFolderThreadRecord)parent).getData();
    CommonHFSCatalogLeafRecord rec=view.getRecord(data.getParentID(),data.getNodeName());
    if (rec instanceof CommonHFSCatalogFolderRecord)     return (CommonHFSCatalogFolderRecord)rec;
 else     throw new RuntimeException("String_Node_Str" + "String_Node_Str" + rec.getClass());
  }
 else   if (parent instanceof CommonHFSCatalogFileThreadRecord) {
    throw new RuntimeException("String_Node_Str" + parentID + "String_Node_Str");
  }
 else {
    throw new RuntimeException("String_Node_Str" + parentID + "String_Node_Str"+ parent.getClass()+ "String_Node_Str");
  }
}

Fixed version (ground truth):
private CommonHFSCatalogFolderRecord lookupParentFolderRecord(CommonHFSCatalogLeafRecord childRecord){
  CommonHFSCatalogNodeID parentID=childRecord.getKey().getParentID();
  CommonHFSCatalogLeafRecord parent=view.getRecord(parentID,view.getEmptyString());
  if (parent == null) {
    if (parentID.toLong() == 1)     return null;
 else     throw new RuntimeException("String_Node_Str" + parentID.toLong() + "String_Node_Str");
  }
  if (parent instanceof CommonHFSCatalogFolderThreadRecord) {
    CommonHFSCatalogFolderThread data=((CommonHFSCatalogFolderThreadRecord)parent).getData();
    CommonHFSCatalogLeafRecord rec=view.getRecord(data.getParentID(),data.getNodeName());
    if (rec == null)     return null;
 else     if (rec instanceof CommonHFSCatalogFolderRecord)     return (CommonHFSCatalogFolderRecord)rec;
 else     throw new RuntimeException("String_Node_Str" + "String_Node_Str" + rec.getClass());
  }
 else   if (parent instanceof CommonHFSCatalogFileThreadRecord) {
    throw new RuntimeException("String_Node_Str" + parentID + "String_Node_Str");
  }
 else {
    throw new RuntimeException("String_Node_Str" + parentID + "String_Node_Str"+ parent.getClass()+ "String_Node_Str");
  }
}
Program: 168569
Project: 168569
Buggy source:
@Override public boolean existsPartitionSystem(){
  try {
    ReadableRandomAccessStream llf=data.createReadOnlyFile();
    byte[] secondBlock=new byte[512];
    llf.seek(512);
    llf.readFully(secondBlock);
    GPTHeader gh=new GPTHeader(secondBlock,0);
    if (gh.isValid()) {
      return true;
    }
  }
 catch (  Exception e) {
  }
  return false;
}

Fixed version (ground truth):
@Override public boolean existsPartitionSystem(){
  try {
    ReadableRandomAccessStream llf=data.createReadOnlyFile();
    byte[] secondBlock=new byte[512];
    llf.seek(512);
    llf.readFully(secondBlock);
    GPTHeader gh=new GPTHeader(secondBlock,0,512);
    if (gh.isValid()) {
      return true;
    }
  }
 catch (  Exception e) {
  }
  return false;
}
Program: 168570
Project: 168570
Buggy source:
public byte[] getBytes(){
  byte[] result=new byte[512];
  byte[] curData;
  int i=0;
  System.arraycopy(reserved1,0,result,i,reserved1.length);
  i+=reserved1.length;
  System.arraycopy(optIBMBootmgrEntry,0,result,i,optIBMBootmgrEntry.length);
  i+=optIBMBootmgrEntry.length;
  System.arraycopy(reserved2,0,result,i,reserved2.length);
  i+=reserved2.length;
  System.arraycopy(optDiskSignature,0,result,i,optDiskSignature.length);
  i+=optDiskSignature.length;
  curData=firstEntry.getBytes();
  System.arraycopy(curData,0,result,i,curData.length);
  i+=curData.length;
  curData=secondEntry.getBytes();
  System.arraycopy(curData,0,result,i,curData.length);
  i+=curData.length;
  System.arraycopy(reserved4,0,result,i,reserved4.length);
  i+=reserved4.length;
  System.arraycopy(mbrSignature,0,result,i,mbrSignature.length);
  i+=mbrSignature.length;
  if (i != result.length)   throw new RuntimeException("String_Node_Str");
  return result;
}

Fixed version (ground truth):
public byte[] getBytes(){
  byte[] result=new byte[512];
  byte[] curData;
  int i=0;
  System.arraycopy(reserved1,0,result,i,reserved1.length);
  i+=reserved1.length;
  System.arraycopy(optIBMBootmgrEntry,0,result,i,optIBMBootmgrEntry.length);
  i+=optIBMBootmgrEntry.length;
  System.arraycopy(reserved2,0,result,i,reserved2.length);
  i+=reserved2.length;
  System.arraycopy(optDiskSignature,0,result,i,optDiskSignature.length);
  i+=optDiskSignature.length;
  System.arraycopy(reserved3,0,result,i,reserved3.length);
  i+=reserved3.length;
  curData=firstEntry.getBytes();
  System.arraycopy(curData,0,result,i,curData.length);
  i+=curData.length;
  curData=secondEntry.getBytes();
  System.arraycopy(curData,0,result,i,curData.length);
  i+=curData.length;
  System.arraycopy(reserved4,0,result,i,reserved4.length);
  i+=reserved4.length;
  System.arraycopy(mbrSignature,0,result,i,mbrSignature.length);
  i+=mbrSignature.length;
  if (i != result.length)   throw new RuntimeException("String_Node_Str");
  return result;
}
Program: 168571
Project: 168571
Buggy source:
public void printFields(PrintStream ps,String prefix){
  ps.println(prefix + "String_Node_Str" + Util.toHexStringBE(getOptionalDiskSignature())+ "String_Node_Str");
  for (int i=0; i < partitions.length; ++i) {
    ps.println(prefix + "String_Node_Str" + i+ "String_Node_Str");
    if (partitions[i].isValid()) {
      partitions[i].print(ps,prefix + "String_Node_Str");
    }
 else     ps.println(prefix + "String_Node_Str");
  }
  ps.println(prefix + "String_Node_Str" + Util.toHexStringBE(getMBRSignature()));
}

Fixed version (ground truth):
public void printFields(PrintStream ps,String prefix){
  ps.println(prefix + "String_Node_Str" + Util.toHexStringBE(getOptionalDiskSignature())+ "String_Node_Str");
  ps.println(prefix + "String_Node_Str");
  for (int i=0; i < partitions.length; ++i) {
    ps.println(prefix + "String_Node_Str" + i+ "String_Node_Str");
    if (partitions[i].isValid()) {
      partitions[i].print(ps,prefix + "String_Node_Str");
    }
 else     ps.println(prefix + "String_Node_Str");
  }
  ps.println(prefix + "String_Node_Str" + Util.toHexStringBE(getMBRSignature()));
}
Program: 168572
Project: 168572
Buggy source:
public static int unsignedArrayCompare(char[] a,int aoff,int alen,char[] b,int boff,int blen){
  int compareLen=Math.max(alen,blen);
  for (int i=0; i < compareLen; ++i) {
    int curA=a[aoff + i] & 0xFFFF;
    int curB=b[boff + i] & 0xFFFF;
    if (curA != curB)     return curA - curB;
  }
  return alen - blen;
}

Fixed version (ground truth):
public static int unsignedArrayCompare(char[] a,int aoff,int alen,char[] b,int boff,int blen){
  int compareLen=Math.min(alen,blen);
  for (int i=0; i < compareLen; ++i) {
    int curA=a[aoff + i] & 0xFFFF;
    int curB=b[boff + i] & 0xFFFF;
    if (curA != curB)     return curA - curB;
  }
  return alen - blen;
}
Program: 168573
Project: 168573
Buggy source:
public static boolean arraysEqual(Object[] a,Object[] b){
  if (a.length != b.length)   return false;
 else {
    for (int i=0; i < a.length; ++i)     if (!a[i].equals(b[i]))     return false;
    return true;
  }
}

Fixed version (ground truth):
public static boolean arraysEqual(Object[] a,Object[] b){
  return arrayRegionsEqual(a,0,a.length,b,0,b.length);
}
Program: 168574
Project: 168574
Buggy source:
public void setStartingLBA(long i){
  Util.arrayCopy(Util.toByteArrayBE(i),startingLBA);
}

Fixed version (ground truth):
public void setStartingLBA(long i){
  Util.arrayCopy(Util.toByteArrayLE(i),startingLBA);
}
Program: 168575
Project: 168575
Buggy source:
public void setEndingLBA(long i){
  Util.arrayCopy(Util.toByteArrayBE(i),endingLBA);
}

Fixed version (ground truth):
public void setEndingLBA(long i){
  Util.arrayCopy(Util.toByteArrayLE(i),endingLBA);
}
Program: 168576
Project: 168576
Buggy source:
public void printFields(PrintStream ps,String prefix){
  printPartitionInfo(ps,prefix + "String_Node_Str");
}

Fixed version (ground truth):
public void printFields(PrintStream ps,String prefix){
  printPartitionInfo(ps,prefix + "String_Node_Str");
  ps.println(prefix + "String_Node_Str");
  ps.println(prefix + "String_Node_Str" + getStartOffset());
  ps.println(prefix + "String_Node_Str" + getLength());
  ps.println(prefix + "String_Node_Str" + getType());
}
Program: 168577
Project: 168577
Buggy source:
public long getStartOffset(){
  return (getPmPyPartStart() + getPmLgDataStart()) * blockSize;
}

Fixed version (ground truth):
public long getStartOffset(){
  return (Util.unsign(getPmPyPartStart()) + Util.unsign(getPmLgDataStart())) * blockSize;
}
Program: 168578
Project: 168578
Buggy source:
public long getLength(){
  return getPmDataCnt() * blockSize;
}

Fixed version (ground truth):
public long getLength(){
  return Util.unsign(getPmDataCnt()) * blockSize;
}
Program: 168579
Project: 168579
Buggy source:
public ApplePartitionMap(LowLevelFile isoRaf,long pmOffset,int blockSize){
  isoRaf.seek(pmOffset);
  byte[] currentBlock=new byte[blockSize];
  ArrayList<APMPartition> partitionList=new ArrayList<APMPartition>();
  while (true) {
    isoRaf.readFully(currentBlock);
    if ((currentBlock[0] & 0xFF) == 0x50 && (currentBlock[1] & 0xFF) == 0x4D) {
      APMPartition p=new APMPartition(currentBlock,0,blockSize);
      partitionList.add(p);
    }
 else     break;
  }
  partitions=partitionList.toArray(new APMPartition[partitionList.size()]);
}

Fixed version (ground truth):
public ApplePartitionMap(byte[] data,int off,int blockSize){
  byte[] currentBlock=new byte[blockSize];
  ArrayList<APMPartition> partitionList=new ArrayList<APMPartition>();
  while (true) {
    System.arraycopy(data,off,currentBlock,0,currentBlock.length);
    off+=currentBlock.length;
    if ((currentBlock[0] & 0xFF) == 0x50 && (currentBlock[1] & 0xFF) == 0x4D) {
      APMPartition p=new APMPartition(currentBlock,0,blockSize);
      partitionList.add(p);
    }
 else     break;
  }
  partitions=partitionList.toArray(new APMPartition[partitionList.size()]);
}
Program: 168580
Project: 168580
Buggy source:
public static int length(){
  return 268;
}

Fixed version (ground truth):
public static int length(){
  return 269;
}
Program: 168581
Project: 168581
Buggy source:
public int getSbBlkCount(){
  return Util.readIntBE(sbBlkCount);
}

Fixed version (ground truth):
/** 
 * Number of blocks on the device. 
 */
public int getSbBlkCount(){
  return Util.readIntBE(sbBlkCount);
}
Program: 168582
Project: 168582
Buggy source:
public short getSbSig(){
  return Util.readShortBE(sbSig);
}

Fixed version (ground truth):
/** 
 * Device signature. (Should be "ER"...) 
 */
public short getSbSig(){
  return Util.readShortBE(sbSig);
}
Program: 168583
Project: 168583
Buggy source:
public short getSbBlkSize(){
  return Util.readShortBE(sbBlkSize);
}

Fixed version (ground truth):
/** 
 * Block size of the device. 
 */
public short getSbBlkSize(){
  return Util.readShortBE(sbBlkSize);
}
Program: 168584
Project: 168584
Buggy source:
public short getSbDrvrCount(){
  return Util.readShortBE(sbDrvrCount);
}

Fixed version (ground truth):
/** 
 * Number of driver descriptor entries. 
 */
public short getSbDrvrCount(){
  return Util.readShortBE(sbDrvrCount);
}
Program: 168585
Project: 168585
Buggy source:
public short getReserved1(){
  return Util.readShortBE(reserved1);
}

Fixed version (ground truth):
/** 
 * Reserved. 
 */
public short getReserved1(){
  return Util.readShortBE(reserved1);
}
Program: 168586
Project: 168586
Buggy source:
public int getReserved3(){
  return Util.readIntBE(reserved3);
}

Fixed version (ground truth):
/** 
 * Reserved. 
 */
public int getReserved3(){
  return Util.readIntBE(reserved3);
}
Program: 168587
Project: 168587
Buggy source:
public void printFields(PrintStream ps,String prefix){
  ps.println(prefix + "String_Node_Str" + getSbSig());
  ps.println(prefix + "String_Node_Str" + getSbBlkSize());
  ps.println(prefix + "String_Node_Str" + getSbBlkCount());
  ps.println(prefix + "String_Node_Str" + getReserved1());
  ps.println(prefix + "String_Node_Str" + getReserved2());
  ps.println(prefix + "String_Node_Str" + getReserved3());
  ps.println(prefix + "String_Node_Str" + getSbDrvrCount());
  ps.println(prefix + "String_Node_Str");
  getFirstEntry().print(ps,prefix + "String_Node_Str");
  ps.println(prefix + "String_Node_Str");
  getBabab().print(ps,prefix + "String_Node_Str");
  ps.println(prefix + "String_Node_Str" + getReserved4());
}

Fixed version (ground truth):
public void printFields(PrintStream ps,String prefix){
  ps.println(prefix + "String_Node_Str" + getSbSigAsString()+ "String_Node_Str");
  ps.println(prefix + "String_Node_Str" + getSbBlkSize());
  ps.println(prefix + "String_Node_Str" + getSbBlkCount());
  ps.println(prefix + "String_Node_Str" + getReserved1());
  ps.println(prefix + "String_Node_Str" + getReserved2());
  ps.println(prefix + "String_Node_Str" + getReserved3());
  ps.println(prefix + "String_Node_Str" + getSbDrvrCount());
  ps.println(prefix + "String_Node_Str" + entries.length+ "String_Node_Str");
  for (int i=0; i < entries.length; ++i) {
    ps.println(prefix + "String_Node_Str" + i+ "String_Node_Str");
    entries[i].print(ps,prefix + "String_Node_Str");
  }
  if (entries.length == 0)   ps.println(prefix + "String_Node_Str");
  ps.println(prefix + "String_Node_Str" + ddPad.length+ "String_Node_Str");
}
Program: 168588
Project: 168588
Buggy source:
public DriverDescriptorRecord(byte[] data,int offset){
  System.arraycopy(data,offset + 0,sbSig,0,2);
  System.arraycopy(data,offset + 2,sbBlkSize,0,2);
  System.arraycopy(data,offset + 4,sbBlkCount,0,4);
  System.arraycopy(data,offset + 8,reserved1,0,2);
  System.arraycopy(data,offset + 10,reserved2,0,2);
  System.arraycopy(data,offset + 12,reserved3,0,4);
  System.arraycopy(data,offset + 16,sbDrvrCount,0,2);
  firstEntry=new DriverDescriptorEntry(data,offset + 18);
  babab=new DriverDescriptorEntry(data,offset + 26);
  System.arraycopy(data,offset + 266,reserved4,0,2);
}

Fixed version (ground truth):
public DriverDescriptorRecord(byte[] data,int offset){
  System.arraycopy(data,offset + 0,sbSig,0,2);
  System.arraycopy(data,offset + 2,sbBlkSize,0,2);
  System.arraycopy(data,offset + 4,sbBlkCount,0,4);
  System.arraycopy(data,offset + 8,reserved1,0,2);
  System.arraycopy(data,offset + 10,reserved2,0,2);
  System.arraycopy(data,offset + 12,reserved3,0,4);
  System.arraycopy(data,offset + 16,sbDrvrCount,0,2);
  entries=new DriverDescriptorEntry[getSbDrvrCount()];
  int i;
  for (i=0; i < entries.length; ++i)   entries[i]=new DriverDescriptorEntry(data,offset + 18 + DriverDescriptorEntry.length() * i);
  int padOffset=offset + 18 + DriverDescriptorEntry.length() * i;
  ddPad=new byte[length() - padOffset];
  System.arraycopy(data,padOffset,ddPad,0,ddPad.length);
}
Program: 168589
Project: 168589
Buggy source:
public short getReserved2(){
  return Util.readShortBE(reserved2);
}

Fixed version (ground truth):
/** 
 * Reserved. 
 */
public short getReserved2(){
  return Util.readShortBE(reserved2);
}
Program: 168590
Project: 168590
Buggy source:
public long getStartOffset(){
  return getLBAFirstSector() * sectorSize;
}

Fixed version (ground truth):
public long getStartOffset(){
  return Util.unsign(getLBAFirstSector()) * sectorSize;
}
Program: 168591
Project: 168591
Buggy source:
public long getLength(){
  return getLBAPartitionLength() * sectorSize;
}

Fixed version (ground truth):
public long getLength(){
  return Util.unsign(getLBAPartitionLength()) * sectorSize;
}
Program: 168592
Project: 168592
Buggy source:
public void seek(long pos){
  try {
    raf.seek(pos);
  }
 catch (  IOException ioe) {
    throw new RuntimeException("String_Node_Str" + pos + "String_Node_Str"+ ioe.getMessage(),ioe);
  }
}

Fixed version (ground truth):
public void seek(long pos){
  try {
    raf.seek(pos);
  }
 catch (  IOException ioe) {
    throw new RuntimeException("String_Node_Str" + pos + "String_Node_Str"+ ioe.toString(),ioe);
  }
}
Program: 168594
Project: 168594
Buggy source:
public RecordNodeStorage(HFSPlusCatalogLeafRecord record){
  this.record=record;
  if (record.getData().getRecordType() != HFSPlusCatalogLeafRecordData.RECORD_TYPE_FOLDER && record.getData().getRecordType() != HFSPlusCatalogLeafRecordData.RECORD_TYPE_FOLDER_THREAD)   throw new IllegalArgumentException("String_Node_Str");
}

Fixed version (ground truth):
public RecordNodeStorage(HFSPlusCatalogLeafRecord parentRecord){
  this.parentRecord=parentRecord;
  if (parentRecord.getData().getRecordType() != HFSPlusCatalogLeafRecordData.RECORD_TYPE_FOLDER)   throw new IllegalArgumentException("String_Node_Str");
}
Program: 168595
Project: 168595
Buggy source:
public HFSPlusCatalogLeafRecord getRecord(){
  return record;
}

Fixed version (ground truth):
public HFSPlusCatalogLeafRecord getRecord(){
  return parentRecord;
}
Program: 168596
Project: 168596
Buggy source:
private void populateFilesystemGUI(HFSPlusCatalogLeafRecord[] contents){
  DefaultMutableTreeNode rootNode=new NoLeafMutableTreeNode("String_Node_Str");
  populateNode(rootNode,contents);
  DefaultTreeModel model=new DefaultTreeModel(rootNode);
  dirTree.setModel(model);
  populateTable(contents);
  addressField.setText("String_Node_Str");
}

Fixed version (ground truth):
private void populateFilesystemGUI(HFSPlusCatalogLeafRecord root,HFSPlusCatalogLeafRecord[] contents){
  DefaultMutableTreeNode rootNode=new NoLeafMutableTreeNode(new RecordNodeStorage(root));
  populateNode(rootNode,contents);
  DefaultTreeModel model=new DefaultTreeModel(rootNode);
  dirTree.setModel(model);
  populateTable(contents);
  addressField.setText("String_Node_Str");
}
Program: 168599
Project: 168599
Buggy source:
public String toString(){
  HFSPlusCatalogLeafRecordData recData=record.getData();
  if (recData.getRecordType() == HFSPlusCatalogLeafRecordData.RECORD_TYPE_FOLDER)   return record.getKey().getNodeName().toString();
 else   if (recData.getRecordType() == HFSPlusCatalogLeafRecordData.RECORD_TYPE_FOLDER_THREAD && recData instanceof HFSPlusCatalogThread)   return ((HFSPlusCatalogThread)recData).getNodeName().toString();
 else   throw new RuntimeException("String_Node_Str");
}

Fixed version (ground truth):
public String toString(){
  HFSPlusCatalogLeafRecordData recData=parentRecord.getData();
  return parentRecord.getKey().getNodeName().toString();
}
Program: 168600
Project: 168600
Buggy source:
private double distanceFromSky(int itemIndex){
  C cell=positioner.getVisibleCell(itemIndex);
  return gravity.get() == Gravity.FRONT ? sizeTracker.getViewportLength() - orientation.maxY(cell) : orientation.minY(cell);
}

Fixed version (ground truth):
private double distanceFromSky(int itemIndex){
  C cell=positioner.getVisibleCell(itemIndex);
  int lastIndex=cellListManager.getLazyCellList().size() - 1;
  return gravity.get() == Gravity.FRONT ? itemIndex == lastIndex ? 0 : sizeTracker.getViewportLength() - orientation.maxY(cell) : orientation.minY(cell);
}
Program: 168601
Project: 168601
Buggy source:
@Override public TargetPosition transformByChange(int pos,int removedSize,int addedSize){
  if (itemIndex >= pos + removedSize) {
    return new MinDistanceTo(itemIndex - removedSize + addedSize,minY,maxY);
  }
 else   if (itemIndex >= pos) {
    return new MinDistanceTo(pos,Offset.fromStart(0.0),Offset.fromEnd(0.0));
  }
 else {
    return this;
  }
}

Fixed version (ground truth):
@Override public TargetPosition transformByChange(int pos,int removedSize,int addedSize){
  if (itemIndex >= pos + removedSize) {
    return new MinDistanceTo(itemIndex - removedSize + addedSize,minY,maxY);
  }
 else   if (itemIndex >= pos) {
    if (addedSize == removedSize) {
      return this;
    }
 else {
      return new MinDistanceTo(pos,Offset.fromStart(0.0),Offset.fromEnd(0.0));
    }
  }
 else {
    return this;
  }
}
Program: 168602
Project: 168602
Buggy source:
/** 
 * Recursively persist the array and all its object's children.
 * @throws JSONException when something went wrong through parsing, this also fails the database transaction and results in no data changes
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public <IdType>List<IdType> persistArrayApi11(Class<?> modelClass,JSONArray jsonArray) throws JSONException {
  try {
    if (!mDatabase.inTransaction()) {
      mDatabase.enableWriteAheadLogging();
    }
    mDatabase.beginTransactionNonExclusive();
    List<IdType> id_list=persistArrayOfObjects(modelClass,jsonArray);
    mDatabase.setTransactionSuccessful();
    return id_list;
  }
 catch (  JSONException e) {
    throw e;
  }
 finally {
    if (mDatabase.inTransaction()) {
      mDatabase.endTransaction();
    }
  }
}

Fixed version (ground truth):
/** 
 * Recursively persist the array and all its object's children.
 * @throws JSONException when something went wrong through parsing, this also fails the database transaction and results in no data changes
 */
@TargetApi(Build.VERSION_CODES.HONEYCOMB) public <IdType>List<IdType> persistArrayApi11(Class<?> modelClass,JSONArray jsonArray) throws JSONException {
  try {
    enableWriteAheadLogging();
    mDatabase.beginTransactionNonExclusive();
    List<IdType> id_list=persistArrayOfObjects(modelClass,jsonArray);
    mDatabase.setTransactionSuccessful();
    return id_list;
  }
 catch (  JSONException e) {
    throw e;
  }
 finally {
    endTransaction();
  }
}
Program: 168603
Project: 168603
Buggy source:
private <IdType>IdType persistObjectApiDeprecate(Class<?> modelClass,JSONObject jsonObject) throws JSONException {
  try {
    mDatabase.beginTransaction();
    IdType id=persistObjectInternal(modelClass,jsonObject);
    mDatabase.setTransactionSuccessful();
    return id;
  }
  finally {
    if (mDatabase.inTransaction()) {
      mDatabase.endTransaction();
    }
  }
}

Fixed version (ground truth):
private <IdType>IdType persistObjectApiDeprecate(Class<?> modelClass,JSONObject jsonObject) throws JSONException {
  try {
    mDatabase.beginTransaction();
    IdType id=persistObjectInternal(modelClass,jsonObject);
    mDatabase.setTransactionSuccessful();
    return id;
  }
  finally {
    endTransaction();
  }
}