nus-yam/ex-repair huggingface dataset:
Program: 12818
Project: 12818
Buggy source:
protected void displayDoubleLores(WritableImage screen,int xOffset,int y,int rowAddress){
  int c1=((RAM128k)computer.getMemory()).getAuxVideoMemory().readByte(rowAddress + xOffset) & 0x0FF;
  int c2=((RAM128k)computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
  if ((y & 7) < 4) {
    c1&=15;
    c2&=15;
  }
 else {
    c1>>=4;
    c2>>=4;
  }
  PixelWriter writer=screen.getPixelWriter();
  Color color=Palette.color[c1];
  int xx=xOffset * 7;
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  color=Palette.color[c2];
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
}

Fixed version (ground truth):
protected void displayDoubleLores(WritableImage screen,int xOffset,int y,int rowAddress){
  int c1=((RAM128k)computer.getMemory()).getAuxVideoMemory().readByte(rowAddress + xOffset) & 0x0FF;
  int c2=((RAM128k)computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
  if ((y & 7) < 4) {
    c1&=15;
    c2&=15;
  }
 else {
    c1>>=4;
    c2>>=4;
  }
  PixelWriter writer=screen.getPixelWriter();
  Color color=Palette.color[FLIP_NYBBLE[c1]];
  int xx=xOffset * 14;
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  color=Palette.color[c2];
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
}
Program: 12819
Project: 12819
Buggy source:
protected void showDhgr(WritableImage screen,int xOffset,int y,int dhgrWord){
  int xx=xOffset * 7;
  PixelWriter writer=screen.getPixelWriter();
  try {
    for (int i=0; i < 7; i++) {
      Color color=Palette.color[FLIP_NYBBLE[dhgrWord & 15]];
      writer.setColor(xx++,y,color);
      writer.setColor(xx++,y,color);
      writer.setColor(xx++,y,color);
      writer.setColor(xx++,y,color);
      dhgrWord>>=4;
    }
  }
 catch (  ArrayIndexOutOfBoundsException ex) {
    Logger.getLogger(getClass().getName()).warning("String_Node_Str");
  }
}

Fixed version (ground truth):
protected void showDhgr(WritableImage screen,int xOffset,int y,int dhgrWord){
  PixelWriter writer=screen.getPixelWriter();
  try {
    for (int i=0; i < 7; i++) {
      Color color;
      if (!dhgrMode && hiresMode) {
        color=Palette.color[dhgrWord & 15];
      }
 else {
        color=Palette.color[FLIP_NYBBLE[dhgrWord & 15]];
      }
      writer.setColor(xOffset++,y,color);
      writer.setColor(xOffset++,y,color);
      writer.setColor(xOffset++,y,color);
      writer.setColor(xOffset++,y,color);
      dhgrWord>>=4;
    }
  }
 catch (  ArrayIndexOutOfBoundsException ex) {
    Logger.getLogger(getClass().getName()).warning("String_Node_Str");
  }
}
Program: 12820
Project: 12820
Buggy source:
protected void displayLores(WritableImage screen,int xOffset,int y,int rowAddress){
  int c1=((RAM128k)computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
  if ((y & 7) < 4) {
    c1&=15;
  }
 else {
    c1>>=4;
  }
  Color color=Palette.color[c1];
  PixelWriter writer=screen.getPixelWriter();
  int xx=xOffset * 7;
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
}

Fixed version (ground truth):
protected void displayLores(WritableImage screen,int xOffset,int y,int rowAddress){
  int c1=((RAM128k)computer.getMemory()).getMainMemory().readByte(rowAddress + xOffset) & 0x0FF;
  if ((y & 7) < 4) {
    c1&=15;
  }
 else {
    c1>>=4;
  }
  Color color=Palette.color[c1];
  PixelWriter writer=screen.getPixelWriter();
  int xx=xOffset * 14;
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
  writer.setColor(xx++,y,color);
}
Program: 12821
Project: 12821
Buggy source:
protected void showBW(WritableImage screen,int xOffset,int y,int dhgrWord){
  int xx=xOffset * 7;
  PixelWriter writer=screen.getPixelWriter();
  for (int i=0; i < 28; i++) {
    writer.setColor(xx++,y,(dhgrWord & 1) == 1 ? WHITE : BLACK);
    dhgrWord>>=1;
  }
}

Fixed version (ground truth):
protected void showBW(WritableImage screen,int xOffset,int y,int dhgrWord){
  int xx=xOffset;
  PixelWriter writer=screen.getPixelWriter();
  for (int i=0; i < 28; i++) {
    if (xx < 560) {
      writer.setColor(xx++,y,(dhgrWord & 1) == 1 ? WHITE : BLACK);
    }
    dhgrWord>>=1;
  }
}
Program: 12822
Project: 12822
Buggy source:
private File getDraggedFile(List<File> files){
  if (files == null || files.isEmpty()) {
    return null;
  }
  for (  File f : files) {
    if (f.isFile())     return f;
  }
  return null;
}

Fixed version (ground truth):
private File getDraggedFile(List<File> files){
  if (files == null || files.isEmpty()) {
    return null;
  }
  for (  File f : files) {
    if (f.exists())     return f;
  }
  return null;
}
Program: 12823
Project: 12823
Buggy source:
private void generateTimestamp(byte[] buffer,int offset,long date){
  Calendar c=Calendar.getInstance();
  c.setTimeInMillis(date);
  buffer[offset + 0]=0;
  buffer[offset + 1]=0;
  buffer[offset + 2]=0;
  buffer[offset + 3]=0;
}

Fixed version (ground truth):
private void generateTimestamp(byte[] buffer,int offset,long date){
  Calendar c=Calendar.getInstance();
  c.setTimeInMillis(date);
  buffer[offset + 1]=(byte)(((c.get(Calendar.YEAR) - 2000) << 1) | ((c.get(Calendar.MONTH) + 1) >> 3));
  buffer[offset + 0]=(byte)(((((c.get(Calendar.MONTH) + 1) & 7) << 5) | c.get(Calendar.DAY_OF_MONTH)) & 0x0ff);
  buffer[offset + 3]=(byte)c.get(Calendar.HOUR_OF_DAY);
  buffer[offset + 2]=(byte)c.get(Calendar.MINUTE);
}
Program: 12824
Project: 12824
Buggy source:
@Override public boolean accept(File file){
  if (file.getName().endsWith("String_Node_Str"))   return false;
  char c=file.getName().charAt(0);
  if (c == '.' || c == '~') {
    return false;
  }
  return !file.isHidden();
}

Fixed version (ground truth):
@Override public boolean accept(File file){
  if (file.getName().endsWith("String_Node_Str")) {
    return false;
  }
  char c=file.getName().charAt(0);
  if (c == '.' || c == '~') {
    return false;
  }
  return !file.isHidden();
}
Program: 12825
Project: 12825
Buggy source:
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  checkFile();
  if (block == 0) {
    generateHeader(buffer);
    for (int i=0; i < 12 && i < children.size(); i++)     generateFileEntry(buffer,4 + (i + 1) * FILE_ENTRY_SIZE,i);
  }
 else {
    int start=(block * 13) - 1;
    int end=start + 13;
    int offset=4;
    for (int i=start; i < end && i < children.size(); i++) {
      generateFileEntry(buffer,offset,i);
      offset+=FILE_ENTRY_SIZE;
    }
  }
}

Fixed version (ground truth):
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  checkFile();
  if (block == 0) {
    generateHeader(buffer);
    for (int i=0; i < 12 && i < children.size(); i++) {
      generateFileEntry(buffer,4 + (i + 1) * FILE_ENTRY_SIZE,i);
    }
  }
 else {
    int start=(block * 13) - 1;
    int end=start + 13;
    int offset=4;
    for (int i=start; i < end && i < children.size(); i++) {
      generateFileEntry(buffer,offset,i);
      offset+=FILE_ENTRY_SIZE;
    }
  }
}
Program: 12826
Project: 12826
Buggy source:
/** 
 * Generate the directory header found in the base block of a directory
 * @param buffer where to write data
 */
@SuppressWarnings("String_Node_Str") private void generateHeader(byte[] buffer){
  generateWord(buffer,0,0);
  int nextBlock=0;
  if (!additionalNodes.isEmpty())   nextBlock=additionalNodes.get(0).baseBlock;
  generateWord(buffer,0x02,nextBlock);
  buffer[4]=(byte)((baseBlock == 0x02 ? 0x0f0 : 0x0E0) + getName().length());
  generateName(buffer,5,this);
  for (int i=0x014; i <= 0x01b; i++)   buffer[i]=0;
  generateTimestamp(buffer,0x01c,getPhysicalFile().lastModified());
  buffer[0x020]=0x019;
  buffer[0x021]=0x000;
  buffer[0x022]=0x03;
  buffer[0x023]=(byte)FILE_ENTRY_SIZE;
  buffer[0x024]=(byte)0x0d;
  generateWord(buffer,0x025,children.size());
  generateWord(buffer,0x027,ownerFilesystem.freespaceBitmap.baseBlock);
  generateWord(buffer,0x029,ownerFilesystem.MAX_BLOCK);
}

Fixed version (ground truth):
/** 
 * Generate the directory header found in the base block of a directory
 * @param buffer where to write data
 */
@SuppressWarnings("String_Node_Str") private void generateHeader(byte[] buffer){
  generateWord(buffer,0,0);
  int nextBlock=0;
  if (!additionalNodes.isEmpty()) {
    nextBlock=additionalNodes.get(0).baseBlock;
  }
  generateWord(buffer,0x02,nextBlock);
  buffer[4]=(byte)((baseBlock == 0x02 ? 0x0f0 : 0x0E0) + getName().length());
  generateName(buffer,5,this);
  for (int i=0x014; i <= 0x01b; i++) {
    buffer[i]=0;
  }
  generateTimestamp(buffer,0x01c,getPhysicalFile().lastModified());
  buffer[0x020]=0x019;
  buffer[0x021]=0x000;
  buffer[0x022]=0x03;
  buffer[0x023]=(byte)FILE_ENTRY_SIZE;
  buffer[0x024]=(byte)0x0d;
  generateWord(buffer,0x025,children.size());
  generateWord(buffer,0x027,ownerFilesystem.freespaceBitmap.baseBlock);
  generateWord(buffer,0x029,ownerFilesystem.MAX_BLOCK);
}
Program: 12827
Project: 12827
Buggy source:
/** 
 * Generate the entry of a directory
 * @param buffer where to write data
 * @param offset starting offset in buffer to write
 * @param fileNumber number of file (indexed in Children array) to write
 */
private void generateFileEntry(byte[] buffer,int offset,int fileNumber) throws IOException {
  DiskNode child=children.get(fileNumber);
  buffer[offset]=(byte)((child.getType().code << 4) + child.getName().length());
  generateName(buffer,offset + 1,child);
  buffer[offset + 0x010]=(byte)((child instanceof DirectoryNode) ? 0x0f : ((FileNode)child).fileType);
  generateWord(buffer,offset + 0x011,child.getBaseBlock());
  generateWord(buffer,offset + 0x013,1 + child.additionalNodes.size());
  int length=((int)child.physicalFile.length()) & 0x0ffffff;
  generateWord(buffer,offset + 0x015,length & 0x0ffff);
  buffer[offset + 0x017]=(byte)((length >> 16) & 0x0ff);
  generateTimestamp(buffer,offset + 0x018,child.physicalFile.lastModified());
  buffer[offset + 0x01c]=0x19;
  buffer[offset + 0x01d]=0;
  buffer[offset + 0x01e]=(byte)0x0ff;
  if (child instanceof FileNode)   generateWord(buffer,offset + 0x01f,((FileNode)child).loadAddress);
  generateTimestamp(buffer,offset + 0x021,child.physicalFile.lastModified());
  generateWord(buffer,offset + 0x025,getBaseBlock());
}

Fixed version (ground truth):
/** 
 * Generate the entry of a directory
 * @param buffer where to write data
 * @param offset starting offset in buffer to write
 * @param fileNumber number of file (indexed in Children array) to write
 */
private void generateFileEntry(byte[] buffer,int offset,int fileNumber) throws IOException {
  DiskNode child=children.get(fileNumber);
  child.allocate();
  buffer[offset]=(byte)((child.getType().code << 4) + child.getName().length());
  generateName(buffer,offset + 1,child);
  buffer[offset + 0x010]=(byte)((child instanceof DirectoryNode) ? 0x0f : ((FileNode)child).fileType);
  generateWord(buffer,offset + 0x011,child.getBaseBlock());
  generateWord(buffer,offset + 0x013,child.additionalNodes.size());
  int length=((int)child.physicalFile.length()) & 0x0ffffff;
  generateWord(buffer,offset + 0x015,length & 0x0ffff);
  buffer[offset + 0x017]=(byte)((length >> 16) & 0x0ff);
  generateTimestamp(buffer,offset + 0x018,child.physicalFile.lastModified());
  buffer[offset + 0x01c]=0x19;
  buffer[offset + 0x01d]=0;
  buffer[offset + 0x01e]=(byte)0x001;
  if (child instanceof FileNode) {
    generateWord(buffer,offset + 0x01f,((FileNode)child).loadAddress);
  }
  generateTimestamp(buffer,offset + 0x021,child.physicalFile.lastModified());
  generateWord(buffer,offset + 0x025,getBaseBlock());
}
Program: 12828
Project: 12828
Buggy source:
public void refresh(){
  ownerFilesystem.deallocateEntry(this);
  doRefresh();
  allocationTime=System.currentTimeMillis();
  allocated=true;
  ownerFilesystem.allocateEntry(this);
}

Fixed version (ground truth):
public void refresh() throws IOException {
  ownerFilesystem.deallocateEntry(this);
  doRefresh();
  allocationTime=System.currentTimeMillis();
  allocated=true;
  ownerFilesystem.allocateEntry(this);
}
Program: 12829
Project: 12829
Buggy source:
@Override public void setName(String name){
  String[] parts=name.split("String_Node_Str");
  FileType t=null;
  int offset=0;
  if (parts.length > 1) {
    String extension=parts[parts.length - 1].toUpperCase();
    String[] extParts=extension.split("String_Node_Str");
    if (extParts.length == 2) {
      offset=Integer.parseInt(extParts[1],16);
      extension=extParts[0];
    }
    try {
      t=FileType.valueOf(extension);
    }
 catch (    IllegalArgumentException ex) {
      System.out.println("String_Node_Str" + extension + "String_Node_Str");
    }
    name="String_Node_Str";
    for (int i=0; i < parts.length - 1; i++) {
      name+=(i > 0 ? "String_Node_Str" + parts[i] : parts[i]);
    }
    if (extParts[extParts.length - 1].equals("String_Node_Str")) {
      name+="String_Node_Str";
    }
  }
  if (t == null) {
    t=FileType.UNKNOWN;
  }
  if (offset == 0) {
    offset=t.defaultLoadAddress;
  }
  fileType=t.code;
  loadAddress=offset;
  super.setName(name);
}

Fixed version (ground truth):
@Override public void setName(String name){
  String[] parts=name.replaceAll("String_Node_Str","String_Node_Str").split("String_Node_Str");
  FileType t=FileType.UNKNOWN;
  int offset=0;
  String prodosName=name;
  if (parts.length > 1) {
    String extension=parts[parts.length - 1].toUpperCase();
    String[] extParts=extension.split("String_Node_Str");
    if (extParts.length == 2) {
      offset=Integer.parseInt(extParts[1],16);
      extension=extParts[0];
    }
    try {
      t=FileType.valueOf(extension);
    }
 catch (    IllegalArgumentException ex) {
      System.out.println("String_Node_Str" + extension + "String_Node_Str");
    }
    prodosName="String_Node_Str";
    for (int i=0; i < parts.length - 1; i++) {
      prodosName+=(i > 0 ? "String_Node_Str" + parts[i] : parts[i]);
    }
    if (extParts[extParts.length - 1].equals("String_Node_Str")) {
      prodosName+="String_Node_Str";
    }
  }
  if (offset == 0) {
    offset=t.defaultLoadAddress;
  }
  fileType=t.code;
  loadAddress=offset;
  super.setName(prodosName);
}
Program: 12830
Project: 12830
Buggy source:
@Override public void readBlock(int block,byte[] buffer) throws IOException {
switch (this.getType()) {
case SEEDLING:
    readFile(buffer,0);
  break;
case SAPLING:
if (block > 0) {
  readFile(buffer,(block - 1));
}
 else {
  generateIndex(buffer,0,256);
}
break;
case TREE:
int dataBlocks=(int)((getPhysicalFile().length() / ProdosVirtualDisk.BLOCK_SIZE) + 1);
int treeBlocks=(dataBlocks / 256);
if (block == 0) {
generateIndex(buffer,0,treeBlocks);
}
 else if (block < treeBlocks) {
int start=treeBlocks + (block - 1 * 256);
int end=Math.min(start + 256,treeBlocks);
generateIndex(buffer,treeBlocks,end);
}
 else {
readFile(buffer,(block - treeBlocks));
}
break;
}
}

Fixed version (ground truth):
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  int dataBlocks=(int)((getPhysicalFile().length() + ProdosVirtualDisk.BLOCK_SIZE - 1) / ProdosVirtualDisk.BLOCK_SIZE);
  int treeBlocks=(((dataBlocks * 2) + (ProdosVirtualDisk.BLOCK_SIZE - 2)) / ProdosVirtualDisk.BLOCK_SIZE);
  if (treeBlocks > 1)   treeBlocks++;
switch (this.getType()) {
case SEEDLING:
    readFile(buffer,0);
  break;
case SAPLING:
if (block > 0) {
  readFile(buffer,(block - 1));
}
 else {
  generateIndex(buffer,0,dataBlocks);
}
break;
case TREE:
if (block == 0) {
System.out.println("String_Node_Str" + getName());
generateIndex(buffer,1,treeBlocks);
}
 else if (block <= treeBlocks) {
System.out.println("String_Node_Str" + block + "String_Node_Str"+ getName());
int start=treeBlocks + ((block - 1) * 256);
int end=treeBlocks + dataBlocks;
generateIndex(buffer,start,end);
}
 else {
readFile(buffer,(block - treeBlocks - 1));
}
break;
}
}
Program: 12831
Project: 12831
Buggy source:
private void generateIndex(byte[] buffer,int indexStart,int indexLimit){
  int pos=0;
  for (int i=indexStart; pos < 256 && i < indexLimit && i < additionalNodes.size(); i++, pos++) {
    buffer[pos]=(byte)(additionalNodes.get(i).baseBlock & 0x0ff);
    buffer[pos + 256]=(byte)((additionalNodes.get(i).baseBlock >> 8) & 0x0ff);
  }
}

