wuchong commented on a change in pull request #13275:
URL: https://github.com/apache/flink/pull/13275#discussion_r490817084
##########
File path:
flink-connectors/flink-connector-hbase/src/main/java/org/apache/flink/connector/hbase/source/AbstractTableInputFormat.java
##########
@@ -186,73 +188,79 @@ public void close() throws IOException {
if (resultScanner != null) {
resultScanner.close();
}
- } finally {
+ closeTable();
+ } finally {
Review comment:
nit:
```suggestion
} finally {
```
##########
File path:
flink-connectors/flink-connector-hbase/src/main/java/org/apache/flink/connector/hbase/source/AbstractTableInputFormat.java
##########
@@ -186,73 +188,79 @@ public void close() throws IOException {
if (resultScanner != null) {
resultScanner.close();
}
- } finally {
+ closeTable();
+ } finally {
resultScanner = null;
}
}
- @Override
- public void closeInputFormat() throws IOException {
+ public void closeTable() throws IOException {
try {
if (table != null) {
table.close();
}
+ if (connection != null) {
+ connection.close();
+ }
+ } catch (IOException e) {
+ if (connection != null) {
+ connection.close();
+ }
+ throw e;
Review comment:
The duplicate close looks strange to me. I think @rmetzger gave a nice
idea above. You can just catch and log the error and move each close in a
separate try block. You can take
`org.apache.flink.connector.hbase.sink.HBaseSinkFunction#close` as an example.
That will be much clean.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]