nus-yam/ex-repair huggingface dataset:
Program: 130537
Project: 130537
Buggy source:
@NotNull @Override public DotNetTypeRef toTypeRef(boolean resolveFromParent){
  DotNetType type=getNewType();
  if (type == null) {
    CSharpFieldOrPropertySetBlock fieldOrPropertySetBlock=getFieldOrPropertySetBlock();
    if (fieldOrPropertySetBlock == null) {
      return DotNetTypeRef.ERROR_TYPE;
    }
    return new CSharpAnonymTypeRef(getContainingFile(),fieldOrPropertySetBlock.getSets());
  }
 else {
    DotNetTypeRef typeRef=null;
    if (canResolve()) {
      if (type instanceof DotNetReferenceType) {
        DotNetReferenceExpression referenceExpression=((DotNetReferenceType)type).getReferenceExpression();
        if (referenceExpression instanceof CSharpReferenceExpression) {
          typeRef=((CSharpReferenceExpressionImpl)referenceExpression).toTypeRef(CSharpReferenceExpressionImpl.ResolveToKind.TYPE_OR_GENERIC_PARAMETER_OR_DELEGATE_METHOD,resolveFromParent);
        }
 else {
          typeRef=DotNetTypeRef.ERROR_TYPE;
        }
      }
 else {
        typeRef=type.toTypeRef();
      }
    }
 else {
      typeRef=type.toTypeRef();
    }
    for (    CSharpNewArrayLengthImpl length : getNewArrayLengths()) {
      typeRef=new CSharpArrayTypeRef(typeRef,length.getDimensionSize());
    }
    return typeRef;
  }
}

Fixed version (ground truth):
@NotNull @Override public DotNetTypeRef toTypeRef(boolean resolveFromParent){
  DotNetType type=getNewType();
  if (type == null) {
    CSharpFieldOrPropertySetBlock fieldOrPropertySetBlock=getFieldOrPropertySetBlock();
    if (fieldOrPropertySetBlock == null) {
      return DotNetTypeRef.ERROR_TYPE;
    }
    return new CSharpAnonymTypeRef(getContainingFile(),fieldOrPropertySetBlock.getSets());
  }
 else {
    DotNetTypeRef typeRef=null;
    if (canResolve()) {
      DotNetType[] arguments=DotNetType.EMPTY_ARRAY;
      if (type instanceof DotNetTypeWithTypeArguments) {
        arguments=((DotNetTypeWithTypeArguments)type).getArguments();
        type=((DotNetTypeWithTypeArguments)type).getInnerType();
      }
      if (type instanceof DotNetReferenceType) {
        DotNetReferenceExpression referenceExpression=((DotNetReferenceType)type).getReferenceExpression();
        if (referenceExpression instanceof CSharpReferenceExpression) {
          typeRef=((CSharpReferenceExpressionImpl)referenceExpression).toTypeRef(CSharpReferenceExpressionImpl.ResolveToKind.TYPE_OR_GENERIC_PARAMETER_OR_DELEGATE_METHOD,resolveFromParent);
        }
 else {
          typeRef=DotNetTypeRef.ERROR_TYPE;
        }
      }
 else {
        typeRef=type.toTypeRef();
      }
      if (arguments.length != 0) {
        typeRef=new DotNetGenericWrapperTypeRef(typeRef,DotNetTypeRefUtil.toArray(arguments));
      }
    }
 else {
      typeRef=type.toTypeRef();
    }
    for (    CSharpNewArrayLengthImpl length : getNewArrayLengths()) {
      typeRef=new CSharpArrayTypeRef(typeRef,length.getDimensionSize());
    }
    return typeRef;
  }
}
Program: 130540
Project: 130540
Buggy source:
/** 
 * Remember this eats up the regex char!
 * @param source
 * @param sink
 * @param regex
 */
final void readUntil(StringBuffer source,StringBuffer sink,String regex){
  this.readBefore(source,sink,regex);
  this.extractChar(source,sink);
}

Fixed version (ground truth):
/** 
 * Remember this eats up the regex char!
 * @param source
 * @param sink
 * @param regex
 */
final void readUntil(StringBuffer source,StringBuffer sink,String regex){
  this.readBefore(source,sink,regex);
  if (this.peek(source) != '"') {
    this.extractChar(source,sink);
  }
}
Program: 130541
Project: 130541
Buggy source:
/** 
 * Copy constructor.
 * @param copy CodeBlock to copy.
 */
public CodeBlock(CodeBlock<T> copy){
  this.parent=copy.parent;
  this.prototype=copy.prototype;
  this.addStatements(copy.statements);
  for (  CodeBlock<T> child : copy.getChildren()) {
    this.addChild(new CodeBlock<T>(child));
  }
}

Fixed version (ground truth):
/** 
 * Copy constructor.
 * @param copy CodeBlock to copy.
 */
public CodeBlock(CodeBlock<T> copy){
  this();
  this.parent=copy.parent;
  this.prototype=copy.prototype;
  this.addStatements(copy.statements);
  for (  CodeBlock<T> child : copy.getChildren()) {
    this.addChild(new CodeBlock<T>(child));
  }
}
Program: 130542
Project: 130542
Buggy source:
@Override public boolean newLineBrace(){
  int onLineBrace=0;
  int newLineBrace=0;
  for (  String s : this.code.split("String_Node_Str")) {
    if (s.charAt(s.length() - 1) == '\n') {
      newLineBrace++;
    }
 else {
      onLineBrace++;
    }
  }
  return newLineBrace >= onLineBrace;
}