Fixed version (ground truth):
private void generateIndex(byte[] buffer,int indexStart,int indexLimit){
  System.out.println("String_Node_Str");
  Arrays.fill(buffer,(byte)0);
  for (int i=indexStart, count=0; count < 256 && i < indexLimit && i < additionalNodes.size(); i++, count++) {
    int base=additionalNodes.get(i).baseBlock;
    System.out.print(Integer.toHexString(base) + "String_Node_Str");
    buffer[count]=(byte)(base & 0x0ff);
    buffer[count + 256]=(byte)(base >> 8);
  }
  System.out.println();
  for (int i=0; i < 256; i++) {
    System.out.printf("String_Node_Str",buffer[i] & 0x0ff);
  }
  System.out.println();
  for (int i=256; i < 512; i++) {
    System.out.printf("String_Node_Str",buffer[i] & 0x0ff);
  }
  System.out.println();
}
Program: 12832
Project: 12832
Buggy source:
@Override public EntryType getType(){
  long fileSize=getPhysicalFile().length();
  if (fileSize <= SEEDLING_MAX_SIZE) {
    setType(EntryType.SEEDLING);
    return EntryType.SEEDLING;
  }
 else   if (fileSize <= SAPLING_MAX_SIZE) {
    setType(EntryType.SAPLING);
    return EntryType.SAPLING;
  }
  setType(EntryType.TREE);
  return EntryType.TREE;
}

