Program: 3524
Project: 3524
Buggy source:
private void writeInjectMethod(JavaWriter jw,TypeElement element,AnnotatedFragment fragment) throws IOException, ProcessingException {
  Set<ArgumentAnnotatedField> allArguments=fragment.getAll();
  String fragmentType=supportAnnotations ? "String_Node_Str" + element.getSimpleName().toString() : element.getSimpleName().toString();
  jw.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.FINAL,Modifier.STATIC),fragmentType,"String_Node_Str");
  if (!allArguments.isEmpty()) {
    jw.emitStatement("String_Node_Str");
    if (!fragment.getRequiredFields().isEmpty()) {
      jw.beginControlFlow("String_Node_Str");
      jw.emitStatement("String_Node_Str");
      jw.endControlFlow();
    }
  }
  int setterAssignmentHelperCounter=0;
  for (  ArgumentAnnotatedField field : allArguments) {
    jw.emitEmptyLine();
    String setterMethod=null;
    boolean useSetter=field.isUseSetterMethod();
    if (useSetter) {
      ExecutableElement setterMethodElement=fragment.findSetterForField(field);
      setterMethod=setterMethodElement.getSimpleName().toString();
    }
    if (field.hasCustomBundler()) {
      String setterAssignmentHelperStr=null;
      String assignmentStr;
      if (useSetter) {
        setterAssignmentHelperStr=field.getType() + "String_Node_Str" + setterAssignmentHelperCounter+ "String_Node_Str";
        assignmentStr="String_Node_Str" + setterAssignmentHelperCounter + "String_Node_Str";
        setterAssignmentHelperCounter++;
      }
 else {
        assignmentStr="String_Node_Str";
      }
      if (field.isRequired()) {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(CUSTOM_BUNDLER_BUNDLE_KEY + field.getKey()) + "String_Node_Str");
        jw.emitStatement("String_Node_Str",field.getKey());
        jw.endControlFlow();
        if (useSetter) {
          jw.emitStatement(setterAssignmentHelperStr,field.getBundlerFieldName(),field.getKey());
          jw.emitStatement(assignmentStr,setterMethod);
        }
 else {
          jw.emitStatement(assignmentStr,field.getName(),field.getBundlerFieldName(),field.getKey());
        }
      }
 else {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(CUSTOM_BUNDLER_BUNDLE_KEY + field.getKey()) + "String_Node_Str");
        if (useSetter) {
          jw.emitStatement(setterAssignmentHelperStr,field.getBundlerFieldName(),field.getKey());
          jw.emitStatement(assignmentStr,setterMethod);
        }
 else {
          jw.emitStatement(assignmentStr,field.getName(),field.getBundlerFieldName(),field.getKey());
        }
        jw.endControlFlow();
      }
    }
 else {
      String op=getOperation(field);
      if (op == null) {
        throw new ProcessingException(element,"String_Node_Str" + "String_Node_Str",ArgsBundler.class.getSimpleName());
      }
      String cast="String_Node_Str".equals(op) ? "String_Node_Str" + field.getType() + "String_Node_Str" : "String_Node_Str";
      if (!field.isRequired()) {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(field.getKey()) + "String_Node_Str");
      }
 else {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(field.getKey()) + "String_Node_Str");
        jw.emitStatement("String_Node_Str",field.getKey());
        jw.endControlFlow();
      }
      if (useSetter) {
        jw.emitStatement("String_Node_Str",setterMethod,op,field.getKey(),cast);
      }
 else {
        jw.emitStatement("String_Node_Str",field.getName(),op,field.getKey(),cast);
      }
      if (!field.isRequired()) {
        jw.endControlFlow();
      }
    }
  }
  jw.endMethod();
}