Fixed version (ground truth):
@Override public boolean newLineBrace(){
  int onLineBrace=0;
  int newLineBrace=0;
  for (  String s : this.code.split("String_Node_Str")) {
    if (s.length() == 0) {
      continue;
    }
    if (s.charAt(s.length() - 1) == '\n') {
      newLineBrace++;
    }
 else {
      onLineBrace++;
    }
  }
  return newLineBrace >= onLineBrace;
}
Program: 130543
Project: 130543
Buggy source:
@Override String readNextLiteral(StringBuffer source){
  StringBuffer sink=new StringBuffer();
  if (source.charAt(0) == '"') {
    this.extractChar(source,sink);
    char prev='\0';
    char next;
    while (source.length() > 0) {
      next=source.charAt(0);
      this.extractChar(source,sink);
      if (prev != '\\' && next == '"') {
        break;
      }
    }
  }
 else   if (source.charAt(0) == '\'') {
    if (source.charAt(1) == '\\') {
      this.extractMultipleChars(source,sink,4);
    }
 else {
      this.extractMultipleChars(source,sink,3);
    }
  }
 else {
    this.readBefore(source,sink,"String_Node_Str");
    if (source.charAt(0) == 'l' || source.charAt(0) == 'L') {
      this.extractChar(source,sink);
    }
 else     if (source.charAt(0) == '.') {
      this.extractChar(source,sink);
      this.readBefore(source,sink,"String_Node_Str");
      if (source.charAt(0) == 'f' || source.charAt(0) == 'F') {
        this.extractChar(source,sink);
      }
    }
  }
  return sink.toString();
}

Fixed version (ground truth):
@Override String readNextLiteral(StringBuffer source){
  StringBuffer sink=new StringBuffer();
  if (source.charAt(0) == '"') {
    this.extractChar(source,sink);
    char prev='\0';
    char next;
    while (source.length() > 0) {
      next=source.charAt(0);
      this.extractChar(source,sink);
      if (prev != '\\' && next == '"') {
        break;
      }
      prev=next;
    }
  }
 else   if (source.charAt(0) == '\'') {
    if (source.charAt(1) == '\\') {
      this.extractMultipleChars(source,sink,4);
    }
 else {
      this.extractMultipleChars(source,sink,3);
    }
  }
 else {
    this.readBefore(source,sink,"String_Node_Str");
    if (source.charAt(0) == 'l' || source.charAt(0) == 'L') {
      this.extractChar(source,sink);
    }
 else     if (source.charAt(0) == '.') {
      this.extractChar(source,sink);
      this.readBefore(source,sink,"String_Node_Str");
      if (source.charAt(0) == 'f' || source.charAt(0) == 'F') {
        this.extractChar(source,sink);
      }
    }
  }
  return sink.toString();
}
Program: 130544
Project: 130544
Buggy source:
public static String getInstanceData(FeatureSet f,Set<String> authors){
  StringBuffer x=new StringBuffer();
  x.append(f.numFunctions() + "String_Node_Str");
  x.append(f.length() + "String_Node_Str");
  x.append(f.numTokens() + "String_Node_Str");
  x.append(f.numComments() + "String_Node_Str");
  x.append(f.getLiterals().size() + "String_Node_Str");
  x.append(f.getReservedWords().size() + "String_Node_Str");
  x.append(f.avgLineLength() + "String_Node_Str");
  x.append(f.numEmptyLines() + "String_Node_Str");
  x.append(f.whiteSpaceRatio() + "String_Node_Str");
  x.append(f.avgParamsPerFunction() + "String_Node_Str");
  x.append(getAuthorName((AbstractExtractor)f) + "String_Node_Str");
  authors.add(getAuthorName((AbstractExtractor)f));
  return x.toString();
}

Fixed version (ground truth):
public String getInstanceData(FeatureSet f,Set<String> authors){
  StringBuffer x=new StringBuffer();
  appendAttributes(f,x);
  x.append(getAuthorName((AbstractExtractor)f) + "String_Node_Str");
  authors.add(getAuthorName((AbstractExtractor)f));
  return x.toString();
}
Program: 130545
Project: 130545
Buggy source:
public static void makeARFFHeader(String targetPath,Set<String> authors){
  List<String> allLines=new LinkedList<String>();
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  Iterator<String> author=authors.iterator();
  while (author.hasNext()) {
    allLines.add(author.next());
    if (author.hasNext()) {
      allLines.add("String_Node_Str");
    }
  }
  allLines.add("String_Node_Str");
  Util.writeFile(allLines,targetPath,false);
}

Fixed version (ground truth):
public void makeARFFHeader(String targetPath,Set<String> authors){
  List<String> allLines=new LinkedList<String>();
  allLines.add("String_Node_Str");
  arffAttributes(allLines);
  allLines.add("String_Node_Str");
  Iterator<String> author=authors.iterator();
  while (author.hasNext()) {
    allLines.add(author.next());
    if (author.hasNext()) {
      allLines.add("String_Node_Str");
    }
  }
  allLines.add("String_Node_Str");
  Util.writeFile(allLines,targetPath,false);
}
Program: 130546
Project: 130546
Buggy source:
public static double stdDev(List<Integer> list){
  throw new UnsupportedOperationException();
}