Fixed version (ground truth):
@Override public EntryType getType(){
  long fileSize=getPhysicalFile().length();
  if (fileSize <= SEEDLING_MAX_SIZE) {
    setType(EntryType.SEEDLING);
    return EntryType.SEEDLING;
  }
 else   if (fileSize <= SAPLING_MAX_SIZE) {
    setType(EntryType.SAPLING);
    return EntryType.SAPLING;
  }
 else {
    setType(EntryType.TREE);
    return EntryType.TREE;
  }
}
Program: 12833
Project: 12833
Buggy source:
@Override public void doAllocate() throws IOException {
  int dataBlocks=(int)((getPhysicalFile().length() / ProdosVirtualDisk.BLOCK_SIZE) + 1);
  int treeBlocks;
  if (dataBlocks > 1 && dataBlocks < 257) {
    treeBlocks=1;
  }
 else {
    treeBlocks=1 + (dataBlocks / 256);
  }
  for (int i=1; i < dataBlocks + treeBlocks; i++) {
    SubNode subNode=new SubNode(i,this);
  }
}

Fixed version (ground truth):
@Override public void doAllocate() throws IOException {
  int dataBlocks=(int)((getPhysicalFile().length() + ProdosVirtualDisk.BLOCK_SIZE - 1) / ProdosVirtualDisk.BLOCK_SIZE);
  int treeBlocks=(((dataBlocks * 2) + (ProdosVirtualDisk.BLOCK_SIZE - 2)) / ProdosVirtualDisk.BLOCK_SIZE);
  if (treeBlocks > 1)   treeBlocks++;
  System.out.println("String_Node_Str" + (dataBlocks + treeBlocks) + "String_Node_Str"+ getName()+ "String_Node_Str"+ dataBlocks+ "String_Node_Str"+ treeBlocks);
  for (int i=0; i < dataBlocks + treeBlocks; i++) {
    new SubNode(i,this);
  }
  setBaseBlock(additionalNodes.get(0).getBaseBlock());
}
Program: 12834
Project: 12834
Buggy source:
public FileNode(ProdosVirtualDisk ownerFilesystem,File file) throws IOException {
  setOwnerFilesystem(ownerFilesystem);
  setPhysicalFile(file);
}

