Program: 92949
Project: 92949
Buggy source:
public void produce(ProduceTask task,String topic,Integer partition,Collection<? extends ProduceRecord<JsonNode,JsonNode>> records){
  SchemaHolder schemaHolder=task.getSchemaHolder();
  Schema keySchema=null, valueSchema=null;
  Integer keySchemaId=schemaHolder.getKeySchemaId();
  Integer valueSchemaId=schemaHolder.getValueSchemaId();
  try {
    if (keySchemaId != null) {
      keySchema=keySerializer.getByID(keySchemaId);
    }
 else     if (schemaHolder.getKeySchema() != null) {
      keySchema=new Schema.Parser().parse(schemaHolder.getKeySchema());
      keySchemaId=keySerializer.register(topic + "String_Node_Str",keySchema);
    }
    if (valueSchemaId != null) {
      valueSchema=valueSerializer.getByID(valueSchemaId);
    }
 else     if (schemaHolder.getValueSchema() != null) {
      valueSchema=new Schema.Parser().parse(schemaHolder.getValueSchema());
      valueSchemaId=valueSerializer.register(topic + "String_Node_Str",valueSchema);
    }
  }
 catch (  RestClientException e) {
    throw new RestException("String_Node_Str",408,40801,e);
  }
catch (  SchemaParseException e) {
    throw Errors.invalidSchemaException(e);
  }
catch (  IOException e) {
    throw new RestException("String_Node_Str",408,40801,e);
  }
  task.setSchemaIds(keySchemaId,valueSchemaId);
  ArrayList<ProducerRecord<Object,Object>> kafkaRecords=new ArrayList<ProducerRecord<Object,Object>>();
  try {
    for (    ProduceRecord<JsonNode,JsonNode> record : records) {
      Object key=(keySchema != null ? AvroConverter.toAvro(record.getKey(),keySchema) : null);
      Object value=(valueSchema != null ? AvroConverter.toAvro(record.getValue(),valueSchema) : null);
      Integer recordPartition=partition;
      if (recordPartition == null) {
        recordPartition=record.partition();
      }
      kafkaRecords.add(new ProducerRecord(topic,recordPartition,key,value));
    }
  }
 catch (  ConversionException e) {
    throw Errors.jsonAvroConversionException(e);
  }
  for (  ProducerRecord<Object,Object> rec : kafkaRecords) {
    producer.send(rec,task.createCallback());
  }
}

Fixed version (ground truth):
public void produce(ProduceTask task,String topic,Integer partition,Collection<? extends ProduceRecord<JsonNode,JsonNode>> records){
  SchemaHolder schemaHolder=task.getSchemaHolder();
  Schema keySchema=null, valueSchema=null;
  Integer keySchemaId=schemaHolder.getKeySchemaId();
  Integer valueSchemaId=schemaHolder.getValueSchemaId();
  try {
    if (keySchemaId != null) {
      keySchema=keySerializer.getByID(keySchemaId);
    }
 else     if (schemaHolder.getKeySchema() != null) {
      keySchema=new Schema.Parser().parse(schemaHolder.getKeySchema());
      if (schemaIdCache.containsKey(keySchema)) {
        keySchemaId=schemaIdCache.get(keySchema);
      }
 else {
        keySchemaId=keySerializer.register(topic + "String_Node_Str",keySchema);
        schemaIdCache.put(keySchema,keySchemaId);
      }
    }
    if (valueSchemaId != null) {
      valueSchema=valueSerializer.getByID(valueSchemaId);
    }
 else     if (schemaHolder.getValueSchema() != null) {
      valueSchema=new Schema.Parser().parse(schemaHolder.getValueSchema());
      if (schemaIdCache.containsKey(valueSchema)) {
        valueSchemaId=schemaIdCache.get(valueSchema);
      }
 else {
        valueSchemaId=valueSerializer.register(topic + "String_Node_Str",valueSchema);
        schemaIdCache.put(valueSchema,valueSchemaId);
      }
    }
  }
 catch (  RestClientException e) {
    throw new RestException("String_Node_Str",408,40801,e);
  }
catch (  SchemaParseException e) {
    throw Errors.invalidSchemaException(e);
  }
catch (  IOException e) {
    throw new RestException("String_Node_Str",408,40801,e);
  }
  task.setSchemaIds(keySchemaId,valueSchemaId);
  ArrayList<ProducerRecord<Object,Object>> kafkaRecords=new ArrayList<ProducerRecord<Object,Object>>();
  try {
    for (    ProduceRecord<JsonNode,JsonNode> record : records) {
      Object key=(keySchema != null ? AvroConverter.toAvro(record.getKey(),keySchema) : null);
      Object value=(valueSchema != null ? AvroConverter.toAvro(record.getValue(),valueSchema) : null);
      Integer recordPartition=partition;
      if (recordPartition == null) {
        recordPartition=record.partition();
      }
      kafkaRecords.add(new ProducerRecord(topic,recordPartition,key,value));
    }
  }
 catch (  ConversionException e) {
    throw Errors.jsonAvroConversionException(e);
  }
  for (  ProducerRecord<Object,Object> rec : kafkaRecords) {
    producer.send(rec,task.createCallback());
  }
}