Fixed version (ground truth):
public static double stdDev(List<Integer> list){
  return Math.sqrt(variance(list));
}
Program: 130547
Project: 130547
Buggy source:
public static void makeARFF(List<File> files,String targetPath){
  Set<String> authors=new HashSet<>();
  List<String> allLines=new LinkedList<String>();
  for (  File f : files) {
    System.out.println(f.getAbsolutePath());
    try {
      allLines.add(getInstanceData((FeatureSet)getExtractor(f),authors));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  makeARFFHeader(targetPath,authors);
  Util.writeFile(allLines,targetPath,true);
  System.out.println(authors.size() + "String_Node_Str");
  System.out.println(files.size() + "String_Node_Str");
}

Fixed version (ground truth):
public void makeARFF(List<File> files,String targetPath){
  Set<String> authors=new HashSet<>();
  List<String> allLines=new LinkedList<String>();
  for (  File f : files) {
    System.out.println(f.getAbsolutePath());
    try {
      allLines.add(getInstanceData((FeatureSet)getExtractor(f),authors));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  makeARFFHeader(targetPath,authors);
  Util.writeFile(allLines,targetPath,true);
  System.out.println(authors.size() + "String_Node_Str");
  System.out.println(files.size() + "String_Node_Str");
}
Program: 130548
Project: 130548
Buggy source:
@Override public Map<WhiteSpace,Integer> getWhiteSpace(){
  MultiSet<WhiteSpace> whitespace=new MultiSet<WhiteSpace>();
  for (int i=0; i < this.code.length(); i++) {
    if (this.code.charAt(i) == '\n') {
      whitespace.add(WhiteSpace.newLine);
    }
 else     if (this.code.charAt(i) == '\t') {
      whitespace.add(WhiteSpace.tab);
    }
 else     if (this.code.charAt(i) == ' ') {
      whitespace.add(WhiteSpace.space);
    }
  }
  return whitespace;
}

Fixed version (ground truth):
@Override public Map<WhiteSpace,Integer> getWhiteSpace(){
  MultiSet<WhiteSpace> whitespace=new MultiSet<WhiteSpace>();
  whitespace.put(WhiteSpace.newLine,0);
  whitespace.put(WhiteSpace.tab,0);
  whitespace.put(WhiteSpace.space,0);
  for (int i=0; i < this.code.length(); i++) {
    if (this.code.charAt(i) == '\n') {
      whitespace.add(WhiteSpace.newLine);
    }
 else     if (this.code.charAt(i) == '\t') {
      whitespace.add(WhiteSpace.tab);
    }
 else     if (this.code.charAt(i) == ' ') {
      whitespace.add(WhiteSpace.space);
    }
  }
  return whitespace;
}
Program: 130549
Project: 130549
Buggy source:
@Override public Map<ControlStatement,Integer> getControlStructures(){
  MultiSet<ControlStatement> myControls=new MultiSet<>();
  for (  String s : this.blocks.getPrototypesRecursively()) {
    if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.elifStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.elseStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.ifStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.switchStatement);
    }
  }
  myControls.put(ControlStatement.ternaryOperator,this.code.split("String_Node_Str").length - 1);
  return myControls;
}

Fixed version (ground truth):
@Override public Map<ControlStatement,Integer> getControlStructures(){
  MultiSet<ControlStatement> myControls=new MultiSet<>();
  myControls.put(ControlStatement.elifStatement,0);
  myControls.put(ControlStatement.elseStatement,0);
  myControls.put(ControlStatement.ifStatement,0);
  myControls.put(ControlStatement.switchStatement,0);
  myControls.put(ControlStatement.ternaryOperator,0);
  for (  String s : this.blocks.getPrototypesRecursively()) {
    if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.elifStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.elseStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.ifStatement);
    }
 else     if (s.matches("String_Node_Str")) {
      myControls.add(ControlStatement.switchStatement);
    }
  }
  myControls.put(ControlStatement.ternaryOperator,this.code.split("String_Node_Str").length - 1);
  return myControls;
}
Program: 130550
Project: 130550
Buggy source:
@Override public Map<Loops,Integer> getLoops(){
  MultiSet<Loops> myLoops=new MultiSet<>();
  for (  String s : this.blocks.getPrototypesRecursively()) {
    if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.doWhileLoop);
    }
 else     if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.forLoop);
    }
 else     if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.whileLoop);
    }
  }
  return myLoops;
}

Fixed version (ground truth):
@Override public Map<Loops,Integer> getLoops(){
  MultiSet<Loops> myLoops=new MultiSet<>();
  myLoops.put(Loops.doWhileLoop,0);
  myLoops.put(Loops.forLoop,0);
  myLoops.put(Loops.whileLoop,0);
  for (  String s : this.blocks.getPrototypesRecursively()) {
    if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.doWhileLoop);
    }
 else     if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.forLoop);
    }
 else     if (s.matches("String_Node_Str")) {
      myLoops.add(Loops.whileLoop);
    }
  }
  return myLoops;
}
Program: 130551
Project: 130551
Buggy source:
public AbstractExtractor(File program) throws IOException {
  this.setTokenDelimiter();
  this.file=program;
  BufferedReader reader=new BufferedReader(new FileReader(program));
  StringBuffer source=new StringBuffer();
  char nextChar;
  while (reader.ready()) {
    nextChar=(char)reader.read();
    source.append(nextChar);
  }
  reader.close();
  this.literals=new MultiSet<String>();
  this.commentList=new LinkedList<>();
  StringBuffer sink=new StringBuffer();
  while (source.length() > 0) {
    if (matchesLiteral(source)) {
      this.literals.add(readNextLiteral(source));
    }
 else     if (matchesComment(source)) {
      this.commentList.add(readNextComment(source));
    }
 else {
      readUntilNextToken(source,sink);
    }
  }
  source=sink;
  sink=new StringBuffer();
  this.blocks=new CodeBlock<String>(this.file.getName());
  CodeBlock<String> currentBlock=blocks;
  while (source.length() > 0) {
    if (isPrototype(source)) {
      currentBlock.addStatements(breakIntoStmts(sink));
      sink=new StringBuffer();
      CodeBlock<String> temp=new CodeBlock<String>(extractPrototype(source));
      currentBlock.addChild(temp);
      currentBlock=temp;
    }
 else     if (isBlockEnd(source,sink)) {
      currentBlock.addStatements(breakIntoStmts(sink));
      sink=new StringBuffer();
      currentBlock=currentBlock.getParent();
    }
 else {
      readUntilNextToken(source,sink);
    }
  }
}