Fixed version (ground truth):
public FileNode(ProdosVirtualDisk ownerFilesystem,File file) throws IOException {
  setOwnerFilesystem(ownerFilesystem);
  setPhysicalFile(file);
  setName(file.getName());
}
Program: 12835
Project: 12835
Buggy source:
private void init(ProdosVirtualDisk ownerFilesystem,File physicalFile,boolean root) throws IOException {
  isRoot=root;
  setPhysicalFile(physicalFile);
  setType(EntryType.SUBDIRECTORY);
  setName(physicalFile.getName());
}

Fixed version (ground truth):
private void init(ProdosVirtualDisk ownerFilesystem,File physicalFile,boolean root) throws IOException {
  isRoot=root;
  directoryEntries=new ArrayList<>();
  setPhysicalFile(physicalFile);
  setType(EntryType.SUBDIRECTORY);
  setName(physicalFile.getName());
  allocate();
}
Program: 12836
Project: 12836
Buggy source:
private void generatePointers(byte[] buffer,int prevBlock,int nextBlock){
  generateWord(buffer,0,prevBlock);
  generateWord(buffer,0x02,nextBlock);
}

Fixed version (ground truth):
private void generatePointers(byte[] buffer,int sequence){
  DiskNode prev=getNodeSequence(sequence - 1);
  DiskNode next=getNodeSequence(sequence + 1);
  generateWord(buffer,0,prev != null ? prev.getBaseBlock() : 0);
  generateWord(buffer,0x02,next != null ? next.getBaseBlock() : 0);
}
Program: 12837
Project: 12837
Buggy source:
private void generateName(byte[] buffer,int offset,DiskNode node){
  for (int i=0; i < node.getName().length(); i++) {
    buffer[offset + i]=(byte)node.getName().charAt(i);
  }
}

Fixed version (ground truth):
private void generateName(byte[] buffer,int offset,DiskNode node){
  for (int i=0; i < node.getName().length() && i < 15; i++) {
    buffer[offset + i]=(byte)node.getName().charAt(i);
  }
}
Program: 12838
Project: 12838
Buggy source:
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  Arrays.fill(buffer,(byte)0);
  checkFile();
  if (block == 0) {
    generateHeader(buffer);
    for (int i=0; i < 12 && i < children.size(); i++) {
      generateFileEntry(buffer,4 + (i + 1) * FILE_ENTRY_SIZE,i);
    }
  }
 else {
    generatePointers(buffer,getNodeSequence(block - 1).getBaseBlock(),getNodeSequence(block + 1) != null ? getNodeSequence(block + 1).getBaseBlock() : 0);
    int start=(block * 13) - 1;
    int end=start + 13;
    int offset=4;
    for (int i=start; i < end && i < children.size(); i++) {
      generateFileEntry(buffer,offset,i);
      offset+=FILE_ENTRY_SIZE;
    }
  }
}

Fixed version (ground truth):
@Override public void readBlock(int block,byte[] buffer) throws IOException {
  checkFile();
  int start=0;
  int end=0;
  int offset=4;
  generatePointers(buffer,block);
  if (block == 0) {
    generateHeader(buffer);
    offset+=FILE_ENTRY_SIZE;
    end=ENTRIES_PER_BLOCK - 1;
  }
 else {
    start=(block * ENTRIES_PER_BLOCK) - 1;
    end=start + ENTRIES_PER_BLOCK;
  }
  for (int i=start; i < end && i < directoryEntries.size(); i++, offset+=FILE_ENTRY_SIZE) {
    generateFileEntry(buffer,offset,i);
  }
}
Program: 12839
Project: 12839
Buggy source:
/** 
 * Generate the directory header found in the base block of a directory
 * @param buffer where to write data
 */
