Program: 17410
Project: 17410
Buggy source:
public static CQLStatementIterator makeCQLforUpdate(String keyspace,CDefinition def,UUID key,Map<String,Object> oldValues,Map<String,Object> newValues) throws CQLGenerationException {
  List<CQLStatement> ret=Lists.newArrayList();
  List<CIndex> effectedIndexes=getEffectedIndexes(def,oldValues,newValues);
  List<CIndex> uneffectedIndexes=getUneffectedIndexes(def,oldValues,newValues);
  for (  CIndex i : effectedIndexes) {
    ret.add(makeCQLforDeleteUUIDFromIndex(keyspace,def,i,key,i.getIndexKeyAndValues(oldValues),null));
  }
  Map<String,Object> completeValues=Maps.newHashMap(oldValues);
  for (  String k : newValues.keySet()) {
    completeValues.put(k,newValues.get(k));
  }
  Map<String,ArrayList> fieldsAndValues=makeFieldAndValueList(def,completeValues);
  Map<String,Object> newValuesAndIndexValues=Maps.newHashMap(newValues);
  for (  String s : def.getRequiredFields()) {
    if (newValuesAndIndexValues.get(s) == null) {
      newValuesAndIndexValues.put(s,completeValues.get(s));
    }
  }
  Map<String,ArrayList> fieldsAndValuesForNewValuesAndIndexValues=makeFieldAndValueList(def,newValuesAndIndexValues);
  for (  CIndex i : effectedIndexes) {
    if (def.isAllowNullPrimaryKeyInserts()) {
      if (!i.validateIndexKeys(i.getIndexKeyAndValues(completeValues))) {
        continue;
      }
    }
    addCQLStatmentsForIndexInsert(keyspace,true,ret,def,completeValues,i,key,fieldsAndValues,null,null);
  }
  for (  CIndex i : uneffectedIndexes) {
    if (def.isAllowNullPrimaryKeyInserts()) {
      if (!i.validateIndexKeys(i.getIndexKeyAndValues(newValuesAndIndexValues))) {
        continue;
      }
    }
    addCQLStatmentsForIndexInsert(keyspace,false,ret,def,newValuesAndIndexValues,i,key,fieldsAndValuesForNewValuesAndIndexValues,null,null);
  }
  Map<String,ArrayList> fieldsAndValuesOnlyForChanges=makeFieldAndValueList(def,newValues);
  ret.add(makeInsertStatementStatic(keyspace,makeTableName(def,null),(List<String>)fieldsAndValuesOnlyForChanges.get("String_Node_Str").clone(),(List<Object>)fieldsAndValuesOnlyForChanges.get("String_Node_Str").clone(),key,null,null));
  ret.add(makeInsertUpdateIndexStatement(keyspace,def,key,def.makeIndexValues(completeValues)));
  return new BoundedCQLStatementIterator(ret);
}

Fixed version (ground truth):
public static CQLStatementIterator makeCQLforUpdate(String keyspace,CDefinition def,UUID key,Map<String,Object> oldValues,Map<String,Object> newValues) throws CQLGenerationException {
  List<CQLStatement> ret=Lists.newArrayList();
  List<CIndex> effectedIndexes=getEffectedIndexes(def,oldValues,newValues);
  List<CIndex> uneffectedIndexes=getUneffectedIndexes(def,oldValues,newValues);
  for (  CIndex i : effectedIndexes) {
    Map<String,Object> compositeKeyToDelete=i.getIndexKeyAndValues(oldValues);
    if (def.isAllowNullPrimaryKeyInserts()) {
      if (!i.validateIndexKeys(compositeKeyToDelete)) {
        continue;
      }
    }
    ret.add(makeCQLforDeleteUUIDFromIndex(keyspace,def,i,key,compositeKeyToDelete,null));
  }
  Map<String,Object> completeValues=Maps.newHashMap(oldValues);
  for (  String k : newValues.keySet()) {
    completeValues.put(k,newValues.get(k));
  }
  Map<String,ArrayList> fieldsAndValues=makeFieldAndValueList(def,completeValues);
  Map<String,Object> newValuesAndIndexValues=Maps.newHashMap(newValues);
  for (  String s : def.getRequiredFields()) {
    if (newValuesAndIndexValues.get(s) == null) {
      newValuesAndIndexValues.put(s,completeValues.get(s));
    }
  }
  Map<String,ArrayList> fieldsAndValuesForNewValuesAndIndexValues=makeFieldAndValueList(def,newValuesAndIndexValues);
  for (  CIndex i : effectedIndexes) {
    if (def.isAllowNullPrimaryKeyInserts()) {
      if (!i.validateIndexKeys(i.getIndexKeyAndValues(completeValues))) {
        continue;
      }
    }
    addCQLStatmentsForIndexInsert(keyspace,true,ret,def,completeValues,i,key,fieldsAndValues,null,null);
  }
  for (  CIndex i : uneffectedIndexes) {
    if (def.isAllowNullPrimaryKeyInserts()) {
      if (!i.validateIndexKeys(i.getIndexKeyAndValues(newValuesAndIndexValues))) {
        continue;
      }
    }
    addCQLStatmentsForIndexInsert(keyspace,false,ret,def,newValuesAndIndexValues,i,key,fieldsAndValuesForNewValuesAndIndexValues,null,null);
  }
  Map<String,ArrayList> fieldsAndValuesOnlyForChanges=makeFieldAndValueList(def,newValues);
  ret.add(makeInsertStatementStatic(keyspace,makeTableName(def,null),(List<String>)fieldsAndValuesOnlyForChanges.get("String_Node_Str").clone(),(List<Object>)fieldsAndValuesOnlyForChanges.get("String_Node_Str").clone(),key,null,null));
  ret.add(makeInsertUpdateIndexStatement(keyspace,def,key,def.makeIndexValues(completeValues)));
  return new BoundedCQLStatementIterator(ret);
}