Program: 27037
Project: 27037
Buggy source:
public void writeSaveDefinition(JavaWriter javaWriter,boolean isModelContainerAdapter,boolean isContentValues,AtomicInteger columnCount) throws IOException {
  if (isForeignKey && isModel) {
    if (fieldIsModelContainer) {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
 else {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
    if (isModelContainerAdapter) {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
    String modelDefinition=isModelContainerAdapter ? (ModelUtils.getVariable(true) + columnFieldName) : ModelUtils.getModelStatement(columnFieldName);
    if (isModelContainerAdapter) {
      javaWriter.emitStatement("String_Node_Str",modelDefinition,ModelUtils.getVariable(true),ModelUtils.getVariable(true),columnFieldName,columnFieldType);
    }
 else {
      javaWriter.beginControlFlow("String_Node_Str",modelDefinition);
    }
    if (saveModelForeignKey) {
      javaWriter.emitStatement("String_Node_Str",modelDefinition);
    }
    List<AdapterQueryBuilder> elseNullPuts=new ArrayList<>();
    for (    ForeignKeyReference foreignKeyReference : foreignKeyReferences) {
      ColumnAccessModel columnAccessModel=new ColumnAccessModel(this,foreignKeyReference);
      ForeignKeyContainerModel foreignKeyContainerModel=new ForeignKeyContainerModel(columnAccessModel,isContentValues);
      foreignKeyContainerModel.setModelContainerName(modelDefinition);
      foreignKeyContainerModel.setIndex(columnCount.intValue());
      foreignKeyContainerModel.setIsModelContainerDefinition(isModelContainerAdapter);
      foreignKeyContainerModel.setPutValue(foreignKeyReference.columnName());
      foreignKeyContainerModel.write(javaWriter);
      if (!isModelContainerAdapter) {
        elseNullPuts.add(foreignKeyContainerModel.getNullStatement());
      }
      columnCount.incrementAndGet();
    }
    if (!isModelContainerAdapter) {
      javaWriter.nextControlFlow("String_Node_Str");
      for (      AdapterQueryBuilder queryBuilder : elseNullPuts) {
        javaWriter.emitStatement(queryBuilder.getQuery());
      }
      javaWriter.endControlFlow();
    }
  }
 else {
    String getType=columnFieldType;
    boolean isPrimitive=element.asType().getKind().isPrimitive();
    if (isPrimitive) {
      getType=manager.getTypeUtils().boxedClass((PrimitiveType)element.asType()).asType().toString();
    }
    ColumnAccessModel columnAccessModel=new ColumnAccessModel(manager,this,isModelContainerAdapter);
    ContentValueModel contentValueModel=new ContentValueModel(columnAccessModel,isContentValues);
    contentValueModel.setPutValue(columnName);
    contentValueModel.setIndex(columnCount.intValue());
    contentValueModel.setDatabaseTypeName(getType);
    contentValueModel.write(javaWriter);
    columnCount.incrementAndGet();
  }
}

Fixed version (ground truth):
public void writeSaveDefinition(JavaWriter javaWriter,boolean isModelContainerAdapter,boolean isContentValues,AtomicInteger columnCount) throws IOException {
  if (isForeignKey && isModel) {
    if (fieldIsModelContainer) {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
 else {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
    if (isModelContainerAdapter) {
      javaWriter.emitSingleLineComment("String_Node_Str");
    }
    String modelDefinition=isModelContainerAdapter ? (ModelUtils.getVariable(true) + columnFieldName) : ModelUtils.getModelStatement(columnFieldName);
    if (isModelContainerAdapter) {
      javaWriter.emitStatement("String_Node_Str",modelDefinition,ModelUtils.getVariable(true),ModelUtils.getVariable(true),columnFieldName,foreignKeyTableClassName);
    }
 else {
      javaWriter.beginControlFlow("String_Node_Str",modelDefinition);
    }
    if (saveModelForeignKey) {
      javaWriter.emitStatement("String_Node_Str",modelDefinition);
    }
    List<AdapterQueryBuilder> elseNullPuts=new ArrayList<>();
    for (    ForeignKeyReference foreignKeyReference : foreignKeyReferences) {
      ColumnAccessModel columnAccessModel=new ColumnAccessModel(this,foreignKeyReference);
      ForeignKeyContainerModel foreignKeyContainerModel=new ForeignKeyContainerModel(columnAccessModel,isContentValues);
      foreignKeyContainerModel.setModelContainerName(modelDefinition);
      foreignKeyContainerModel.setIndex(columnCount.intValue());
      foreignKeyContainerModel.setIsModelContainerDefinition(isModelContainerAdapter);
      foreignKeyContainerModel.setPutValue(foreignKeyReference.columnName());
      foreignKeyContainerModel.write(javaWriter);
      if (!isModelContainerAdapter) {
        elseNullPuts.add(foreignKeyContainerModel.getNullStatement());
      }
      columnCount.incrementAndGet();
    }
    if (!isModelContainerAdapter) {
      javaWriter.nextControlFlow("String_Node_Str");
      for (      AdapterQueryBuilder queryBuilder : elseNullPuts) {
        javaWriter.emitStatement(queryBuilder.getQuery());
      }
      javaWriter.endControlFlow();
    }
  }
 else {
    String getType=columnFieldType;
    boolean isPrimitive=element.asType().getKind().isPrimitive();
    if (isPrimitive) {
      getType=manager.getTypeUtils().boxedClass((PrimitiveType)element.asType()).asType().toString();
    }
    ColumnAccessModel columnAccessModel=new ColumnAccessModel(manager,this,isModelContainerAdapter);
    ContentValueModel contentValueModel=new ContentValueModel(columnAccessModel,isContentValues);
    contentValueModel.setPutValue(columnName);
    contentValueModel.setIndex(columnCount.intValue());
    contentValueModel.setDatabaseTypeName(getType);
    contentValueModel.write(javaWriter);
    columnCount.incrementAndGet();
  }
}