@SuppressWarnings("String_Node_Str") private void generateHeader(byte[] buffer){
  generatePointers(buffer,0,getNodeSequence(1) == null ? 0 : getNodeSequence(1).getBaseBlock());
  buffer[4]=(byte)((isRoot ? 0x0F0 : 0x0E0) | getName().length());
  generateName(buffer,5,this);
  for (int i=0x014; i <= 0x01b; i++) {
    buffer[i]=0;
  }
  if (!isRoot) {
    buffer[0x014]=0x075;
  }
  generateTimestamp(buffer,0x01c,getPhysicalFile().lastModified());
  buffer[0x020]=0x019;
  buffer[0x021]=0x000;
  buffer[0x022]=0x03;
  buffer[0x023]=(byte)FILE_ENTRY_SIZE;
  buffer[0x024]=(byte)0x0d;
  generateWord(buffer,0x025,children.size());
  if (isRoot) {
    generateWord(buffer,0x027,ownerFilesystem.freespaceBitmap.getBaseBlock());
    generateWord(buffer,0x029,ownerFilesystem.MAX_BLOCK);
  }
 else {
    generateWord(buffer,0x027,getParent().getBaseBlock());
    buffer[0x029]=(byte)(getParent().getChildren().indexOf(this) + 1);
    buffer[0x02a]=0x027;
  }
}

Fixed version (ground truth):
/** 
 * Generate the directory header found in the base block of a directory
 * @param buffer where to write data
 */
@SuppressWarnings("String_Node_Str") private void generateHeader(byte[] buffer){
  buffer[4]=(byte)((isRoot ? 0x0F0 : 0x0E0) | getName().length());
  generateName(buffer,5,this);
  if (!isRoot) {
    buffer[0x014]=0x075;
    buffer[0x015]=PRODOS_VERSION;
    buffer[0x017]=STANDARD_PERMISSIONS;
    buffer[0x018]=FILE_ENTRY_SIZE;
    buffer[0x019]=ENTRIES_PER_BLOCK;
  }
  generateTimestamp(buffer,0x01c,getPhysicalFile().lastModified());
  buffer[0x020]=PRODOS_VERSION;
  buffer[0x021]=0x000;
  buffer[0x022]=STANDARD_PERMISSIONS;
  buffer[0x023]=(byte)FILE_ENTRY_SIZE;
  buffer[0x024]=(byte)ENTRIES_PER_BLOCK;
  generateWord(buffer,0x025,directoryEntries.size() + 1);
  if (isRoot) {
    generateWord(buffer,0x027,ownerFilesystem.freespaceBitmap.getBaseBlock());
    generateWord(buffer,0x029,ownerFilesystem.MAX_BLOCK);
  }
 else {
    int indexInParent=getParent().getChildren().indexOf(this) + 2;
    int parentBlock=getParent().getNodeSequence(indexInParent / ENTRIES_PER_BLOCK).getBaseBlock();
    generateWord(buffer,0x027,parentBlock);
    buffer[0x029]=(byte)(indexInParent % ENTRIES_PER_BLOCK);
    buffer[0x02a]=(byte)FILE_ENTRY_SIZE;
  }
}
Program: 12840
Project: 12840
Buggy source:
@Override public void doAllocate() throws IOException {
  File[] files=physicalFile.listFiles(this);
  int numEntries=files.length;
  int numBlocks=1 + numEntries / 13;
  for (int i=1; i < numBlocks; i++) {
    new SubNode(i,this,getOwnerFilesystem().getNextFreeBlock());
  }
  for (  File f : files) {
    addFile(f);
  }
  Collections.sort(children,(  DiskNode o1,  DiskNode o2) -> o1.getName().compareTo(o2.getName()));
}

Fixed version (ground truth):
@Override public void doAllocate() throws IOException {
  for (int i=1; i < getBlockCount(); i++) {
    if (isRoot) {
      new SubNode(i,this,getOwnerFilesystem().getNextFreeBlock(3));
    }
 else {
      new SubNode(i,this);
    }
  }
  for (  File f : physicalFile.listFiles()) {
    addFile(f);
  }
  Collections.sort(children,(  DiskNode o1,  DiskNode o2) -> o1.getName().compareTo(o2.getName()));
}
Program: 12841
Project: 12841
Buggy source:
/** 
 * Generate the entry of a directory
 * @param buffer where to write data
 * @param offset starting offset in buffer to write
 * @param fileNumber number of file (indexed in Children array) to write
 */
private void generateFileEntry(byte[] buffer,int offset,int fileNumber) throws IOException {
  DiskNode child=children.get(fileNumber);
  buffer[offset]=(byte)((child.getType().code << 4) + child.getName().length());
  generateName(buffer,offset + 1,child);
  buffer[offset + 0x010]=(byte)((child instanceof DirectoryNode) ? 0x0f : ((FileNode)child).fileType);
  generateWord(buffer,offset + 0x011,child.getBaseBlock());
  generateWord(buffer,offset + 0x013,child.additionalNodes.size());
  int length=((int)child.physicalFile.length()) & 0x0ffffff;
  generateWord(buffer,offset + 0x015,length & 0x0ffff);
  buffer[offset + 0x017]=(byte)((length >> 16) & 0x0ff);
  generateTimestamp(buffer,offset + 0x018,child.physicalFile.lastModified());
  buffer[offset + 0x01c]=0x19;
  buffer[offset + 0x01d]=0;
  buffer[offset + 0x01e]=(byte)0x001;
  if (child instanceof FileNode) {
    generateWord(buffer,offset + 0x01f,((FileNode)child).loadAddress);
  }
  generateTimestamp(buffer,offset + 0x021,child.physicalFile.lastModified());
  generateWord(buffer,offset + 0x025,getBaseBlock());
}

Fixed version (ground truth):
/** 
 * Generate the entry of a directory
 * @param buffer where to write data
 * @param offset starting offset in buffer to write
 * @param fileNumber number of file (indexed in Children array) to write
 */
private void generateFileEntry(byte[] buffer,int offset,int fileNumber) throws IOException {
  DiskNode child=directoryEntries.get(fileNumber);
  buffer[offset]=(byte)((child.getType().code << 4) | child.getName().length());
  generateName(buffer,offset + 1,child);
  buffer[offset + 0x010]=(byte)((child instanceof DirectoryNode) ? 0x0f : ((FileNode)child).fileType);
  generateWord(buffer,offset + 0x011,child.getBaseBlock());
  generateWord(buffer,offset + 0x013,child.additionalNodes.size() + 1);
  int length=child.getLength();
  length&=0x0ffffff;
  generateWord(buffer,offset + 0x015,length & 0x0ffff);
  buffer[offset + 0x017]=(byte)((length >> 16) & 0x0ff);
  generateTimestamp(buffer,offset + 0x018,child.physicalFile.lastModified());
  buffer[offset + 0x01c]=PRODOS_VERSION;
  buffer[offset + 0x01d]=0;
  buffer[offset + 0x01e]=STANDARD_PERMISSIONS;
  if (child instanceof FileNode) {
    generateWord(buffer,offset + 0x01f,((FileNode)child).loadAddress);
  }
  generateTimestamp(buffer,offset + 0x021,child.physicalFile.lastModified());
  generateWord(buffer,offset + 0x025,getBaseBlock());
}
Program: 12842
Project: 12842
Buggy source:
private void addFile(File file){
  try {
    if (file.isDirectory()) {
      addChild(new DirectoryNode(getOwnerFilesystem(),file,false));
    }
 else {
      addChild(new FileNode(getOwnerFilesystem(),file));
    }
  }
 catch (  IOException ex) {
    Logger.getLogger(DirectoryNode.class.getName()).log(Level.SEVERE,null,ex);
  }
}