Fixed version (ground truth):
public AbstractExtractor(File program) throws IOException {
  setTokenDelimiter();
  this.file=program;
  BufferedReader reader=new BufferedReader(new FileReader(program));
  StringBuffer source=new StringBuffer();
  char nextChar;
  while (reader.ready()) {
    nextChar=(char)reader.read();
    source.append(nextChar);
  }
  reader.close();
  this.literals=new MultiSet<String>();
  this.commentList=new LinkedList<>();
  StringBuffer sink=new StringBuffer();
  while (source.length() > 0) {
    if (matchesLiteral(source)) {
      this.literals.add(readNextLiteral(source));
    }
 else     if (matchesComment(source)) {
      this.commentList.add(readNextComment(source));
    }
 else {
      readUntilNextToken(source,sink);
    }
  }
  source=sink;
  sink=new StringBuffer();
  code=source.toString();
  this.blocks=new CodeBlock<String>(this.file.getName());
  CodeBlock<String> currentBlock=blocks;
  while (source.length() > 0) {
    if (isPrototype(source)) {
      currentBlock.addStatements(breakIntoStmts(sink));
      sink=new StringBuffer();
      CodeBlock<String> temp=new CodeBlock<String>(extractPrototype(source));
      currentBlock.addChild(temp);
      currentBlock=temp;
    }
 else     if (isBlockEnd(source,sink)) {
      currentBlock.addStatements(breakIntoStmts(sink));
      sink=new StringBuffer();
      currentBlock=currentBlock.getParent();
    }
 else {
      readUntilNextToken(source,sink);
    }
  }
}
Program: 130552
Project: 130552
Buggy source:
String getTokenDelimiter(){
  return this.tokenDelimiter;
}

Fixed version (ground truth):
static String getTokenDelimiter(){
  return tokenDelimiter;
}
Program: 130553
Project: 130553
Buggy source:
void setTokenDelimiter(){
}

Fixed version (ground truth):
static void setTokenDelimiter(){
}
Program: 130554
Project: 130554
Buggy source:
@Override boolean isPrototype(StringBuffer source){
  String s=source.toString();
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    return true;
  }
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    int braceIndex=s.indexOf('{');
    int semicolonIndex=s.indexOf(';');
    if (braceIndex == -1) {
      return false;
    }
    if (semicolonIndex == -1) {
      return true;
    }
    return braceIndex < semicolonIndex;
  }
  return false;
}

Fixed version (ground truth):
@Override boolean isPrototype(StringBuffer source){
  String s=source.toString();
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    return true;
  }
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    int braceIndex=s.indexOf('{');
    int semicolonIndex=s.indexOf(';');
    if (braceIndex == -1) {
      return false;
    }
    if (semicolonIndex == -1) {
      return true;
    }
    return braceIndex < semicolonIndex;
  }
  return false;
}
Program: 130555
Project: 130555
Buggy source:
@Override void readUntilNextToken(StringBuffer source,StringBuffer sink){
  this.readUntil(source,sink,this.tokenDelimiter);
}

Fixed version (ground truth):
@Override void readUntilNextToken(StringBuffer source,StringBuffer sink){
  this.readUntil(source,sink,tokenDelimiter);
}
Program: 130556
Project: 130556
Buggy source:
public static void makeARFFHeader(String targetPath){
}

Fixed version (ground truth):
public static void makeARFFHeader(String targetPath,Set<String> authors){
  List<String> allLines=new LinkedList<String>();
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  allLines.add("String_Node_Str");
  Iterator<String> author=authors.iterator();
  while (author.hasNext()) {
    allLines.add(author.next());
    if (author.hasNext()) {
      allLines.add("String_Node_Str");
    }
  }
  allLines.add("String_Node_Str");
  Util.writeFile(allLines,targetPath,false);
}
Program: 130557
Project: 130557
Buggy source:
public static void makeARFF(List<File> files,String targetPath){
  makeARFFHeader(targetPath);
  for (  File f : files) {
    try {
      printInstanceData((FeatureSet)getExtractor(f),new File(targetPath));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
}

Fixed version (ground truth):
public static void makeARFF(List<File> files,String targetPath){
  Set<String> authors=new HashSet<>();
  List<String> allLines=new LinkedList<String>();
  for (  File f : files) {
    System.out.println(f.getAbsolutePath());
    try {
      allLines.add(getInstanceData((FeatureSet)getExtractor(f),authors));
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
  }
  makeARFFHeader(targetPath,authors);
  Util.writeFile(allLines,targetPath,true);
  System.out.println(authors.size() + "String_Node_Str");
  System.out.println(files.size() + "String_Node_Str");
}
Program: 130558
Project: 130558
Buggy source:
/** 
 * Same as readUntil except it doesn't eat the regex.
 * @param source
 * @param sink
 * @param regex
 */
final void readBefore(StringBuffer source,StringBuffer sink,String regex){
  while (!source.substring(0,1).matches(regex)) {
    this.extractChar(source,sink);
  }
}

Fixed version (ground truth):
/** 
 * Same as readUntil except it doesn't eat the regex.
 * @param source
 * @param sink
 * @param regex
 */
final void readBefore(StringBuffer source,StringBuffer sink,String regex){
  while (source.length() > 1 && !source.substring(0,1).matches(regex)) {
    this.extractChar(source,sink);
  }
}
Program: 130559
Project: 130559
Buggy source:
@Override boolean isBlockEnd(StringBuffer source,StringBuffer sink){
  if (source.charAt(0) == '}') {
    source.deleteCharAt(0);
    if (source.charAt(0) == ';') {
      source.deleteCharAt(0);
    }
 else     if (source.toString().matches("String_Node_Str")) {
      int semicolonIndex=source.indexOf("String_Node_Str");
      this.extractMultipleChars(source,sink,semicolonIndex + 1);
    }
    return true;
  }
  return false;
}

Fixed version (ground truth):
@Override boolean isBlockEnd(StringBuffer source,StringBuffer sink){
  if (source.charAt(0) == '}') {
    source.deleteCharAt(0);
    if (source.length() > 0 && source.charAt(0) == ';') {
      source.deleteCharAt(0);
    }
 else     if (source.length() > 0 && source.toString().matches("String_Node_Str")) {
      int semicolonIndex=source.indexOf("String_Node_Str");
      this.extractMultipleChars(source,sink,semicolonIndex + 1);
    }
    return true;
  }
  return false;
}
Program: 130560
Project: 130560
Buggy source:
protected static boolean isFunction(String s){
  return s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str");
}

Fixed version (ground truth):
protected static boolean isFunction(String s){
  return !(s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str"));
}
Program: 130561
Project: 130561
Buggy source:
@Override String extractPrototype(StringBuffer source){
  StringBuffer sink=new StringBuffer();
  this.readUntil(source,sink,"String_Node_Str");
  return sink.substring(0,sink.length() - 1);
}

Fixed version (ground truth):
@Override String extractPrototype(StringBuffer source){
  StringBuffer sink=new StringBuffer();
  String s=source.toString();
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    int lineIndex=s.indexOf("String_Node_Str");
    int braceIndex=s.indexOf("String_Node_Str");
    if (braceIndex == -1 || braceIndex < lineIndex || s.substring(lineIndex,braceIndex).matches("String_Node_Str")) {
      this.readBefore(source,sink,"String_Node_Str");
      return sink.toString();
    }
  }
  this.readUntil(source,sink,"String_Node_Str");
  return sink.substring(0,sink.length() - 1);
}
Program: 130562
Project: 130562
Buggy source:
@Override boolean isPrototype(StringBuffer source){
  String s=source.toString();
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    return true;
  }
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    int braceIndex=s.indexOf('{');
    int semicolonIndex=s.indexOf(';');
    if (braceIndex == -1) {
      return false;
    }
    if (semicolonIndex == -1) {
      return true;
    }
    return braceIndex < semicolonIndex;
  }
  return false;
}

Fixed version (ground truth):
@Override boolean isPrototype(StringBuffer source){
  String s=source.toString();
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str")) {
    return true;
  }
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    return true;
  }
  if (s.matches("String_Node_Str") || s.matches("String_Node_Str") || s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")|| s.matches("String_Node_Str")) {
    int braceIndex=s.indexOf('{');
    int semicolonIndex=s.indexOf(';');
    if (braceIndex == -1) {
      return false;
    }
    if (semicolonIndex == -1) {
      return true;
    }
    return braceIndex < semicolonIndex;
  }
  return false;
}
Program: 130563
Project: 130563
Buggy source:
public void encode(final CharSequence s) throws IOException {
  if (s.length() <= 0)   return;
  final CharBuffer in=CharBuffer.wrap(s);
  if (s.length() > m_buffer.capacity())   m_buffer=ByteBuffer.allocate(s.length());
  reset();
  CoderResult cr=m_stringEncoder.encode(in,m_buffer,true);
  if (cr.isUnderflow())   cr=m_stringEncoder.flush(m_buffer);
  if (cr.isOverflow())   cr.throwException();
  m_buffer.flip();
}

