Program: 26908
Project: 26908
Buggy source:
@Override public MethodSpec getMethodSpec(){
  MethodSpec.Builder methodBuilder=MethodSpec.methodBuilder("String_Node_Str").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC,Modifier.FINAL).returns(ClassName.get(String.class));
  CodeBlock.Builder creationBuilder=CodeBlock.builder().add("String_Node_Str").add(QueryBuilder.quote(tableDefinition.tableName)).add("String_Node_Str");
  for (int i=0; i < tableDefinition.getColumnDefinitions().size(); i++) {
    if (i > 0) {
      creationBuilder.add("String_Node_Str");
    }
    ColumnDefinition columnDefinition=tableDefinition.getColumnDefinitions().get(i);
    creationBuilder.add(columnDefinition.getCreationName());
  }
  for (  UniqueGroupsDefinition definition : tableDefinition.uniqueGroupsDefinitions) {
    creationBuilder.add(definition.getCreationName());
  }
  int primarySize=tableDefinition.getPrimaryColumnDefinitions().size();
  for (int i=0; i < primarySize; i++) {
    if (i == 0) {
      creationBuilder.add("String_Node_Str");
    }
    if (i > 0) {
      creationBuilder.add("String_Node_Str");
    }
    ColumnDefinition primaryDefinition=tableDefinition.getPrimaryColumnDefinitions().get(i);
    creationBuilder.add(QueryBuilder.quote(primaryDefinition.columnName));
    if (i == primarySize - 1) {
      creationBuilder.add("String_Node_Str");
    }
  }
  int foreignSize=tableDefinition.foreignKeyDefinitions.size();
  List<CodeBlock> foreignKeyBlocks=new ArrayList<>();
  List<CodeBlock> tableNameBlocks=new ArrayList<>();
  List<CodeBlock> referenceKeyBlocks=new ArrayList<>();
  for (int i=0; i < foreignSize; i++) {
    CodeBlock.Builder foreignKeyBuilder=CodeBlock.builder();
    CodeBlock.Builder referenceBuilder=CodeBlock.builder();
    ForeignKeyColumnDefinition foreignKeyColumnDefinition=tableDefinition.foreignKeyDefinitions.get(i);
    foreignKeyBuilder.add("String_Node_Str");
    for (int j=0; j < foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.size(); j++) {
      if (j > 0) {
        foreignKeyBuilder.add("String_Node_Str");
      }
      ForeignKeyReferenceDefinition referenceDefinition=foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.get(j);
      foreignKeyBuilder.add("String_Node_Str",QueryBuilder.quote(referenceDefinition.columnName));
    }
    foreignKeyBuilder.add("String_Node_Str");
    foreignKeyBlocks.add(foreignKeyBuilder.build());
    tableNameBlocks.add(CodeBlock.builder().add("String_Node_Str",ClassNames.FLOW_MANAGER,foreignKeyColumnDefinition.referencedTableClassName).build());
    referenceBuilder.add("String_Node_Str");
    for (int j=0; j < foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.size(); j++) {
      if (j > 0) {
        referenceBuilder.add("String_Node_Str");
      }
      ForeignKeyReferenceDefinition referenceDefinition=foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.get(i);
      referenceBuilder.add("String_Node_Str",QueryBuilder.quote(referenceDefinition.foreignColumnName));
    }
    referenceBuilder.add("String_Node_Str",foreignKeyColumnDefinition.onUpdate.name().replace("String_Node_Str","String_Node_Str"),foreignKeyColumnDefinition.onDelete.name().replace("String_Node_Str","String_Node_Str"));
    referenceKeyBlocks.add(referenceBuilder.build());
  }
  CodeBlock.Builder codeBuilder=CodeBlock.builder().add("String_Node_Str",creationBuilder.build().toString());
  if (foreignSize > 0) {
    for (int i=0; i < foreignSize; i++) {
      codeBuilder.add("String_Node_Str",foreignKeyBlocks.get(i),tableNameBlocks.get(i),referenceKeyBlocks.get(i));
    }
  }
  codeBuilder.add("String_Node_Str","String_Node_Str").add("String_Node_Str");
  methodBuilder.addCode(codeBuilder.build());
  return methodBuilder.build();
}

