Program: 176535
Project: 176535
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,String poolName,List<Column> columns,Class columnType){
  Object pooledConnection=null;
  try {
    Cassandra.Client api=null;
    pooledConnection=getPooledConection(persistenceUnit);
    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) {
      throw new PersistenceException("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));
      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()));
      api.system_update_column_family(columnFamilyDefToUpdate);
    }
  }
 catch (  InvalidRequestException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  SchemaDisagreementException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  TException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  NotFoundException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  PropertyAccessException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ 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(persistenceUnit);
    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) {
      throw new PersistenceException("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));
      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()));
      api.system_update_column_family(columnFamilyDefToUpdate);
    }
  }
 catch (  InvalidRequestException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  SchemaDisagreementException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  TException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  NotFoundException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
catch (  PropertyAccessException e) {
    log.warn("String_Node_Str" + tableName + "String_Node_Str"+ e);
  }
 finally {
    releaseConnection(pooledConnection);
  }
}