Fixed version (ground truth):
public void encode(final CharSequence s) throws IOException {
  if (s.length() <= 0)   return;
  final CharBuffer in=CharBuffer.wrap(s);
  if (s.length() * 4 > m_buffer.capacity())   m_buffer=ByteBuffer.allocate(s.length() * 4);
  reset();
  CoderResult cr=m_stringEncoder.encode(in,m_buffer,true);
  if (cr.isUnderflow())   cr=m_stringEncoder.flush(m_buffer);
  if (cr.isOverflow())   cr.throwException();
  m_buffer.flip();
}
Program: 130564
Project: 130564
Buggy source:
@SuppressWarnings("String_Node_Str") private void writeObject(final Object o,final Type typ) throws IOException {
  if (o == null) {
    write("String_Node_Str");
    return;
  }
switch (typ.typeEnum()) {
case ENUM:
    write(o != null ? o.toString() : null);
  break;
case BOOL:
write((Boolean)o);
break;
case INT8:
write((Byte)o);
break;
case INT16:
write((Short)o);
break;
case INT32:
write((Integer)o);
break;
case INT64:
write((Long)o);
break;
case FLOAT32:
write((Float)o);
break;
case FLOAT64:
write((Double)o);
break;
case STRING:
write(quoteEscape((String)o));
break;
case ARRAY:
writeArray(o,(ArrayType)typ);
break;
case LIST:
writeList((List<Object>)o,(ListType)typ);
break;
case MAP:
writeMap((Map<Object,Object>)o,(MapType)typ);
break;
case UNKNOWN:
case CUSTOM:
writeMGenObject((MGenBase)o,(CustomType)typ);
break;
default :
throw new SerializationException("String_Node_Str");
}
}

Fixed version (ground truth):
@SuppressWarnings("String_Node_Str") private void writeObject(final Object o,final Type typ) throws IOException {
  if (o == null) {
    write("String_Node_Str");
    return;
  }
switch (typ.typeEnum()) {
case ENUM:
    write(quote(o.toString()));
  break;
case BOOL:
write((Boolean)o);
break;
case INT8:
write((Byte)o);
break;
case INT16:
write((Short)o);
break;
case INT32:
write((Integer)o);
break;
case INT64:
write((Long)o);
break;
case FLOAT32:
write((Float)o);
break;
case FLOAT64:
write((Double)o);
break;
case STRING:
write(quoteEscape((String)o));
break;
case ARRAY:
writeArray(o,(ArrayType)typ);
break;
case LIST:
writeList((List<Object>)o,(ListType)typ);
break;
case MAP:
writeMap((Map<Object,Object>)o,(MapType)typ);
break;
case UNKNOWN:
case CUSTOM:
writeMGenObject((MGenBase)o,(CustomType)typ);
break;
default :
throw new SerializationException("String_Node_Str");
}
}
Program: 130566
Project: 130566
Buggy source:
private void writeMap(final HashMap<Object,Object> map,final MapType typ,final boolean tag) throws IOException {
  if (tag)   writeTypeTag(TAG_MAP);
  if (map != null && !map.isEmpty()) {
    writeSize(map.size());
    writeElements(map.keySet(),typ.keyType());
    writeElements(map.values(),typ.valueType());
  }
 else {
    writeSize(0);
  }
}

Fixed version (ground truth):
private void writeMap(final HashMap<Object,Object> map,final MapType typ,final boolean tag) throws IOException {
  if (tag)   writeTypeTag(TAG_MAP);
  if (map != null && !map.isEmpty()) {
    writeSize(map.size());
    writeElements(true,map.keySet(),typ.keyType());
    writeElements(true,map.values(),typ.valueType());
  }
 else {
    writeSize(0);
  }
}
Program: 130567
Project: 130567
Buggy source:
private void writeList(final List<Object> list,final ListType typ,final boolean tag) throws IOException {
  if (tag)   writeTypeTag(TAG_LIST);
  writeElements(list,typ.elementType());
}

