Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't throw exception in AbstractJdbcResultSet.close method #2833

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -32,12 +32,6 @@ public BigDecimal getBigDecimal(String columnLabel, int scale) throws SQLExcepti
throw new RuntimeException("Not implemented");
}

@Override
public void close() throws SQLException {
// TODO: Implement the logic
throw new RuntimeException("Not implemented");
}

@Override
public boolean wasNull() throws SQLException {
// TODO: Implement the logic
Expand Down
Expand Up @@ -141,6 +141,11 @@ public boolean next() throws SQLException {
}
}

@Override
public void close() throws SQLException {
// TODO: Implement the logic
}

private boolean isEndOfStream(T cursor) {
return cursor instanceof ConnectionImpl.EndOfFieldValueList;
}
Expand Down
Expand Up @@ -3013,6 +3013,7 @@ public void testBQResultSetMultiThreadedOrder() throws SQLException {
++cnt;
}
assertEquals(300000, cnt); // total 300000 rows should be read
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -3042,6 +3043,7 @@ public void testBQResultSetPaginationSlowQuery() throws SQLException {
++cnt;
}
assertEquals(300000, cnt); // total 300000 rows should be read
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -3102,6 +3104,7 @@ public void testExecuteSelectSinglePageTableRow() throws SQLException {
assertEquals(3, (integerArrayFieldValue.get(2).getNumericValue()).intValue());

assertFalse(rs.next()); // no 3rd row in the table
rs.close(); // assert close method does not throw an exception
}

@Test
Expand All @@ -3128,6 +3131,7 @@ public void testConnectionClose() throws SQLException {
assertTrue(cnt < 100000); // Extra records are still read even after canceling, as
// the backgrounds threads are still active while the interrupt occurs and the
// buffer and pageCache are cleared
rs.close(); // assert close method does not throw an exception
}

@Test
Expand All @@ -3154,6 +3158,7 @@ public void testBQResultSetPagination() throws SQLException {
++cnt;
}
assertEquals(300000, cnt); // total 300000 rows should be read
rs.close(); // assert close method does not throw an exception
}

// @Test - Temporarily disabling till https://github.com/googleapis/gax-java/issues/1712 or
Expand Down Expand Up @@ -3192,6 +3197,7 @@ public void testReadAPIIterationAndOrder()
}
assertEquals(300000, cnt); // total 300000 rows should be read
connection.close();
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -3233,6 +3239,7 @@ public void testReadAPIIterationAndOrderAsync()
}
assertEquals(300000, cnt); // total 300000 rows should be read
connection.close();
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -3383,6 +3390,7 @@ public void testReadAPIConnectionMultiClose()
}
assertEquals(300000, cnt); // total 300000 rows should be read
assertTrue(connection.close()); // check if connection closed
rs.close(); // assert close method does not throw an exception
closeCnt++;
}
assertEquals(
Expand Down Expand Up @@ -3452,6 +3460,7 @@ public void testExecuteSelectSinglePageTableRowColInd() throws SQLException {
(integerArrayFieldValue.get(2).getNumericValue()).intValue(),
(integerArrayFieldValueColInd.get(2).getNumericValue()).intValue());
}
rs.close(); // assert close method does not throw an exception
}
}

Expand Down Expand Up @@ -3486,6 +3495,7 @@ public void testExecuteSelectStruct() throws SQLException {
assertEquals("Vancouver", addressFieldValue.get(0).getStringValue());
assertEquals(5, addressFieldValue.get(1).getLongValue());
assertFalse(rs.next()); // only 1 row of data
rs.close(); // assert close method does not throw an exception
}

@Test
Expand All @@ -3512,6 +3522,7 @@ public void testExecuteSelectStructSubField() throws SQLException {
assertEquals(rs.getString("city"), rs.getObject(0));
assertEquals("Vancouver", cityFieldValue);
assertFalse(rs.next()); // only 1 row of data
rs.close(); // assert close method does not throw an exception
}

@Test
Expand All @@ -3535,6 +3546,7 @@ public void testExecuteSelectArray() throws SQLException {
assertEquals(1, arrayFieldValue.get(0).getLongValue());
assertEquals(2, arrayFieldValue.get(1).getLongValue());
assertEquals(3, arrayFieldValue.get(2).getLongValue());
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -3574,6 +3586,7 @@ public void testExecuteSelectArrayOfStruct() throws SQLException {
assertEquals(Attribute.RECORD, arrayOfStructFieldValue.get(1).getAttribute());
assertEquals("Boston", arrayOfStructFieldValue.get(1).getRecordValue().get(0).getStringValue());
assertEquals(10, arrayOfStructFieldValue.get(1).getRecordValue().get(1).getLongValue());
rs.close(); // assert close method does not throw an exception
}

/* TODO(prasmish): replicate the entire test case for executeSelect */
Expand Down
Expand Up @@ -272,6 +272,7 @@ public void testIterateAndOrder() throws SQLException {
}
assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
connection.close();
rs.close(); // assert close method does not throw an exception
}

/*
Expand Down Expand Up @@ -336,6 +337,7 @@ public void testIterateAndOrderDefaultConnSettings() throws SQLException {
}
assertEquals(LIMIT_RECS, cnt); // all the records were retrieved
assertTrue(connection.close());
rs.close(); // assert close method does not throw an exception
}

/*
Expand All @@ -361,6 +363,7 @@ public void testConnectionClose() throws SQLException {
// to be retrieved
// as a number of records should have been already buffered. less than
// LIMIT_RECS should be retrieved
rs.close(); // assert close method does not throw an exception
}

@Test
Expand Down Expand Up @@ -449,6 +452,7 @@ public void testMultipleRuns() throws SQLException {
++cnt;
}
connection.close();
rs.close(); // assert close method does not throw an exception
totalCnt += cnt;
assertEquals(MULTI_LIMIT_RECS * 2, totalCnt);
}
Expand Down Expand Up @@ -484,6 +488,7 @@ public void testPositionalParams()
++cnt;
}
connection.close();
rs.close(); // assert close method does not throw an exception
assertEquals(MULTI_LIMIT_RECS, cnt);
}

Expand Down Expand Up @@ -537,13 +542,14 @@ public void testForTableNotFound() throws SQLException {

// this iterated through all the rows (just reads the title column)
private Long getResultHashWiki(BigQueryResult bigQueryResultSet) throws SQLException {
ResultSet rs = bigQueryResultSet.getResultSet();
long hash = 0L;
System.out.print("\n Running");
while (rs.next()) {
hash += rs.getString("title") == null ? 0 : rs.getString("title").hashCode();
try (ResultSet rs = bigQueryResultSet.getResultSet()) {
long hash = 0L;
System.out.print("\n Running");
while (rs.next()) {
hash += rs.getString("title") == null ? 0 : rs.getString("title").hashCode();
}
return hash;
}
return hash;
}

// asserts the value of each row
Expand Down