Fixed version (ground truth):
private void addFile(File file){
  if (!hasChildNamed(file.getName())) {
    try {
      if (file.isDirectory()) {
        addFileEntry(new DirectoryNode(getOwnerFilesystem(),file,false));
      }
 else {
        addFileEntry(new FileNode(getOwnerFilesystem(),file));
      }
    }
 catch (    IOException ex) {
      Logger.getLogger(DirectoryNode.class.getName()).log(Level.SEVERE,null,ex);
    }
  }
}
Program: 12843
Project: 12843
Buggy source:
@Override public boolean checkFile() throws IOException {
  boolean success=true;
  if (!super.checkFile()) {
    return false;
  }
  HashSet<String> realFiles=new HashSet<>();
  File[] realFileList=physicalFile.listFiles(this);
  for (  File f : realFileList) {
    realFiles.add(f.getName());
  }
  for (Iterator<DiskNode> i=getChildren().iterator(); i.hasNext(); ) {
    DiskNode node=i.next();
    if (realFiles.contains(node.getPhysicalFile().getName())) {
      realFiles.remove(node.getPhysicalFile().getName());
    }
 else {
      i.remove();
      success=false;
    }
    if (node.isAllocated()) {
      if (!(node instanceof DirectoryNode) && !node.checkFile()) {
        success=false;
      }
    }
  }
  if (!realFiles.isEmpty()) {
    success=false;
    realFiles.stream().forEach((fileName) -> {
      addFile(new File(physicalFile,fileName));
    }
);
  }
  return success;
}

Fixed version (ground truth):
@Override public boolean checkFile() throws IOException {
  boolean success=true;
  if (!allocated) {
    allocate();
  }
 else {
    try {
      if (!super.checkFile()) {
        return false;
      }
      HashSet<String> realFiles=new HashSet<>();
      File[] realFileList=physicalFile.listFiles(this);
      for (      File f : realFileList) {
        realFiles.add(f.getName());
      }
      for (Iterator<DiskNode> i=directoryEntries.iterator(); i.hasNext(); ) {
        DiskNode node=i.next();
        if (realFiles.contains(node.getPhysicalFile().getName())) {
          realFiles.remove(node.getPhysicalFile().getName());
        }
 else {
          i.remove();
          success=false;
        }
        if (node.isAllocated()) {
          if (!(node instanceof DirectoryNode) && !node.checkFile()) {
            success=false;
          }
        }
      }
      if (!realFiles.isEmpty()) {
        success=false;
        realFiles.stream().forEach((fileName) -> {
          addFile(new File(physicalFile,fileName));
        }
);
      }
    }
 catch (    IOException ex) {
      return false;
    }
  }
  return success;
}
Program: 12845
Project: 12845
Buggy source:
private void reinitMotherboard(){
  if (motherboard != null && motherboard.isRunning()) {
    motherboard.suspend();
  }
  motherboard=new Motherboard(this);
  motherboard.reconfigure();
}

Fixed version (ground truth):
private void reinitMotherboard(){
  if (motherboard != null && motherboard.isRunning()) {
    motherboard.suspend();
  }
  motherboard=new Motherboard(this,motherboard);
  reconfigure();
  motherboard.reconfigure();
}
Program: 12846
Project: 12846
Buggy source:
public void resume(){
  setRun(true);
}

Fixed version (ground truth):
public void resume(){
  setRun(true);
  waitCycles=0;
}
Program: 12847
Project: 12847
Buggy source:
/** 
 * Creates a new instance of Motherboard
 * @param computer
 */
public Motherboard(Computer computer){
  super(computer);
}

Fixed version (ground truth):
/** 
 * Creates a new instance of Motherboard
 * @param computer
 * @param oldMotherboard
 */
public Motherboard(Computer computer,Motherboard oldMotherboard){
  super(computer);
  if (oldMotherboard != null) {
    miscDevices.addAll(oldMotherboard.miscDevices);
    speaker=oldMotherboard.speaker;
  }
}
Program: 12848
Project: 12848
Buggy source:
@Override protected void doEvent(RAMEvent e){
  setRun(true);
  readJoystick();
  xSwitch.setState(true);
  x=10 + joyX * 11;
  ySwitch.setState(true);
  y=10 + joyY * 11;
  e.setNewValue(computer.getVideo().getFloatingBus());
}

Fixed version (ground truth):
@Override protected void doEvent(RAMEvent e){
  readJoystick();
  xSwitch.setState(true);
  x=10 + joyX * 11;
  ySwitch.setState(true);
  y=10 + joyY * 11;
  e.setNewValue(computer.getVideo().getFloatingBus());
  resume();
}
Program: 12849
Project: 12849
Buggy source:
@Override void registerListeners(){
  if (repulsiveHack) {
    addCheat(RAMEvent.TYPE.WRITE,this::repulsiveBehavior,0x1508,0x1518);
  }
  if (featherFall) {
    addCheat(RAMEvent.TYPE.WRITE,this::featherFallBehavior,PLAYER_Y);
    bypassCode(0x6bb3,0x6bb4);
  }
  if (moonJump) {
    addCheat(RAMEvent.TYPE.WRITE,this::moonJumpBehavior,Y_VELOCITY);
  }
  if (infiniteLives) {
    forceValue(LIVES,11);
  }
  if (scoreHack) {
    forceValue(0x90,SCORE);
    forceValue(0x09,SCORE + 1);
    forceValue(0x13,SCORE + 2);
  }
  if (snakeCharmer) {
    bypassCode(0x07963,0x07964);
  }
  if (mouseHack) {
    EmulatorUILogic.addMouseListener(listener);
  }
 else {
    EmulatorUILogic.removeMouseListener(listener);
  }
}

Fixed version (ground truth):
@Override void registerListeners(){
}
Program: 12850
Project: 12850
Buggy source:
static TOKEN findMatch(String search,int start){
  for (  TOKEN t : values()) {
    int i=start;
    boolean found=true;
    for (int j=0; j < t.toString().length() && j + i < search.length(); j++) {
      while (search.charAt(j + i) == ' ') {
        i++;
      }
      if (i + j >= search.length() || (search.charAt(i + j) != t.toString().charAt(j))) {
        found=false;
        break;
      }
    }
    if (found) {
      return t;
    }
  }
  return null;
}

