Program: 176196
Project: 176196
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
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
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.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        entity=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.getType().equals(Type.SUPER_COLUMN_FAMILY) && !m.isCounterColumnType()) {
            setFieldValueViaCQL(entity,thriftColumnValue,attribute);
          }
 else {
            setFieldValue(entity,thriftColumnValue,attribute);
          }
        }
      }
 else {
        entity=populateCompositeId(m,entity,thriftColumnName,thriftColumnValue,metaModel);
      }
    }
  }
 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(attribute.getJavaType());
      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=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
 * @throws IllegalAccessException
 * @throws InstantiationException
 */
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.INSTANCE.getApplicationMetadata().getMetamodel(m.getPersistenceUnit());
      String fieldName=m.getFieldName(thriftColumnName);
      Attribute attribute=fieldName != null ? entityType.getAttribute(fieldName) : null;
      if (attribute != null) {
        entity=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.getType().equals(Type.SUPER_COLUMN_FAMILY) && !m.isCounterColumnType()) {
            setFieldValueViaCQL(entity,thriftColumnValue,attribute);
          }
 else {
            setFieldValue(entity,thriftColumnValue,attribute);
          }
        }
      }
 else {
        entity=populateCompositeId(m,entity,thriftColumnName,thriftColumnValue,metaModel);
      }
    }
  }
 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(((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=initialize(m,entity,null);
      }
    }
  }
  return entity;
}