Fixed version (ground truth):
@Override public MethodSpec getMethodSpec(){
  MethodSpec.Builder methodBuilder=MethodSpec.methodBuilder("String_Node_Str").addAnnotation(Override.class).addModifiers(Modifier.PUBLIC,Modifier.FINAL).returns(ClassName.get(String.class));
  CodeBlock.Builder creationBuilder=CodeBlock.builder().add("String_Node_Str").add(QueryBuilder.quote(tableDefinition.tableName)).add("String_Node_Str");
  for (int i=0; i < tableDefinition.getColumnDefinitions().size(); i++) {
    if (i > 0) {
      creationBuilder.add("String_Node_Str");
    }
    ColumnDefinition columnDefinition=tableDefinition.getColumnDefinitions().get(i);
    creationBuilder.add(columnDefinition.getCreationName());
  }
  for (  UniqueGroupsDefinition definition : tableDefinition.uniqueGroupsDefinitions) {
    creationBuilder.add(definition.getCreationName());
  }
  int primarySize=tableDefinition.getPrimaryColumnDefinitions().size();
  for (int i=0; i < primarySize; i++) {
    if (i == 0) {
      creationBuilder.add("String_Node_Str");
    }
    if (i > 0) {
      creationBuilder.add("String_Node_Str");
    }
    ColumnDefinition primaryDefinition=tableDefinition.getPrimaryColumnDefinitions().get(i);
    creationBuilder.add(QueryBuilder.quote(primaryDefinition.columnName));
    if (i == primarySize - 1) {
      creationBuilder.add("String_Node_Str");
    }
  }
  int foreignSize=tableDefinition.foreignKeyDefinitions.size();
  List<CodeBlock> foreignKeyBlocks=new ArrayList<>();
  List<CodeBlock> tableNameBlocks=new ArrayList<>();
  List<CodeBlock> referenceKeyBlocks=new ArrayList<>();
  for (int i=0; i < foreignSize; i++) {
    CodeBlock.Builder foreignKeyBuilder=CodeBlock.builder();
    CodeBlock.Builder referenceBuilder=CodeBlock.builder();
    ForeignKeyColumnDefinition foreignKeyColumnDefinition=tableDefinition.foreignKeyDefinitions.get(i);
    foreignKeyBuilder.add("String_Node_Str");
    for (int j=0; j < foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.size(); j++) {
      if (j > 0) {
        foreignKeyBuilder.add("String_Node_Str");
      }
      ForeignKeyReferenceDefinition referenceDefinition=foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.get(j);
      foreignKeyBuilder.add("String_Node_Str",QueryBuilder.quote(referenceDefinition.columnName));
    }
    foreignKeyBuilder.add("String_Node_Str");
    foreignKeyBlocks.add(foreignKeyBuilder.build());
    tableNameBlocks.add(CodeBlock.builder().add("String_Node_Str",ClassNames.FLOW_MANAGER,foreignKeyColumnDefinition.referencedTableClassName).build());
    referenceBuilder.add("String_Node_Str");
    for (int j=0; j < foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.size(); j++) {
      if (j > 0) {
        referenceBuilder.add("String_Node_Str");
      }
      ForeignKeyReferenceDefinition referenceDefinition=foreignKeyColumnDefinition.foreignKeyReferenceDefinitionList.get(j);
      referenceBuilder.add("String_Node_Str",QueryBuilder.quote(referenceDefinition.foreignColumnName));
    }
    referenceBuilder.add("String_Node_Str",foreignKeyColumnDefinition.onUpdate.name().replace("String_Node_Str","String_Node_Str"),foreignKeyColumnDefinition.onDelete.name().replace("String_Node_Str","String_Node_Str"));
    referenceKeyBlocks.add(referenceBuilder.build());
  }
  CodeBlock.Builder codeBuilder=CodeBlock.builder().add("String_Node_Str",creationBuilder.build().toString());
  if (foreignSize > 0) {
    for (int i=0; i < foreignSize; i++) {
      codeBuilder.add("String_Node_Str",foreignKeyBlocks.get(i),tableNameBlocks.get(i),referenceKeyBlocks.get(i));
    }
  }
  codeBuilder.add("String_Node_Str","String_Node_Str").add("String_Node_Str");
  methodBuilder.addCode(codeBuilder.build());
  return methodBuilder.build();
}