Program: 177068
Project: 177068
Buggy source:
/** 
 * From thrift row.
 * @param < E > the element type
 * @param clazz the clazz
 * @param m the m
 * @param tr the cr
 * @return the e
 * @throws Exception the exception
 */
public <E>E fromThriftRow(Class<E> clazz,EntityMetadata m,DataRow<SuperColumn> tr) throws Exception {
  E e=clazz.newInstance();
  PropertyAccessorHelper.set(e,m.getIdColumn().getField(),tr.getId());
  Map<String,Field> columnNameToFieldMap=new HashMap<String,Field>();
  Map<String,Field> superColumnNameToFieldMap=new HashMap<String,Field>();
  MetadataUtils.populateColumnAndSuperColumnMaps(m,columnNameToFieldMap,superColumnNameToFieldMap);
  Collection embeddedCollection=null;
  Field embeddedCollectionField=null;
  for (  SuperColumn sc : tr.getColumns()) {
    String scName=PropertyAccessorFactory.STRING.fromBytes(sc.getName());
    String scNamePrefix=null;
    if (scName.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER) != -1) {
      scNamePrefix=MetadataUtils.getEmbeddedCollectionPrefix(scName);
      embeddedCollectionField=superColumnNameToFieldMap.get(scNamePrefix);
      embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
      String scFieldName=scName.substring(0,scName.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER));
      Field superColumnField=e.getClass().getDeclaredField(scFieldName);
      if (!superColumnField.isAccessible()) {
        superColumnField.setAccessible(true);
      }
      if (superColumnField.getType().equals(List.class)) {
        embeddedCollection=new ArrayList();
      }
 else       if (superColumnField.getType().equals(Set.class)) {
        embeddedCollection=new HashSet();
      }
      Object embeddedObject=populateEmbeddedObject(sc,m);
      embeddedCollection.add(embeddedObject);
      superColumnField.set(e,embeddedCollection);
    }
 else {
      boolean intoRelations=false;
      if (scName.equals(Constants.FOREIGN_KEY_EMBEDDED_COLUMN_NAME)) {
        intoRelations=true;
      }
      for (      Column column : sc.getColumns()) {
        String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
        byte[] value=column.getValue();
        if (value == null) {
          continue;
        }
        if (intoRelations) {
          Relation relation=m.getRelation(name);
          String foreignKeys=PropertyAccessorFactory.STRING.fromBytes(value);
          Set<String> keys=MetadataUtils.deserializeKeys(foreignKeys);
        }
 else {
          Field field=columnNameToFieldMap.get(name);
          Object embeddedObject=PropertyAccessorHelper.getObject(e,scName);
          PropertyAccessorHelper.set(embeddedObject,field,value);
        }
      }
    }
  }
  return e;
}

Fixed version (ground truth):
/** 
 * From thrift row.
 * @param < E > the element type
 * @param clazz the clazz
 * @param m the m
 * @param tr the cr
 * @return the e
 * @throws Exception the exception
 */
public <E>E fromThriftRow(Class<E> clazz,EntityMetadata m,DataRow<SuperColumn> tr) throws Exception {
  E e=clazz.newInstance();
  PropertyAccessorHelper.set(e,m.getIdColumn().getField(),tr.getId());
  Map<String,Field> columnNameToFieldMap=new HashMap<String,Field>();
  Map<String,Field> superColumnNameToFieldMap=new HashMap<String,Field>();
  MetadataUtils.populateColumnAndSuperColumnMaps(m,columnNameToFieldMap,superColumnNameToFieldMap);
  Collection embeddedCollection=null;
  Field embeddedCollectionField=null;
  for (  SuperColumn sc : tr.getColumns()) {
    String scName=PropertyAccessorFactory.STRING.fromBytes(sc.getName());
    String scNamePrefix=null;
    if (scName.indexOf(Constants.EMBEDDED_COLUMN_NAME_DELIMITER) != -1) {
      scNamePrefix=MetadataUtils.getEmbeddedCollectionPrefix(scName);
      embeddedCollectionField=superColumnNameToFieldMap.get(scNamePrefix);
      embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
      Object embeddedObject=populateEmbeddedObject(sc,m);
      embeddedCollection.add(embeddedObject);
      PropertyAccessorHelper.set(e,embeddedCollectionField,embeddedCollection);
    }
 else {
      boolean intoRelations=false;
      if (scName.equals(Constants.FOREIGN_KEY_EMBEDDED_COLUMN_NAME)) {
        intoRelations=true;
      }
      for (      Column column : sc.getColumns()) {
        String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
        byte[] value=column.getValue();
        if (value == null) {
          continue;
        }
        if (intoRelations) {
          Relation relation=m.getRelation(name);
          String foreignKeys=PropertyAccessorFactory.STRING.fromBytes(value);
          Set<String> keys=MetadataUtils.deserializeKeys(foreignKeys);
        }
 else {
          Field field=columnNameToFieldMap.get(name);
          Object embeddedObject=PropertyAccessorHelper.getObject(e,scName);
          PropertyAccessorHelper.set(embeddedObject,field,value);
        }
      }
    }
  }
  return e;
}