Program: 177011
Project: 177011
Buggy source:
private Object populateEntityFromHbaseData(Object entity,HBaseData hbaseData,EntityMetadata m,String rowKey,List<String> relationNames){
  try {
    PropertyAccessorHelper.setId(entity,m,rowKey);
    List<KeyValue> hbaseValues=hbaseData.getColumns();
    Map<String,Object> relations=new HashMap<String,Object>();
    List<Column> columns=m.getColumnsAsList();
    for (    Column column : columns) {
      Field columnField=column.getField();
      String columnName=column.getName();
      for (      KeyValue colData : hbaseValues) {
        String hbaseColumn=Bytes.toString(colData.getColumn());
        String colName=getColumnName(hbaseColumn);
        if (hbaseColumn != null && hbaseColumn.startsWith(columnName)) {
          byte[] hbaseColumnValue=colData.getValue();
          PropertyAccessorHelper.set(entity,columnField,hbaseColumnValue);
          break;
        }
 else         if (relationNames != null && relationNames.contains(getColumnName(colName))) {
          relations.put(colName,Bytes.toString(colData.getValue()));
        }
      }
    }
    List<EmbeddedColumn> columnFamilies=m.getEmbeddedColumnsAsList();
    for (    EmbeddedColumn columnFamily : columnFamilies) {
      Field columnFamilyFieldInEntity=columnFamily.getField();
      Class<?> columnFamilyClass=columnFamilyFieldInEntity.getType();
      Map<String,Field> columnNameToFieldMap=MetadataUtils.createColumnsFieldMap(m,columnFamily);
      if (Collection.class.isAssignableFrom(columnFamilyClass)) {
        Field embeddedCollectionField=columnFamily.getField();
        Object[] embeddedObjectArr=new Object[hbaseValues.size()];
        Object embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
        int prevCFNameCounter=0;
        for (        KeyValue colData : hbaseValues) {
          String cfInHbase=Bytes.toString(colData.getFamily());
          if (!cfInHbase.startsWith(columnFamily.getName())) {
            if (relationNames != null && relationNames.contains(cfInHbase)) {
              relations.put(cfInHbase,Bytes.toString(colData.getValue()));
            }
            continue;
          }
          String cfNamePostfix=MetadataUtils.getEmbeddedCollectionPostfix(cfInHbase);
          int cfNameCounter=Integer.parseInt(cfNamePostfix);
          if (cfNameCounter != prevCFNameCounter) {
            prevCFNameCounter=cfNameCounter;
            embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
          }
          setHBaseDataIntoObject(colData,columnFamilyFieldInEntity,columnNameToFieldMap,embeddedObject);
          embeddedObjectArr[cfNameCounter]=embeddedObject;
          ElementCollectionCacheManager.getInstance().addElementCollectionCacheMapping(rowKey,embeddedObject,cfInHbase);
        }
        Collection embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
        embeddedCollection.addAll(Arrays.asList(embeddedObjectArr));
        embeddedCollection.removeAll(Collections.singletonList(null));
        embeddedObjectArr=null;
        if (embeddedCollection != null && !embeddedCollection.isEmpty()) {
          PropertyAccessorHelper.set(entity,embeddedCollectionField,embeddedCollection);
        }
      }
 else {
        Object columnFamilyObj=columnFamilyClass.newInstance();
        for (        KeyValue colData : hbaseValues) {
          String cfInHbase=Bytes.toString(colData.getFamily());
          if (!cfInHbase.equals(columnFamily.getName())) {
            if (relationNames != null && relationNames.contains(cfInHbase)) {
              relations.put(cfInHbase,Bytes.toString(colData.getValue()));
            }
            continue;
          }
          String colName=Bytes.toString(colData.getQualifier());
          byte[] columnValue=colData.getValue();
          Field columnField=columnNameToFieldMap.get(colName);
          if (columnField != null) {
            if (columnFamilyFieldInEntity.isAnnotationPresent(Embedded.class) || columnFamilyFieldInEntity.isAnnotationPresent(ElementCollection.class)) {
              PropertyAccessorHelper.set(columnFamilyObj,columnField,columnValue);
            }
 else {
              columnFamilyObj=Bytes.toString(columnValue);
            }
          }
        }
        PropertyAccessorHelper.set(entity,columnFamilyFieldInEntity,columnFamilyObj);
      }
    }
    if (!relations.isEmpty()) {
      return new EnhanceEntity(entity,rowKey,relations);
    }
    return entity;
  }
 catch (  PropertyAccessException e1) {
    throw new RuntimeException(e1.getMessage());
  }
catch (  InstantiationException e1) {
    throw new RuntimeException(e1.getMessage());
  }
catch (  IllegalAccessException e1) {
    throw new RuntimeException(e1.getMessage());
  }
}

