Source:
<code>public void testSecondaryGlobalIndexFailure() throws Exception { if (localIndex || transactional) { return; } String schemaName = generateUniqueName(); String dataTableName = generateUniqueName(); String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); String indexTableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); Connection conn = DriverManager.getConnection(getUrl(), props); try { String stmString1 = "CREATE TABLE " + dataTableFullName + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, ZIP INTEGER) " + tableDDLOptions; conn.createStatement().execute(stmString1); String upsertQuery = String.format("UPSERT INTO %s VALUES(?, ?, ?)", dataTableFullName); PreparedStatement stmt1 = conn.prepareStatement(upsertQuery); upsertRow(stmt1, 1); upsertRow(stmt1, 2); conn.commit(); String stmtString2 = String.format( "CREATE %s INDEX %s ON %s (LPAD(UPPER(NAME, 'en_US'),8,'x')||'_xyz') ASYNC ", (localIndex ? "LOCAL" : ""), indexTableName, dataTableFullName); conn.createStatement().execute(stmtString2); runIndexTool(directApi, useSnapshot, schemaName, dataTableName, indexTableName); String qIndexTableName = SchemaUtil.getQualifiedTableName(schemaName, indexTableName); assertEquals(PIndexState.ACTIVE, TestUtil.getIndexState(conn, qIndexTableName)); ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName tableName = TableName.valueOf(qIndexTableName); admin.disableTable(tableName); runIndexTool(directApi, useSnapshot, schemaName, dataTableName, indexTableName, null, -1, new String[0]); assertEquals(PIndexState.ACTIVE, TestUtil.getIndexState(conn, qIndexTableName)); } finally { <START> conn.close(); <END> } }</code><technical_language>Nit: Instead of this finally block been: try (Connection conn = DriverManager.getConnection(getUrl(), props)) { .... }</technical_language>

Target:
public void testSecondaryGlobalIndexFailure() throws Exception { if (localIndex || transactional || !directApi || useSnapshot) { return; } String schemaName = generateUniqueName(); String dataTableName = generateUniqueName(); String dataTableFullName = SchemaUtil.getTableName(schemaName, dataTableName); String indexTableName = generateUniqueName(); Properties props = PropertiesUtil.deepCopy(TEST_PROPERTIES); try (Connection conn = DriverManager.getConnection(getUrl(), props)) { String stmString1 = "CREATE TABLE " + dataTableFullName + " (ID INTEGER NOT NULL PRIMARY KEY, NAME VARCHAR, ZIP INTEGER) " + tableDDLOptions; conn.createStatement().execute(stmString1); String upsertQuery = String.format("UPSERT INTO %s VALUES(?, ?, ?)", dataTableFullName); PreparedStatement stmt1 = conn.prepareStatement(upsertQuery); upsertRow(stmt1, 1); upsertRow(stmt1, 2); conn.commit(); String stmtString2 = String.format( "CREATE %s INDEX %s ON %s (LPAD(UPPER(NAME, 'en_US'),8,'x')||'_xyz') ASYNC ", (localIndex ? "LOCAL" : ""), indexTableName, dataTableFullName); conn.createStatement().execute(stmtString2); runIndexTool(directApi, useSnapshot, schemaName, dataTableName, indexTableName); String qIndexTableName = SchemaUtil.getQualifiedTableName(schemaName, indexTableName); assertEquals(PIndexState.ACTIVE, TestUtil.getIndexState(conn, qIndexTableName)); ConnectionQueryServices queryServices = conn.unwrap(PhoenixConnection.class).getQueryServices(); Admin admin = queryServices.getAdmin(); TableName tableName = TableName.valueOf(qIndexTableName); admin.disableTable(tableName); runIndexTool(directApi, useSnapshot, schemaName, dataTableName, indexTableName, null, -1, new String[0]); assertEquals(PIndexState.ACTIVE, TestUtil.getIndexState(conn, qIndexTableName)); } }