Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public Scanner scan(Scan scan) throws ExecutionException {
connection.setAutoCommit(false);
rdbEngine.setConnectionToReadOnly(connection, true);
return jdbcService.getScanner(scan, connection);
} catch (SQLException e) {
} catch (Exception e) {
try {
if (connection != null) {
connection.rollback();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,29 @@ public void whenScanOperationExecutedAndScannerClosed_shouldCallJdbcService() th
verify(connection).close();
}

@Test
public void
whenScanOperationExecutedAndJdbcServiceThrowsIllegalArgumentException_shouldThrowExecutionException()
throws Exception {
// Arrange
Exception cause = new IllegalArgumentException("Table not found");
// Simulate the table not found scenario.
when(jdbcService.getScanner(any(), any())).thenThrow(cause);

// Act Assert
assertThatThrownBy(
() -> {
Scan scan = new Scan(new Key("p1", "val")).forNamespace(NAMESPACE).forTable(TABLE);
jdbcDatabase.scan(scan);
})
.isInstanceOf(ExecutionException.class)
.hasCause(cause);
verify(connection).setAutoCommit(false);
verify(connection).setReadOnly(true);
verify(connection).rollback();
verify(connection).close();
}

@Test
public void
whenScanOperationExecutedAndScannerClosed_SQLExceptionThrownByConnectionCommit_shouldThrowIOException()
Expand Down
Loading