Program: 177034
Project: 177034
Buggy source:
/** 
 * Fetches data held in Thrift row super columns and populates to Entity objects
 */
public Object fromSuperColumnThriftRow(Class clazz,EntityMetadata m,ThriftRow tr,List<String> relationNames,boolean isWrapReq) throws Exception {
  Object entity=clazz.newInstance();
  Map<String,Set<String>> foreignKeysMap=new HashMap<String,Set<String>>();
  PropertyAccessorHelper.setId(entity,m,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;
  Map<String,Object> relations=new HashMap<String,Object>();
  for (  SuperColumn sc : tr.getSuperColumns()) {
    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);
      if (embeddedCollection == null) {
        embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
      }
      Object embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
      for (      Column column : sc.getColumns()) {
        String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
        byte[] value=column.getValue();
        if (value == null) {
          continue;
        }
        Field columnField=columnNameToFieldMap.get(name);
        if (columnField != null) {
          PropertyAccessorHelper.set(embeddedObject,columnField,value);
        }
 else         if (relationNames != null && !relationNames.isEmpty() && relationNames.contains(name)) {
          String valueAsStr=PropertyAccessorFactory.STRING.fromBytes(value);
          relations.put(name,valueAsStr);
        }
      }
      embeddedCollection.add(embeddedObject);
      ElementCollectionCacheManager.getInstance().addElementCollectionCacheMapping(tr.getId(),embeddedObject,scName);
    }
 else {
      Field superColumnField=superColumnNameToFieldMap.get(scName);
      if (superColumnField != null) {
        Class superColumnClass=superColumnField.getType();
        Object superColumnObj=superColumnClass.newInstance();
        for (        Column column : sc.getColumns()) {
          String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
          byte[] value=column.getValue();
          Field columnField=columnNameToFieldMap.get(name);
          if (columnField != null) {
            try {
              PropertyAccessorHelper.set(superColumnObj,columnField,value);
            }
 catch (            PropertyAccessException e) {
              log.debug(e.getMessage() + "String_Node_Str");
              superColumnObj=Bytes.toUTF8(value);
            }
          }
 else           if (relationNames != null && !relationNames.isEmpty() && relationNames.contains(name)) {
            String valueAsStr=PropertyAccessorFactory.STRING.fromBytes(value);
            relations.put(name,valueAsStr);
          }
        }
        PropertyAccessorHelper.set(entity,superColumnField,superColumnObj);
      }
    }
  }
  if (embeddedCollection != null && !embeddedCollection.isEmpty()) {
    PropertyAccessorHelper.set(entity,embeddedCollectionField,embeddedCollection);
  }
  return isWrapReq ? new EnhanceEntity(entity,tr.getId(),relations) : entity;
}

Fixed version (ground truth):
/** 
 * Fetches data held in Thrift row super columns and populates to Entity objects
 */
public Object fromSuperColumnThriftRow(Class clazz,EntityMetadata m,ThriftRow tr,List<String> relationNames,boolean isWrapReq) throws Exception {
  Object entity=clazz.newInstance();
  Map<String,Set<String>> foreignKeysMap=new HashMap<String,Set<String>>();
  PropertyAccessorHelper.setId(entity,m,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;
  Map<String,Object> relations=new HashMap<String,Object>();
  for (  SuperColumn sc : tr.getSuperColumns()) {
    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);
      if (embeddedCollection == null) {
        embeddedCollection=MetadataUtils.getEmbeddedCollectionInstance(embeddedCollectionField);
      }
      Object embeddedObject=MetadataUtils.getEmbeddedGenericObjectInstance(embeddedCollectionField);
      for (      Column column : sc.getColumns()) {
        String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
        byte[] value=column.getValue();
        if (value == null) {
          continue;
        }
        Field columnField=columnNameToFieldMap.get(name);
        if (columnField != null) {
          PropertyAccessorHelper.set(embeddedObject,columnField,value);
        }
 else         if (relationNames != null && !relationNames.isEmpty() && relationNames.contains(name)) {
          String valueAsStr=PropertyAccessorFactory.STRING.fromBytes(value);
          relations.put(name,valueAsStr);
        }
      }
      embeddedCollection.add(embeddedObject);
      ElementCollectionCacheManager.getInstance().addElementCollectionCacheMapping(tr.getId(),embeddedObject,scName);
    }
 else {
      Field superColumnField=superColumnNameToFieldMap.get(scName);
      Object superColumnObj=null;
      if (superColumnField != null || (relationNames != null && !relationNames.isEmpty() && relationNames.contains(scName))) {
        Class superColumnClass=superColumnField != null ? superColumnField.getType() : null;
        superColumnObj=superColumnClass != null ? superColumnClass.newInstance() : null;
        for (        Column column : sc.getColumns()) {
          String name=PropertyAccessorFactory.STRING.fromBytes(column.getName());
          byte[] value=column.getValue();
          Field columnField=columnNameToFieldMap.get(name);
          if (columnField != null) {
            try {
              PropertyAccessorHelper.set(superColumnObj,columnField,value);
            }
 catch (            PropertyAccessException e) {
              log.debug(e.getMessage() + "String_Node_Str");
              superColumnObj=Bytes.toUTF8(value);
            }
          }
 else {
            String valueAsStr=PropertyAccessorFactory.STRING.fromBytes(value);
            relations.put(name,valueAsStr);
          }
        }
      }
      if (superColumnField != null) {
        PropertyAccessorHelper.set(entity,superColumnField,superColumnObj);
      }
    }
  }
  if (embeddedCollection != null && !embeddedCollection.isEmpty()) {
    PropertyAccessorHelper.set(entity,embeddedCollectionField,embeddedCollection);
  }
  return isWrapReq ? new EnhanceEntity(entity,tr.getId(),relations) : entity;
}