Program: 177092
Project: 177092
Buggy source:
/** 
 * From thrift row.
 * @param < E > the element type
 * @param clazz the clazz
 * @param m the m
 * @param cr the cr
 * @return the e
 * @throws Exception the exception
 */
private <E>E fromThriftRow(Class<E> clazz,EntityMetadata m,BaseDataAccessor.ThriftRow<SuperColumn> cr) throws Exception {
  E e=clazz.newInstance();
  PropertyAccessorHelper.set(e,m.getIdProperty(),cr.getId());
  Map<String,Field> columnNameToFieldMap=new HashMap<String,Field>();
  for (  Map.Entry<String,EntityMetadata.SuperColumn> entry : m.getSuperColumnsMap().entrySet()) {
    for (    EntityMetadata.Column cMetadata : entry.getValue().getColumns()) {
      columnNameToFieldMap.put(cMetadata.getName(),cMetadata.getField());
    }
  }
  for (  SuperColumn sc : cr.getColumns()) {
    String scName=PropertyAccessorFactory.STRING.fromBytes(sc.getName());
    if (scName.indexOf(Constants.SUPER_COLUMN_NAME_DELIMITER) != -1) {
      String scFieldName=scName.substring(0,scName.indexOf(Constants.SUPER_COLUMN_NAME_DELIMITER));
      Field superColumnField=e.getClass().getDeclaredField(scFieldName);
      Collection embeddedCollection=null;
      if (superColumnField.getType().equals(List.class)) {
        embeddedCollection=new ArrayList();
      }
 else       if (superColumnField.getType().equals(Set.class)) {
        embeddedCollection=new HashSet();
      }
      PelopsDataHandler handler=new PelopsDataHandler();
      Object embeddedObject=handler.populateEmbeddedObject(sc,m);
      embeddedCollection.add(embeddedObject);
    }
 else {
      boolean intoRelations=false;
      if (scName.equals(TO_ONE_SUPER_COL_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) {
          EntityMetadata.Relation relation=m.getRelation(name);
          String foreignKeys=PropertyAccessorFactory.STRING.fromBytes(value);
          Set<String> keys=deserializeKeys(foreignKeys);
          getEntityManager().getEntityResolver().populateForeignEntities(e,cr.getId(),relation,keys.toArray(new String[0]));
        }
 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 cr the cr
 * @return the e
 * @throws Exception the exception
 */
private <E>E fromThriftRow(Class<E> clazz,EntityMetadata m,BaseDataAccessor.ThriftRow<SuperColumn> cr) throws Exception {
  E e=clazz.newInstance();
  PropertyAccessorHelper.set(e,m.getIdProperty(),cr.getId());
  Map<String,Field> columnNameToFieldMap=new HashMap<String,Field>();
  for (  Map.Entry<String,EntityMetadata.SuperColumn> entry : m.getSuperColumnsMap().entrySet()) {
    for (    EntityMetadata.Column cMetadata : entry.getValue().getColumns()) {
      columnNameToFieldMap.put(cMetadata.getName(),cMetadata.getField());
    }
  }
  for (  SuperColumn sc : cr.getColumns()) {
    String scName=PropertyAccessorFactory.STRING.fromBytes(sc.getName());
    if (scName.indexOf(Constants.SUPER_COLUMN_NAME_DELIMITER) != -1) {
      String scFieldName=scName.substring(0,scName.indexOf(Constants.SUPER_COLUMN_NAME_DELIMITER));
      Field superColumnField=e.getClass().getDeclaredField(scFieldName);
      if (!superColumnField.isAccessible()) {
        superColumnField.setAccessible(true);
      }
      Collection embeddedCollection=null;
      if (superColumnField.getType().equals(List.class)) {
        embeddedCollection=new ArrayList();
      }
 else       if (superColumnField.getType().equals(Set.class)) {
        embeddedCollection=new HashSet();
      }
      PelopsDataHandler handler=new PelopsDataHandler();
      Object embeddedObject=handler.populateEmbeddedObject(sc,m);
      embeddedCollection.add(embeddedObject);
      superColumnField.set(e,embeddedCollection);
    }
 else {
      boolean intoRelations=false;
      if (scName.equals(TO_ONE_SUPER_COL_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) {
          EntityMetadata.Relation relation=m.getRelation(name);
          String foreignKeys=PropertyAccessorFactory.STRING.fromBytes(value);
          Set<String> keys=deserializeKeys(foreignKeys);
          getEntityManager().getEntityResolver().populateForeignEntities(e,cr.getId(),relation,keys.toArray(new String[0]));
        }
 else {
          Field field=columnNameToFieldMap.get(name);
          Object embeddedObject=PropertyAccessorHelper.getObject(e,scName);
          PropertyAccessorHelper.set(embeddedObject,field,value);
        }
      }
    }
  }
  return e;
}