Fixed version (ground truth):
private void writeList(final List<Object> list,final ListType typ,final boolean tag) throws IOException {
  if (tag)   writeTypeTag(TAG_LIST);
  writeElements(false,list,typ.elementType());
}
Program: 130568
Project: 130568
Buggy source:
private HashMap<Object,Object> readMap(final boolean readTag,final MapType constraint) throws IOException {
  if (readTag)   ensureTypeTag(null,TAG_MAP,readTypeTag());
  final int nElements=readSize();
  final HashMap<Object,Object> out=new HashMap<Object,Object>(nElements);
  if (nElements > 0) {
    final List<Object> keys=readElements(constraint != null ? constraint.keyType() : null);
    final List<Object> values=readElements(constraint != null ? constraint.valueType() : null);
    if (keys.size() != values.size() || keys.size() != nElements)     throw new StreamCorruptedException("String_Node_Str");
    for (int i=0; i < keys.size(); i++)     out.put(keys.get(i),values.get(i));
  }
  return out;
}

Fixed version (ground truth):
private HashMap<Object,Object> readMap(final boolean doReadTag,final MapType constraint) throws IOException {
  if (doReadTag)   ensureTypeTag(null,TAG_MAP,readTypeTag());
  final int nElements=readSize();
  final HashMap<Object,Object> out=new HashMap<Object,Object>(nElements);
  if (nElements > 0) {
    final List<Object> keys=readElements(true,constraint != null ? constraint.keyType() : null);
    final List<Object> values=readElements(true,constraint != null ? constraint.valueType() : null);
    if (keys.size() != values.size() || keys.size() != nElements)     throw new StreamCorruptedException("String_Node_Str");
    for (int i=0; i < keys.size(); i++)     out.put(keys.get(i),values.get(i));
  }
  return out;
}
Program: 130569
Project: 130569
Buggy source:
private ArrayList<Object> readList(final boolean tag,final ListOrArrayType constraint) throws IOException {
  if (tag)   ensureTypeTag(null,TAG_LIST,readTypeTag());
  return readElements(constraint != null ? constraint.elementType() : null);
}

Fixed version (ground truth):
private ArrayList<Object> readList(final boolean tag,final ListOrArrayType constraint) throws IOException {
  if (tag)   ensureTypeTag(null,TAG_LIST,readTypeTag());
  return readElements(false,constraint != null ? constraint.elementType() : null);
}
Program: 130570
Project: 130570
Buggy source:
private ArrayList<Object> readElements(final Type constraint) throws IOException {
  final int nElements=readSize();
  final ArrayList<Object> out=new ArrayList<Object>(nElements);
  if (nElements > 0) {
    final byte readElemTag=readTypeTag();
    if (constraint != null && constraint.typeTag() != readElemTag)     throwUnexpectTag("String_Node_Str",constraint.typeTag(),readElemTag);
switch (readElemTag) {
case TAG_BOOL:
      for (int i=0; i < nElements; i++)       out.add(readBoolean(false));
    break;
case TAG_INT8:
  for (int i=0; i < nElements; i++)   out.add(readInt8(false));
break;
case TAG_INT16:
for (int i=0; i < nElements; i++) out.add(readInt16(false));
break;
case TAG_INT32:
for (int i=0; i < nElements; i++) out.add(readInt32(false));
break;
case TAG_INT64:
for (int i=0; i < nElements; i++) out.add(readInt64(false));
break;
case TAG_FLOAT32:
for (int i=0; i < nElements; i++) out.add(readFloat32(false));
break;
case TAG_FLOAT64:
for (int i=0; i < nElements; i++) out.add(readFloat64(false));
break;
case TAG_STRING:
if (constraint != null && constraint.typeEnum() == TypeEnum.ENUM) {
final EnumType t=(EnumType)constraint;
for (int i=0; i < nElements; i++) out.add(readEnum(false,t));
}
 else {
for (int i=0; i < nElements; i++) out.add(readFloat64(false));
}
break;
default :
for (int i=0; i < nElements; i++) out.add(readObject(readElemTag,constraint));
break;
}
}
return out;
}

Fixed version (ground truth):
private ArrayList<Object> readElements(final boolean doReadTag,final Type constraint) throws IOException {
  if (doReadTag)   ensureTypeTag(null,TAG_LIST,readTypeTag());
  final int nElements=readSize();
  final ArrayList<Object> out=new ArrayList<Object>(nElements);
  if (nElements > 0) {
    final byte readElemTag=readTypeTag();
    if (constraint != null && constraint.typeTag() != readElemTag)     throwUnexpectTag("String_Node_Str",constraint.typeTag(),readElemTag);
switch (readElemTag) {
case TAG_BOOL:
      for (int i=0; i < nElements; i++)       out.add(readBoolean(false));
    break;
case TAG_INT8:
  for (int i=0; i < nElements; i++)   out.add(readInt8(false));
break;
case TAG_INT16:
for (int i=0; i < nElements; i++) out.add(readInt16(false));
break;
case TAG_INT32:
for (int i=0; i < nElements; i++) out.add(readInt32(false));
break;
case TAG_INT64:
for (int i=0; i < nElements; i++) out.add(readInt64(false));
break;
case TAG_FLOAT32:
for (int i=0; i < nElements; i++) out.add(readFloat32(false));
break;
case TAG_FLOAT64:
for (int i=0; i < nElements; i++) out.add(readFloat64(false));
break;
case TAG_STRING:
if (constraint != null && constraint.typeEnum() == TypeEnum.ENUM) {
final EnumType t=(EnumType)constraint;
for (int i=0; i < nElements; i++) out.add(readEnum(false,t));
}
 else {
for (int i=0; i < nElements; i++) out.add(readString(false));
}
break;
default :
for (int i=0; i < nElements; i++) out.add(readObject(readElemTag,constraint));
break;
}
}
return out;
}
Program: 130572
Project: 130572
Buggy source:
/** 
 * get totalSize
 * @return the totalSize
 */