Fixed version (ground truth):
private Object populateEntityFromHbaseData(Object entity,HBaseData hbaseData,EntityMetadata m,String rowKey,List<String> relationNames){
  try {
    PropertyAccessorHelper.setId(entity,m,rowKey);
    List<KeyValue> hbaseValues=hbaseData.getColumns();
    Map<String,Object> relations=new HashMap<String,Object>();
    List<Column> columns=m.getColumnsAsList();
    for (    Column column : columns) {
      Field columnField=column.getField();
      String columnName=column.getName();
      for (      KeyValue colData : hbaseValues) {
        String hbaseColumn=Bytes.toString(colData.getColumn());
        String colName=getColumnName(hbaseColumn);
        if (hbaseColumn != null && hbaseColumn.startsWith(columnName)) {
          byte[] hbaseColumnValue=colData.getValue();
          PropertyAccessorHelper.set(entity,columnField,hbaseColumnValue);
          break;
        }
 else         if (relationNames != null && relationNames.contains(getColumnName(colName))) {
          relations.put(colName,Bytes.toString(colData.getValue()));
        }
      }
    }
    List<EmbeddedColumn> columnFamilies=m.getEmbeddedColumnsAsList();
    for (    EmbeddedColumn columnFamily : columnFamilies) {
      Field columnFamilyFieldInEntity=columnFamily.getField();
      Class<?> columnFamilyClass=columnFamilyFieldInEntity.getType();
      Map<String,Field> columnNameToFieldMap=MetadataUtils.createColumnsFieldMap(m,columnFamily);
      if (Collection.class.isAssignableFrom(columnFamilyClass)) {
        Field embeddedCollectionField=columnFamily.getField();
        Object[] embeddedObjectArr=new Object[hbaseValues.size()];
        Object embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
        int prevCFNameCounter=0;
        for (        KeyValue colData : hbaseValues) {
          String cfInHbase=Bytes.toString(colData.getFamily());
          if (!cfInHbase.startsWith(columnFamily.getName())) {
            if (relationNames != null && relationNames.contains(cfInHbase)) {
              relations.put(cfInHbase,Bytes.toString(colData.getValue()));
            }
            continue;
          }
          String cfNamePostfix=MetadataUtils.getEmbeddedCollectionPostfix(cfInHbase);
          int cfNameCounter=Integer.parseInt(cfNamePostfix);
          if (cfNameCounter != prevCFNameCounter) {
            prevCFNameCounter=cfNameCounter;
            embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
          }
          setHBaseDataIntoObject(colData,columnFamilyFieldInEntity,columnNameToFieldMap,embeddedObject);
          embeddedObjectArr[cfNameCounter]=embeddedObject;
          ElementCollectionCacheManager.getInstance().addElementCollectionCacheMapping(rowKey,embeddedObject,cfInHbase);
        }
        Collection embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
        embeddedCollection.addAll(Arrays.asList(embeddedObjectArr));
        embeddedCollection.removeAll(Collections.singletonList(null));
        embeddedObjectArr=null;
        if (embeddedCollection != null && !embeddedCollection.isEmpty()) {
          PropertyAccessorHelper.set(entity,embeddedCollectionField,embeddedCollection);
        }
      }
 else {
        Object columnFamilyObj=columnFamilyClass.newInstance();
        for (        KeyValue colData : hbaseValues) {
          String cfInHbase=Bytes.toString(colData.getFamily());
          if (!cfInHbase.equals(columnFamily.getName())) {
            if (relationNames != null && relationNames.contains(cfInHbase)) {
              relations.put(cfInHbase,Bytes.toString(colData.getValue()));
            }
            continue;
          }
          String colName=Bytes.toString(colData.getQualifier());
          byte[] columnValue=colData.getValue();
          Field columnField=columnNameToFieldMap.get(colName);
          if (columnField != null) {
            if (columnFamilyFieldInEntity.isAnnotationPresent(Embedded.class) || columnFamilyFieldInEntity.isAnnotationPresent(ElementCollection.class)) {
              PropertyAccessorHelper.set(columnFamilyObj,columnField,columnValue);
            }
 else {
              columnFamilyObj=Bytes.toString(columnValue);
            }
          }
        }
        PropertyAccessorHelper.set(entity,columnFamilyFieldInEntity,columnFamilyObj);
      }
    }
    if (!relations.isEmpty()) {
      return new EnhanceEntity(entity,rowKey,relations);
    }
 else {
      return new EnhanceEntity(entity,rowKey,null);
    }
  }
 catch (  PropertyAccessException e1) {
    throw new RuntimeException(e1.getMessage());
  }
catch (  InstantiationException e1) {
    throw new RuntimeException(e1.getMessage());
  }
catch (  IllegalAccessException e1) {
    throw new RuntimeException(e1.getMessage());
  }
}