diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java index f54365ba84d..b9144581b2a 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/it/ITDmlReturningTest.java @@ -272,6 +272,8 @@ private List executeQuery(long expectedCount, String stmt) { List rows = new ArrayList<>(); final TransactionCallable callable = transaction -> { + // Make sure we start with an empty list if the transaction is aborted and retried. + rows.clear(); ResultSet resultSet = transaction.executeQuery(Statement.of(stmt)); // resultSet.next() returns false, when no more row exists. // So, number of times resultSet.next() returns true, is the number of rows @@ -335,6 +337,7 @@ private List executeQueryAsync(long expectedCount, String stmt) { List rows = new ArrayList<>(); final TransactionCallable callable = transaction -> { + rows.clear(); AsyncResultSet rs = transaction.executeQueryAsync(Statement.of(stmt)); rs.setCallback( Executors.newSingleThreadExecutor(),