Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 5c9e29c

Browse files
committed
Fix a race condition in a test
It's hard to set this up properly, the cancel request needs to be sent before the GetQueryExecution response with the successful status is returned. Using the number of requests sent works better since it's coupled with the mechanism that blocks the request.
1 parent d024170 commit 5c9e29c

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/test/java/io/burt/athena/AthenaStatementTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,9 +422,6 @@ void throwsAnException() {
422422
class WhenCalledAfterExecute {
423423
@Test
424424
void sendsACancelRequest() throws Exception {
425-
queryExecutionHelper.queueStartQueryResponse("Q1234");
426-
queryExecutionHelper.queueGetQueryExecutionResponse(QueryExecutionState.SUCCEEDED);
427-
ResultSet rs = statement.executeQuery("SELECT 1");
428425
queryExecutionHelper.blockGetQueryExecutionResponse();
429426
queryExecutionHelper.queueStartQueryResponse("Q2345");
430427
queryExecutionHelper.queueGetQueryExecutionResponse(QueryExecutionState.RUNNING);
@@ -437,7 +434,8 @@ void sendsACancelRequest() throws Exception {
437434
}
438435
});
439436
runner.start();
440-
while (!rs.isClosed()) {
437+
while (queryExecutionHelper.getQueryExecutionRequests().size() == 0) {
438+
Thread.sleep(1);
441439
}
442440
statement.cancel();
443441
queryExecutionHelper.unblockGetQueryExecutionResponse();

0 commit comments

Comments
 (0)