Skip to content

Commit

Permalink
Fix bug: Closing iterators on errors for CassandraTable and MysqlTable (
Browse files Browse the repository at this point in the history
#2014)

Co-authored-by: Sagar Rao <[email protected]>
  • Loading branch information
vamossagar12 and Sagar Rao authored Nov 14, 2022
1 parent 020b7dc commit 833ce2f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,12 @@ protected <R> Iterator<R> query(Query query,
} catch (DriverException e) {
LOG.debug("Failed to query [{}], detail statement: {}",
query, selects, e);
// Closing the iterator
try {
rs.close();
} catch (Exception e2) {
LOG.error("Got error {} when closing iterator for query {}", e2, query);
}
throw new BackendException("Failed to query [%s]", e, query);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -477,6 +477,12 @@ protected <R> Iterator<R> query(Session session, Query query,
rs.extend(parser.apply(query, results));
}
} catch (SQLException e) {
// Closing the iterator
try {
rs.close();
} catch (Exception e2) {
LOG.error("Got error {} when closing iterator for query {}", e2, query);
}
throw new BackendException("Failed to query [%s]", e, query);
}

Expand Down

0 comments on commit 833ce2f

Please sign in to comment.