Fixed version (ground truth):
static TOKEN findMatch(String search,int start){
  for (  TOKEN t : values()) {
    int i=start;
    boolean found=true;
    for (int j=0; j < t.toString().length(); j++) {
      while (i + j < search.length() && search.charAt(j + i) == ' ') {
        i++;
      }
      if (i + j >= search.length() || (search.charAt(i + j) != t.toString().charAt(j))) {
        found=false;
        break;
      }
    }
    if (found) {
      return t;
    }
  }
  return null;
}
Program: 12852
Project: 12852
Buggy source:
public static void registerInvokableAction(InvokableAction action,Object owner,Method method,String code){
  boolean isStatic=Modifier.isStatic(method.getModifiers());
  registerKeyHandler(new KeyHandler(code){
    @Override public boolean handleKeyUp(    KeyEvent e){
      if (!action.notifyOnRelease()) {
        return false;
      }
      Object returnValue=null;
      try {
        if (method.getParameterCount() > 0) {
          returnValue=method.invoke(isStatic ? null : owner,false);
        }
 else {
          returnValue=method.invoke(isStatic ? null : owner);
        }
      }
 catch (      IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
        Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
      }
      if (returnValue != null) {
        return (Boolean)returnValue;
      }
      return action.consumeKeyEvent();
    }
    @Override public boolean handleKeyDown(    KeyEvent e){
      Object returnValue=null;
      try {
        if (method.getParameterCount() > 0) {
          returnValue=method.invoke(isStatic ? null : owner,true);
        }
 else {
          returnValue=method.invoke(isStatic ? null : owner);
        }
      }
 catch (      IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
        Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
      }
      if (returnValue != null) {
        return (Boolean)returnValue;
      }
      return action.consumeKeyEvent();
    }
  }
,owner);
}

Fixed version (ground truth):
public static void registerInvokableAction(InvokableAction action,Object owner,Method method,String code){
  boolean isStatic=Modifier.isStatic(method.getModifiers());
  registerKeyHandler(new KeyHandler(code){
    @Override public boolean handleKeyUp(    KeyEvent e){
      if (action == null || !action.notifyOnRelease()) {
        return false;
      }
      Object returnValue=null;
      try {
        if (method.getParameterCount() > 0) {
          returnValue=method.invoke(isStatic ? null : owner,false);
        }
 else {
          returnValue=method.invoke(isStatic ? null : owner);
        }
      }
 catch (      IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
        Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
      }
      if (returnValue != null) {
        return (Boolean)returnValue;
      }
      return action.consumeKeyEvent();
    }
    @Override public boolean handleKeyDown(    KeyEvent e){
      Object returnValue=null;
      try {
        if (method.getParameterCount() > 0) {
          returnValue=method.invoke(isStatic ? null : owner,true);
        }
 else {
          returnValue=method.invoke(isStatic ? null : owner);
        }
      }
 catch (      IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
        Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
      }
      if (returnValue != null) {
        return (Boolean)returnValue;
      }
      return action != null ? action.consumeKeyEvent() : null;
    }
  }
,owner);
}
Program: 12853
Project: 12853
Buggy source:
@Override public boolean handleKeyDown(KeyEvent e){
  Object returnValue=null;
  try {
    if (method.getParameterCount() > 0) {
      returnValue=method.invoke(isStatic ? null : owner,true);
    }
 else {
      returnValue=method.invoke(isStatic ? null : owner);
    }
  }
 catch (  IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
    Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
  }
  if (returnValue != null) {
    return (Boolean)returnValue;
  }
  return action.consumeKeyEvent();
}

Fixed version (ground truth):
@Override public boolean handleKeyDown(KeyEvent e){
  Object returnValue=null;
  try {
    if (method.getParameterCount() > 0) {
      returnValue=method.invoke(isStatic ? null : owner,true);
    }
 else {
      returnValue=method.invoke(isStatic ? null : owner);
    }
  }
 catch (  IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
    Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
  }
  if (returnValue != null) {
    return (Boolean)returnValue;
  }
  return action != null ? action.consumeKeyEvent() : null;
}
Program: 12854
Project: 12854
Buggy source:
@Override public boolean handleKeyUp(KeyEvent e){
  if (!action.notifyOnRelease()) {
    return false;
  }
  Object returnValue=null;
  try {
    if (method.getParameterCount() > 0) {
      returnValue=method.invoke(isStatic ? null : owner,false);
    }
 else {
      returnValue=method.invoke(isStatic ? null : owner);
    }
  }
 catch (  IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
    Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
  }
  if (returnValue != null) {
    return (Boolean)returnValue;
  }
  return action.consumeKeyEvent();
}

Fixed version (ground truth):
@Override public boolean handleKeyUp(KeyEvent e){
  if (action == null || !action.notifyOnRelease()) {
    return false;
  }
  Object returnValue=null;
  try {
    if (method.getParameterCount() > 0) {
      returnValue=method.invoke(isStatic ? null : owner,false);
    }
 else {
      returnValue=method.invoke(isStatic ? null : owner);
    }
  }
 catch (  IllegalAccessException|IllegalArgumentException|InvocationTargetException ex) {
    Logger.getLogger(Keyboard.class.getName()).log(Level.SEVERE,null,ex);
  }
  if (returnValue != null) {
    return (Boolean)returnValue;
  }
  return action.consumeKeyEvent();
}
Program: 12855
Project: 12855
Buggy source:
private static void applyConfigTree(ConfigNode newRoot,ConfigNode oldRoot){
  if (oldRoot == null || newRoot == null) {
    return;
  }
  oldRoot.settings=newRoot.settings;
  oldRoot.hotkeys=newRoot.hotkeys;
  if (oldRoot.subject != null) {
    doApply(oldRoot);
    buildTree(oldRoot,new HashSet());
  }
  newRoot.getChildren().stream().forEach((child) -> {
    String childName=child.toString();
    applyConfigTree(child,oldRoot.findChild(childName));
  }
);
}

Fixed version (ground truth):
private static void applyConfigTree(ConfigNode newRoot,ConfigNode oldRoot){
  if (oldRoot == null || newRoot == null) {
    return;
  }
  oldRoot.settings=newRoot.settings;
  oldRoot.hotkeys=newRoot.hotkeys;
  if (oldRoot.subject != null) {
    doApply(oldRoot);
    buildTree(oldRoot,new HashSet());
  }
  newRoot.getChildren().stream().forEach((child) -> {
    String childName=child.toString();
    ConfigNode oldChild=oldRoot.findChild(childName);
    if (oldChild == null) {
      oldChild=oldRoot.findChild(child.id);
    }
    applyConfigTree(child,oldChild);
  }
);
}
Program: 12856
Project: 12856
Buggy source:
@Override public void resume(){
synchronized (this) {
    if (!isRunning()) {
      super.resume();
      RECV_IRQ_ENABLED=false;
      TRANS_IRQ_ENABLED=false;
      IRQ_TRIGGERED=false;
      try {
        socket=new ServerSocket(IP_PORT);
        socket.setReuseAddress(true);
        socket.setSoTimeout(0);
        listenThread=new Thread(this::socketMonitor);
        listenThread.setDaemon(false);
        listenThread.setName("String_Node_Str" + getSlot());
        listenThread.start();
      }
 catch (      IOException ex) {
        suspend();
        Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE,null,ex);
      }
    }
  }
}

