Program: 175957
Project: 175957
Buggy source:
/** 
 * Populate via thrift.
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param relations the relations
 * @param thriftColumnName the thrift column name
 * @param thriftColumnValue the thrift column value
 * @param isCql3Enabled the is cql3 enabled
 * @return the object
 * @throws InstantiationException the instantiation exception
 * @throws IllegalAccessException the illegal access exception
 */
private Object populateViaThrift(EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,Map<String,Object> relations,String thriftColumnName,Object thriftColumnValue,boolean isCql3Enabled) throws InstantiationException, IllegalAccessException {
  if (relationNames == null || !relationNames.contains(thriftColumnName)) {
    if (thriftColumnValue != null) {
      MetamodelImpl metaModel=(MetamodelImpl)kunderaMetadata.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        entity=KunderaCoreUtils.initialize(m,entity,null);
        if (!attribute.isAssociation()) {
          String idColumnName=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
          if (!metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && thriftColumnName.equals(idColumnName)) {
            setId(m,entity,thriftColumnValue,isCql3Enabled);
            PropertyAccessorHelper.setId(entity,m,(byte[])thriftColumnValue);
          }
          if (isCql3Enabled && !m.isCounterColumnType()) {
            if (metaModel.isEmbeddable(((AbstractAttribute)attribute).getBindableJavaType())) {
              if (attribute.isCollection()) {
                entity=setElementCollection(entity,thriftColumnValue,metaModel,attribute);
              }
 else {
                entity=setUdtValue(entity,thriftColumnValue,metaModel,attribute);
              }
            }
 else {
              setFieldValueViaCQL(entity,thriftColumnValue,attribute);
            }
          }
 else {
            setFieldValue(entity,thriftColumnValue,attribute);
          }
        }
      }
 else       if (metaModel.isEmbeddable(((AbstractAttribute)m.getIdAttribute()).getBindableJavaType())) {
        entity=populateCompositeId(m,entity,thriftColumnName,thriftColumnValue,metaModel,m.getIdAttribute(),m.getEntityClazz());
      }
 else       if (clientBase.getCqlMetadata() != null) {
        if (entity == null) {
          entity=new HashMap();
        }
        if (entity instanceof HashMap) {
          composeAndAdd((HashMap)entity,clientBase.getCqlMetadata(),thriftColumnValue,thriftColumnName);
        }
      }
    }
  }
 else {
    if (relationNames != null && relationNames.contains(thriftColumnName) && thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      EntityMetadata relationMetadata=KunderaMetadataManager.getEntityMetadata(kunderaMetadata,((AbstractAttribute)attribute).getBindableJavaType());
      Object value;
      if (isCql3Enabled && !m.getType().equals(Type.SUPER_COLUMN_FAMILY)) {
        value=getFieldValueViaCQL(thriftColumnValue,relationMetadata.getIdAttribute());
      }
 else {
        value=PropertyAccessorHelper.getObject(relationMetadata.getIdAttribute().getJavaType(),(byte[])thriftColumnValue);
      }
      relations.put(thriftColumnName,value);
      if (entity == null) {
        entity=KunderaCoreUtils.initialize(m,entity,null);
      }
    }
  }
  return entity;
}

Fixed version (ground truth):
/** 
 * Populate via thrift.
 * @param m the m
 * @param entity the entity
 * @param entityType the entity type
 * @param relationNames the relation names
 * @param relations the relations
 * @param thriftColumnName the thrift column name
 * @param thriftColumnValue the thrift column value
 * @param isCql3Enabled the is cql3 enabled
 * @return the object
 * @throws InstantiationException the instantiation exception
 * @throws IllegalAccessException the illegal access exception
 */
private Object populateViaThrift(EntityMetadata m,Object entity,EntityType entityType,List<String> relationNames,Map<String,Object> relations,String thriftColumnName,Object thriftColumnValue,boolean isCql3Enabled) throws InstantiationException, IllegalAccessException {
  if (relationNames == null || !relationNames.contains(thriftColumnName)) {
    if (thriftColumnValue != null) {
      MetamodelImpl metaModel=(MetamodelImpl)kunderaMetadata.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        entity=KunderaCoreUtils.initialize(m,entity,null);
        if (!attribute.isAssociation()) {
          String idColumnName=((AbstractAttribute)m.getIdAttribute()).getJPAColumnName();
          if (!metaModel.isEmbeddable(m.getIdAttribute().getBindableJavaType()) && thriftColumnName.equals(idColumnName)) {
            setId(m,entity,thriftColumnValue,isCql3Enabled);
            PropertyAccessorHelper.setId(entity,m,(byte[])thriftColumnValue);
          }
          if (isCql3Enabled && !m.isCounterColumnType()) {
            if (metaModel.isEmbeddable(((AbstractAttribute)attribute).getBindableJavaType())) {
              if (attribute.isCollection()) {
                entity=setElementCollection(entity,thriftColumnValue,metaModel,attribute);
              }
 else {
                entity=setUdtValue(entity,thriftColumnValue,metaModel,attribute);
              }
            }
 else {
              setFieldValueViaCQL(entity,thriftColumnValue,attribute);
            }
          }
 else {
            setFieldValue(entity,thriftColumnValue,attribute);
          }
        }
      }
 else       if (metaModel.isEmbeddable(((AbstractAttribute)m.getIdAttribute()).getBindableJavaType()) && !isAggregate(thriftColumnName)) {
        entity=populateCompositeId(m,entity,thriftColumnName,thriftColumnValue,metaModel,m.getIdAttribute(),m.getEntityClazz());
      }
 else       if (clientBase.getCqlMetadata() != null) {
        if (entity == null) {
          entity=new HashMap();
        }
        if (entity instanceof HashMap) {
          composeAndAdd((HashMap)entity,clientBase.getCqlMetadata(),thriftColumnValue,thriftColumnName);
        }
      }
    }
  }
 else {
    if (relationNames != null && relationNames.contains(thriftColumnName) && thriftColumnValue != null) {
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      EntityMetadata relationMetadata=KunderaMetadataManager.getEntityMetadata(kunderaMetadata,((AbstractAttribute)attribute).getBindableJavaType());
      Object value;
      if (isCql3Enabled && !m.getType().equals(Type.SUPER_COLUMN_FAMILY)) {
        value=getFieldValueViaCQL(thriftColumnValue,relationMetadata.getIdAttribute());
      }
 else {
        value=PropertyAccessorHelper.getObject(relationMetadata.getIdAttribute().getJavaType(),(byte[])thriftColumnValue);
      }
      relations.put(thriftColumnName,value);
      if (entity == null) {
        entity=KunderaCoreUtils.initialize(m,entity,null);
      }
    }
  }
  return entity;
}