Program: 176370
Project: 176370
Buggy source:
/** 
 * Creates secondary indexes on columns if not already created.
 * @param tableName Column family name
 * @param poolName Pool Name
 * @param columns List of columns
 * @param columnType
 */
protected void createIndexesOnColumns(EntityMetadata m,String tableName,List<Column> columns,Class columnType){
  Object pooledConnection=null;
  try {
    Cassandra.Client api=null;
    pooledConnection=getConection();
    api=getConnection(pooledConnection);
    KsDef ksDef=api.describe_keyspace(m.getSchema());
    List<CfDef> cfDefs=ksDef.getCf_defs();
    CfDef columnFamilyDefToUpdate=null;
    boolean isUpdatable=false;
    for (    CfDef cfDef : cfDefs) {
      if (cfDef.getName().equals(tableName)) {
        columnFamilyDefToUpdate=cfDef;
        break;
      }
    }
    if (columnFamilyDefToUpdate == null) {
      log.error("String_Node_Str",tableName);
      throw new PersistenceException("String_Node_Str" + tableName + "String_Node_Str");
    }
    List<ColumnDef> columnMetadataList=columnFamilyDefToUpdate.getColumn_metadata();
    List<String> indexList=new ArrayList<String>();
    if (columnMetadataList != null) {
      for (      ColumnDef columnDef : columnMetadataList) {
        indexList.add(Bytes.toUTF8(columnDef.getName()));
      }
    }
    for (    Column column : columns) {
      ColumnDef columnDef=new ColumnDef();
      columnDef.setName(column.getName());
      columnDef.setValidation_class(CassandraValidationClassMapper.getValidationClass(columnType,false));
      columnDef.setIndex_type(IndexType.KEYS);
      if (!indexList.contains(Bytes.toUTF8(column.getName()))) {
        isUpdatable=true;
        columnFamilyDefToUpdate.addToColumn_metadata(columnDef);
      }
    }
    if (isUpdatable) {
      columnFamilyDefToUpdate.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(m.getIdAttribute().getJavaType(),isCql3Enabled(m)));
      api.system_update_column_family(columnFamilyDefToUpdate);
    }
  }
 catch (  InvalidRequestException e) {
    log.warn("String_Node_Str",tableName,e);
  }
catch (  SchemaDisagreementException e) {
    log.warn("String_Node_Str",tableName,e);
  }
catch (  TException e) {
    log.warn("String_Node_Str",tableName,e);
  }
catch (  NotFoundException e) {
    log.warn("String_Node_Str",tableName,e);
  }
catch (  PropertyAccessException e) {
    log.warn("String_Node_Str",tableName,e);
  }
 finally {
    releaseConnection(pooledConnection);
  }
}

Fixed version (ground truth):
/** 
 * Creates secondary indexes on columns if not already created.
 * @param tableName Column family name
 * @param poolName Pool Name
 * @param columns List of columns
 * @param columnType
 */
protected void createIndexesOnColumns(EntityMetadata m,String tableName,List<Column> columns,Class columnType){
  Object pooledConnection=null;
  try {
    Cassandra.Client api=null;
    pooledConnection=getConection();
    api=getConnection(pooledConnection);
    KsDef ksDef=api.describe_keyspace(m.getSchema());
    List<CfDef> cfDefs=ksDef.getCf_defs();
    CfDef columnFamilyDefToUpdate=null;
    boolean isUpdatable=false;
    for (    CfDef cfDef : cfDefs) {
      if (cfDef.getName().equals(tableName)) {
        columnFamilyDefToUpdate=cfDef;
        break;
      }
    }
    if (columnFamilyDefToUpdate == null) {
      log.error("String_Node_Str",tableName);
      throw new PersistenceException("String_Node_Str" + tableName + "String_Node_Str");
    }
    List<ColumnDef> columnMetadataList=columnFamilyDefToUpdate.getColumn_metadata();
    List<String> indexList=new ArrayList<String>();
    if (columnMetadataList != null) {
      for (      ColumnDef columnDef : columnMetadataList) {
        indexList.add(Bytes.toUTF8(columnDef.getName()));
      }
    }
    for (    Column column : columns) {
      ColumnDef columnDef=new ColumnDef();
      columnDef.setName(column.getName());
      columnDef.setValidation_class(CassandraValidationClassMapper.getValidationClass(columnType,false));
      columnDef.setIndex_type(IndexType.KEYS);
      if (!indexList.contains(Bytes.toUTF8(column.getName()))) {
        isUpdatable=true;
        columnFamilyDefToUpdate.addToColumn_metadata(columnDef);
      }
    }
    if (isUpdatable) {
      columnFamilyDefToUpdate.setKey_validation_class(CassandraValidationClassMapper.getValidationClass(m.getIdAttribute().getJavaType(),isCql3Enabled(m)));
      api.system_update_column_family(columnFamilyDefToUpdate);
    }
  }
 catch (  Exception e) {
    log.warn("String_Node_Str",tableName,e);
  }
 finally {
    releaseConnection(pooledConnection);
  }
}