Fixed version (ground truth):
@Override public void resume(){
synchronized (this) {
    if (!isRunning()) {
      super.resume();
      RECV_IRQ_ENABLED=false;
      TRANS_IRQ_ENABLED=false;
      IRQ_TRIGGERED=false;
      listenThread=new Thread(this::socketMonitor);
      listenThread.setDaemon(false);
      listenThread.setName("String_Node_Str" + getSlot());
      listenThread.start();
    }
  }
}
Program: 12857
Project: 12857
Buggy source:
public void socketMonitor(){
  while (socket != null && !socket.isClosed()) {
    try {
      Logger.getLogger(CardSSC.class.getName()).log(Level.INFO,"String_Node_Str" + getSlot() + "String_Node_Str"+ IP_PORT,(Throwable)null);
      while ((clientSocket=socket.accept()) != null) {
        socketInput=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
        clientConnected();
        clientSocket.setTcpNoDelay(true);
        while (isConnected()) {
          try {
            Thread.sleep(10);
            if (socketInput.ready()) {
              newInputAvailable=true;
            }
          }
 catch (          InterruptedException ex) {
          }
        }
        clientDisconnected();
        hangUp();
        socketInput=null;
      }
    }
 catch (    SocketTimeoutException ex) {
    }
catch (    IOException ex) {
      Logger.getLogger(CardSSC.class.getName()).log(Level.FINE,null,ex);
    }
  }
  socket=null;
}

Fixed version (ground truth):
public void socketMonitor(){
  try {
    socket=new ServerSocket(IP_PORT);
    socket.setReuseAddress(true);
    socket.setSoTimeout(0);
  }
 catch (  IOException ex) {
    Logger.getLogger(CardSSC.class.getName()).log(Level.SEVERE,null,ex);
    suspend();
    return;
  }
  while (socket != null && !socket.isClosed()) {
    try {
      Logger.getLogger(CardSSC.class.getName()).log(Level.INFO,"String_Node_Str" + getSlot() + "String_Node_Str"+ IP_PORT,(Throwable)null);
      while ((clientSocket=socket.accept()) != null) {
        socketInput=new BufferedReader(new InputStreamReader(clientSocket.getInputStream()));
        clientConnected();
        clientSocket.setTcpNoDelay(true);
        while (isConnected()) {
          try {
            Thread.sleep(10);
            if (socketInput.ready()) {
              newInputAvailable=true;
            }
          }
 catch (          InterruptedException ex) {
          }
        }
        clientDisconnected();
        hangUp();
        socketInput=null;
      }
    }
 catch (    SocketTimeoutException ex) {
    }
catch (    IOException ex) {
      Logger.getLogger(CardSSC.class.getName()).log(Level.FINE,null,ex);
    }
  }
  socket=null;
}
Program: 12858
Project: 12858
Buggy source:
@Override public void tick(){
  setFloatingBus(computer.getMemory().readRaw(scannerAddress + x));
  if (hPeriod > 0) {
    hPeriod--;
    if (hPeriod == 0) {
      x=-1;
      setScannerLocation(currentWriter.getYOffset(y));
    }
  }
 else {
    if (!isVblank) {
      draw();
    }
    if (x >= APPLE_CYCLES_PER_LINE - 1) {
      int yy=y + hblankOffsetY;
      if (yy < 0) {
        yy+=APPLE_SCREEN_LINES;
      }
      if (yy >= APPLE_SCREEN_LINES) {
        yy-=(TOTAL_LINES - APPLE_SCREEN_LINES);
      }
      setScannerLocation(currentWriter.getYOffset(yy) + hblankOffsetX + (yy < 64 ? 128 : 0));
      x=-1;
      if (!isVblank) {
        if (lineDirty) {
          screenDirty=true;
          currentWriter.clearDirty(y);
        }
        hblankStart(video,y,lineDirty);
        lineDirty=false;
        forceRedrawRowCount--;
      }
      hPeriod=HBLANK;
      y++;
      if (y >= APPLE_SCREEN_LINES) {
        if (!isVblank) {
          y=APPLE_SCREEN_LINES - (TOTAL_LINES - APPLE_SCREEN_LINES);
          isVblank=true;
          vblankStart();
          computer.getMotherboard().vblankStart();
        }
 else {
          y=0;
          isVblank=false;
          vblankEnd();
          computer.getMotherboard().vblankEnd();
        }
      }
    }
  }
  x++;
}

Fixed version (ground truth):
@Override public void tick(){
  setFloatingBus(computer.getMemory().readRaw(scannerAddress + x));
  if (hPeriod > 0) {
    hPeriod--;
    if (hPeriod == 0) {
      x=-1;
      setScannerLocation(currentWriter.getYOffset(y));
    }
  }
 else {
    if (!isVblank && x < (APPLE_CYCLES_PER_LINE - 1)) {
      draw();
    }
    if (x >= APPLE_CYCLES_PER_LINE - 1) {
      int yy=y + hblankOffsetY;
      if (yy < 0) {
        yy+=APPLE_SCREEN_LINES;
      }
      if (yy >= APPLE_SCREEN_LINES) {
        yy-=(TOTAL_LINES - APPLE_SCREEN_LINES);
      }
      setScannerLocation(currentWriter.getYOffset(yy) + hblankOffsetX + (yy < 64 ? 128 : 0));
      x=-1;
      if (!isVblank) {
        if (lineDirty) {
          screenDirty=true;
          currentWriter.clearDirty(y);
        }
        hblankStart(video,y,lineDirty);
        lineDirty=false;
        forceRedrawRowCount--;
      }
      hPeriod=HBLANK;
      y++;
      if (y >= APPLE_SCREEN_LINES) {
        if (!isVblank) {
          y=APPLE_SCREEN_LINES - (TOTAL_LINES - APPLE_SCREEN_LINES);
          isVblank=true;
          vblankStart();
          computer.getMotherboard().vblankStart();
        }
 else {
          y=0;
          isVblank=false;
          vblankEnd();
          computer.getMotherboard().vblankEnd();
        }
      }
    }
  }
  x++;
}