public int getTotalSize(){
  return totalSize;
}

Fixed version (ground truth):
/** 
 * get totalSize
 * @return the totalSize
 */
public long getTotalSize(){
  return totalSize;
}
Program: 130573
Project: 130573
Buggy source:
/** 
 * get finishedSize
 * @return the finishedSize
 */
public int getFinishedSize(){
  return finishedSize;
}

Fixed version (ground truth):
/** 
 * get finishedSize
 * @return the finishedSize
 */
public long getFinishedSize(){
  return finishedSize;
}
Program: 130574
Project: 130574
Buggy source:
/** 
 * set finishedSize
 * @param finishedSize the finishedSize to set
 */
public void setFinishedSize(int finishedSize){
  this.finishedSize=finishedSize;
}

Fixed version (ground truth):
/** 
 * set finishedSize
 * @param finishedSize the finishedSize to set
 */
public void setFinishedSize(long finishedSize){
  this.finishedSize=finishedSize;
}
Program: 130575
Project: 130575
Buggy source:
/** 
 * set totalSize
 * @param totalSize the totalSize to set
 */
public void setTotalSize(int totalSize){
  this.totalSize=totalSize;
}

Fixed version (ground truth):
/** 
 * set totalSize
 * @param totalSize the totalSize to set
 */
public void setTotalSize(long totalSize){
  this.totalSize=totalSize;
}
Program: 130576
Project: 130576
Buggy source:
private String formatSize(int finishedSize,int totalSize){
  StringBuilder sb=new StringBuilder(50);
  float finished=((float)finishedSize) / 1024 / 1024;
  if (finished < 1) {
    sb.append(String.format("String_Node_Str",((float)finishedSize) / 1024));
  }
 else {
    sb.append((String.format("String_Node_Str",finished)));
  }
  float total=((float)totalSize) / 1024 / 1024;
  if (total < 1) {
    sb.append(String.format("String_Node_Str",((float)totalSize) / 1024));
  }
 else {
    sb.append(String.format("String_Node_Str",total));
  }
  return sb.toString();
}

Fixed version (ground truth):
private String formatSize(long finishedSize,long totalSize){
  StringBuilder sb=new StringBuilder(50);
  float finished=((float)finishedSize) / 1024 / 1024;
  if (finished < 1) {
    sb.append(String.format("String_Node_Str",((float)finishedSize) / 1024));
  }
 else {
    sb.append((String.format("String_Node_Str",finished)));
  }
  float total=((float)totalSize) / 1024 / 1024;
  if (total < 1) {
    sb.append(String.format("String_Node_Str",((float)totalSize) / 1024));
  }
 else {
    sb.append(String.format("String_Node_Str",total));
  }
  return sb.toString();
}
Program: 130578
Project: 130578
Buggy source:
private boolean fetchConsensus(boolean forceDownload){
}

Fixed version (ground truth):
private boolean fetchConsensus(boolean forceDownload){
  routers=new TreeMap<>();
  try {
    File cachedConsensus=new File("String_Node_Str");
    SimpleDateFormat df=new SimpleDateFormat("String_Node_Str");
    BufferedReader consensusReader=null;
    PrintWriter cachedConsensusWriter=null;
    if (!forceDownload && cachedConsensus.exists() && cachedConsensus.canRead()) {
      BufferedReader rdr=new BufferedReader(new FileReader(cachedConsensus));
      String ln;
      while ((ln=rdr.readLine()) != null) {
        if (ln.startsWith("String_Node_Str")) {
          int idx=ln.indexOf("String_Node_Str");
          Date valid=df.parse(ln.substring(idx + 1) + "String_Node_Str");
          if (valid.after(new Date())) {
            log.info("String_Node_Str" + valid);
            consensusReader=rdr;
          }
          consensusValidUntil=valid;
          break;
        }
      }
    }
    if (consensusReader == null) {
      log.info("String_Node_Str");
      InputStream conStream=getDirectoryStream("String_Node_Str");
      consensusReader=new BufferedReader(new InputStreamReader(conStream));
      if (new File("String_Node_Str").canWrite())       cachedConsensusWriter=new PrintWriter(cachedConsensus);
    }
    String ln=null;
    OnionRouter cur=null;
    while ((ln=consensusReader.readLine()) != null) {
      if (cachedConsensusWriter != null)       cachedConsensusWriter.println(ln);
      if (ln.startsWith("String_Node_Str")) {
        int idx=ln.indexOf("String_Node_Str");
        consensusValidUntil=df.parse(ln.substring(idx + 1) + "String_Node_Str");
      }
      if (ln.startsWith("String_Node_Str")) {
        String dat[]=ln.split("String_Node_Str");
        if (dat.length < 8)         continue;
        String identityhex=Hex.encodeHexString(Base64.decodeBase64(dat[2]));
        cur=new OnionRouter(dat[1],identityhex,dat[6],Integer.parseInt(dat[7]),Integer.parseInt(dat[8]));
        routers.put(identityhex,cur);
      }
 else       if (ln.startsWith("String_Node_Str") && cur != null) {
        for (        String s : ln.split("String_Node_Str"))         if (!s.equals("String_Node_Str"))         cur.flags.add(s);
      }
 else       if (ln.startsWith("String_Node_Str") && cur != null) {
        String[] lineSplit=ln.split("String_Node_Str");
        if (lineSplit.length >= 3)         cur.consensusIPv4ExitPortSummary=lineSplit[1] + "String_Node_Str" + lineSplit[2];
      }
 else       if (ln.startsWith("String_Node_Str") && cur != null) {
        String[] lineSplit=ln.split("String_Node_Str");
        if (lineSplit.length >= 3) {
          cur.version=lineSplit[1] + "String_Node_Str" + lineSplit[2];
        }
      }
    }
  }
 catch (  MalformedURLException e) {
    return false;
  }
catch (  UnknownHostException e) {
    return false;
  }
catch (  IOException e) {
    return false;
  }
catch (  ParseException e) {
    e.printStackTrace();
    return false;
  }
  return true;
}
Program: 130581
Project: 130581
Buggy source:
/** 
 * Builds a relay cell payload (not including cell header, only relay header)
 * @param toHop Hop that it's destined for
 * @param cmd Command ID, see RELAY_
 * @param stream Stream ID
 * @param payload Relay cell data
 * @return Constructed relay payload
 */
