Program: 80173
Project: 80173
Buggy source:
/** 
 * When doing the   {@link org.apache.gora.cassandra.store.CassandraStore#put(Object,PersistentBase)}operation, the logic is as follows: <ol> <li>Obtain the Avro   {@link org.apache.avro.Schema} for the object.</li><li>Create a new duplicate instance of the object (explained in more detail below) **.</li> <li>Obtain a  {@link java.util.List} of the {@link org.apache.avro.Schema} {@link org.apache.avro.Schema.Field}'s.</li> <li>Iterate through the field   {@link java.util.List}. This allows us to  consequently process each item.</li> <li>Check to see if the   {@link org.apache.avro.Schema.Field} is NOT dirty. If this condition is true then we DO NOT process this field.</li> <li>Obtain the element at the specified position in this list so we can  directly operate on it.</li> <li>Obtain the  {@link org.apache.avro.Schema.Type} of the element obtained above and process it accordingly. N.B. For nested type ARRAY, MAP RECORD or UNION, we shadow the checks in bullet point 5 above to infer that the  {@link org.apache.avro.Schema.Field} is either at position 0 OR it is NOT dirty. If one of these conditions is true then we DO NOT process this field. This is carried out in  {@link org.apache.gora.cassandra.store.CassandraStore#getFieldValue(Schema,Type,Object)}</li> <li>We then insert the Key and Object into the   {@link java.util.LinkedHashMap} buffer before being flushed. This performs a structural modification of the map.</li> </ol> ** We create a duplicate instance of the object to be persisted and insert processed objects into a synchronized  {@link java.util.LinkedHashMap}. This allows  us to keep all the objects in memory till flushing.
 * @see org.apache.gora.store.DataStore#put(java.lang.Object, 
   * org.apache.gora.persistency.Persistent).
 * @param key for the Avro Record (object).
 * @param value Record object to be persisted in Cassandra
 */
@Override public void put(K key,T value){
  Schema schema=value.getSchema();
  @SuppressWarnings("String_Node_Str") T p=(T)SpecificData.get().newRecord(value,schema);
  List<Field> fields=schema.getFields();
  for (int i=1; i < fields.size(); i++) {
    if (!value.isDirty(i)) {
      continue;
    }
    Field field=fields.get(i);
    Type type=field.schema().getType();
    Object fieldValue=value.get(field.pos());
    Schema fieldSchema=field.schema();
    fieldValue=getFieldValue(fieldSchema,type,fieldValue);
    p.put(field.pos(),fieldValue);
  }
  this.buffer.put(key,p);
}

Fixed version (ground truth):
/** 
 * When doing the  {@link org.apache.gora.cassandra.store.CassandraStore#put(Object,PersistentBase)}operation, the logic is as follows: <ol> <li>Obtain the Avro   {@link org.apache.avro.Schema} for the object.</li><li>Create a new duplicate instance of the object (explained in more detail below) **.</li> <li>Obtain a  {@link java.util.List} of the {@link org.apache.avro.Schema}{@link org.apache.avro.Schema.Field}'s.</li> <li>Iterate through the field   {@link java.util.List}. This allows us to consequently process each item.</li> <li>Check to see if the   {@link org.apache.avro.Schema.Field} is NOT dirty.If this condition is true then we DO NOT process this field.</li> <li>Obtain the element at the specified position in this list so we can directly operate on it.</li> <li>Obtain the  {@link org.apache.avro.Schema.Type} of the element obtainedabove and process it accordingly. N.B. For nested type ARRAY, MAP RECORD or UNION, we shadow the checks in bullet point 5 above to infer that the {@link org.apache.avro.Schema.Field} is either atposition 0 OR it is NOT dirty. If one of these conditions is true then we DO NOT process this field. This is carried out in {@link org.apache.gora.cassandra.store.CassandraStore#getFieldValue(Schema,Type,Object)}</li> <li>We then insert the Key and Object into the   {@link java.util.LinkedHashMap} bufferbefore being flushed. This performs a structural modification of the map.</li> </ol> ** We create a duplicate instance of the object to be persisted and insert processed objects into a synchronized  {@link java.util.LinkedHashMap}. This allows us to keep all the objects in memory till flushing.
 * @param key   for the Avro Record (object).
 * @param value Record object to be persisted in Cassandra
 * @see org.apache.gora.store.DataStore#put(java.lang.Object,org.apache.gora.persistency.Persistent)
 */
@Override public void put(K key,T value){
  Schema schema=value.getSchema();
  @SuppressWarnings("String_Node_Str") T p=(T)SpecificData.get().newRecord(value,schema);
  List<Field> fields=schema.getFields();
  for (int i=1; i < fields.size(); i++) {
    if (!value.isDirty(i)) {
      continue;
    }
    Field field=fields.get(i);
    Type type=field.schema().getType();
    Object fieldValue=value.get(field.pos());
    Schema fieldSchema=field.schema();
    fieldValue=getFieldValue(fieldSchema,type,fieldValue);
    p.put(field.pos(),fieldValue);
  }
  this.buffer.put(key,p);
}