Fixed version (ground truth):
private void writeInjectMethod(JavaWriter jw,TypeElement element,AnnotatedFragment fragment) throws IOException, ProcessingException {
  Set<ArgumentAnnotatedField> allArguments=fragment.getAll();
  String fragmentType=supportAnnotations ? "String_Node_Str" + element.getSimpleName().toString() : element.getSimpleName().toString();
  jw.beginMethod("String_Node_Str","String_Node_Str",EnumSet.of(Modifier.PUBLIC,Modifier.FINAL,Modifier.STATIC),fragmentType,"String_Node_Str");
  if (!allArguments.isEmpty()) {
    jw.emitStatement("String_Node_Str");
    if (!fragment.getRequiredFields().isEmpty()) {
      jw.beginControlFlow("String_Node_Str");
      jw.emitStatement("String_Node_Str");
      jw.endControlFlow();
    }
  }
  int setterAssignmentHelperCounter=0;
  for (  ArgumentAnnotatedField field : allArguments) {
    jw.emitEmptyLine();
    String setterMethod=null;
    boolean useSetter=field.isUseSetterMethod();
    if (useSetter) {
      ExecutableElement setterMethodElement=fragment.findSetterForField(field);
      setterMethod=setterMethodElement.getSimpleName().toString();
    }
    if (field.hasCustomBundler()) {
      String setterAssignmentHelperStr=null;
      String assignmentStr;
      if (useSetter) {
        setterAssignmentHelperStr=field.getType() + "String_Node_Str" + setterAssignmentHelperCounter+ "String_Node_Str";
        assignmentStr="String_Node_Str" + setterAssignmentHelperCounter + "String_Node_Str";
        setterAssignmentHelperCounter++;
      }
 else {
        assignmentStr="String_Node_Str";
      }
      if (field.isRequired()) {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(CUSTOM_BUNDLER_BUNDLE_KEY + field.getKey()) + "String_Node_Str");
        jw.emitStatement("String_Node_Str",field.getKey());
        jw.endControlFlow();
        if (useSetter) {
          jw.emitStatement(setterAssignmentHelperStr,field.getBundlerFieldName(),field.getKey());
          jw.emitStatement(assignmentStr,setterMethod);
        }
 else {
          jw.emitStatement(assignmentStr,field.getName(),field.getBundlerFieldName(),field.getKey());
        }
      }
 else {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(CUSTOM_BUNDLER_BUNDLE_KEY + field.getKey()) + "String_Node_Str");
        if (useSetter) {
          jw.emitStatement(setterAssignmentHelperStr,field.getBundlerFieldName(),field.getKey());
          jw.emitStatement(assignmentStr,setterMethod);
        }
 else {
          jw.emitStatement(assignmentStr,field.getName(),field.getBundlerFieldName(),field.getKey());
        }
        jw.endControlFlow();
      }
    }
 else {
      String op=getOperation(field);
      if (op == null) {
        throw new ProcessingException(element,"String_Node_Str" + "String_Node_Str",ArgsBundler.class.getSimpleName());
      }
      String cast="String_Node_Str".equals(op) ? "String_Node_Str" + field.getType() + "String_Node_Str" : "String_Node_Str";
      if (!field.isRequired()) {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(field.getKey()) + "String_Node_Str");
      }
 else {
        jw.beginControlFlow("String_Node_Str" + JavaWriter.stringLiteral(field.getKey()) + "String_Node_Str");
        jw.emitStatement("String_Node_Str",field.getKey());
        jw.endControlFlow();
      }
      if (useSetter) {
        jw.emitStatement("String_Node_Str" + setterAssignmentHelperCounter + "String_Node_Str",field.getType(),op,field.getKey(),cast);
        jw.emitStatement("String_Node_Str" + setterAssignmentHelperCounter + "String_Node_Str",setterMethod);
        setterAssignmentHelperCounter++;
      }
 else {
        jw.emitStatement("String_Node_Str",field.getName(),op,field.getKey(),cast);
      }
      if (!field.isRequired()) {
        jw.endControlFlow();
      }
    }
  }
  jw.endMethod();
}