protected synchronized byte[] buildRelay(TorHop toHop,int cmd,short stream,byte[] payload){
  byte[] fnl=new byte[509];
  ByteBuffer buf=ByteBuffer.wrap(fnl);
  buf.put((byte)cmd);
  buf.putShort((short)0);
  buf.putShort(stream);
  buf.putInt(0);
  buf.putShort((short)payload.length);
  buf.put(payload);
  toHop.df_md.update(fnl);
  MessageDigest md;
  try {
    md=(MessageDigest)toHop.df_md.clone();
    byte digest[]=md.digest();
    byte[] fnl_final=new byte[509];
    System.arraycopy(digest,0,fnl,5,4);
    return fnl;
  }
 catch (  CloneNotSupportedException e) {
    throw new RuntimeException(e);
  }
}

Fixed version (ground truth):
/** 
 * Builds a relay cell payload (not including cell header, only relay header)
 * @param toHop Hop that it's destined for
 * @param cmd Command ID, see RELAY_
 * @param stream Stream ID
 * @param payload Relay cell data
 * @return Constructed relay payload
 */
protected synchronized byte[] buildRelay(TorHop toHop,int cmd,short stream,byte[] payload){
  byte[] fnl=new byte[509];
  ByteBuffer buf=ByteBuffer.wrap(fnl);
  buf.put((byte)cmd);
  buf.putShort((short)0);
  buf.putShort(stream);
  buf.putInt(0);
  if (payload != null) {
    buf.putShort((short)payload.length);
    buf.put(payload);
  }
 else {
    buf.putShort((short)0);
  }
  toHop.df_md.update(fnl);
  MessageDigest md;
  try {
    md=(MessageDigest)toHop.df_md.clone();
    byte digest[]=md.digest();
    byte[] fnl_final=new byte[509];
    System.arraycopy(digest,0,fnl,5,4);
    return fnl;
  }
 catch (  CloneNotSupportedException e) {
    throw new RuntimeException(e);
  }
}
Program: 130582
Project: 130582
Buggy source:
/** 
 * Removes onion skins for received data
 * @param data Encrypted data for onion skin removal.
 * @return Decrypted data.
 */
private byte[] decrypt(byte[] data){
  for (int i=0; i < hops.size(); i++) {
    data=hops.get(i).decrypt(data);
    if (data[1] == 0 && data[2] == 0)     if (i != hops.size() - 1) {
      System.out.println("String_Node_Str" + hops.get(i));
      return data;
    }
  }
  return data;
}

Fixed version (ground truth):
/** 
 * Removes onion skins for received data
 * @param data Encrypted data for onion skin removal.
 * @return Decrypted data.
 */
private byte[] decrypt(byte[] data){
  for (int i=0; i < hops.size(); i++) {
    data=hops.get(i).decrypt(data);
  }
  return data;
}
Program: 130583
Project: 130583
Buggy source:
/** 
 * Internal function. Used to add received bytes to object.
 * @param b Bytes
 */
protected void _putRecved(byte b[]){
  recvWindow--;
  if (recvWindow < 450) {
    try {
      circ.send(new byte[]{00},TorCircuit.RELAY_SENDME,false,(short)streamId);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    recvWindow+=recvWindowIncrement;
  }
  recv.put(b);
  if (listener != null)   listener.dataArrived(this);
synchronized (this) {
    this.notifyAll();
  }
}

Fixed version (ground truth):
/** 
 * Internal function. Used to add received bytes to object.
 * @param b Bytes
 */
protected void _putRecved(byte b[]){
  recvWindow--;
  if (recvWindow < 450) {
    try {
      circ.send(null,TorCircuit.RELAY_SENDME,false,(short)streamId);
    }
 catch (    IOException e) {
      e.printStackTrace();
    }
    recvWindow+=recvWindowIncrement;
  }
  recv.put(b);
  if (listener != null)   listener.dataArrived(this);
synchronized (this) {
    this.notifyAll();
  }
}
Program: 130584
Project: 130584
Buggy source:
@Override public void dataArrived(TorStream s){
  try {
    if (!client.isConnected())     removeClient(this);
    client.write(ByteBuffer.wrap(s.recv(-1,false)));
  }
 catch (  IOException e) {
    try {
      removeClient(this);
    }
 catch (    IOException e1) {
      e1.printStackTrace();
    }
    e.printStackTrace();
  }
}

Fixed version (ground truth):
@Override public void dataArrived(TorStream s){
  try {
    if (!client.isConnected())     removeClient(this);
    client.write(ByteBuffer.wrap(s.recv(-1,false)));
  }
 catch (  IOException e) {
    try {
      removeClient(this);
    }
 catch (    IOException e1) {
    }
  }
  lastData=System.currentTimeMillis();
}
Program: 130585
Project: 130585
Buggy source:
public void removeClient(SocksClient c) throws IOException {
  c.client.close();
  c.stream.destroy();
  clients.remove(c);
}

Fixed version (ground truth):
public void removeClient(SocksClient c) throws IOException {
  c.client.close();
  c.stream.destroy();
  clients.remove(c.client);
}
Program: 130587
Project: 130587
Buggy source:
public SocksClient addClient(SocketChannel s,TorCircuit circ){
  SocksClient cl;
  try {
    cl=new SocksClient(s,circ);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
  clients.add(cl);
  return cl;
}

Fixed version (ground truth):
public SocksClient addClient(SocketChannel s,TorCircuit circ){
  SocksClient cl;
  try {
    cl=new SocksClient(s,circ);
  }
 catch (  IOException e) {
    e.printStackTrace();
    return null;
  }
  clients.put(s,cl);
  return cl;
}