Skip to content

Commit

Permalink
implement Closeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Urmi Mustafi committed Oct 31, 2023
1 parent 2518c6e commit 150ca0b
Showing 1 changed file with 3 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.apache.gobblin.util;

import com.zaxxer.hikari.HikariDataSource;
import java.io.Closeable;
import java.io.IOException;
import java.sql.Connection;
import java.sql.PreparedStatement;
Expand All @@ -35,7 +36,7 @@
* The caller of the class MUST maintain ownership of the {@link DataSource} and close this instance when the
* {@link DataSource} is about to be closed well. Both are to be done only once this instance will no longer be used.
*/
public class DBStatementExecutor {
public class DBStatementExecutor implements Closeable {
private final DataSource dataSource;
private final Logger log;
private final ArrayList<ScheduledThreadPoolExecutor> scheduledExecutors;
Expand Down Expand Up @@ -101,6 +102,7 @@ public void repeatSqlCommandExecutionAtInterval(String sqlCommand, long interval
* Call before closing the data source object associated with this instance to also shut down any executors expecting
* to be run on the data source.
*/
@Override
public void close() {
for (ScheduledThreadPoolExecutor executor : this.scheduledExecutors) {
executor.shutdownNow();
Expand Down

0 comments on commit 150ca0b

Please sign in to comment.