lanchengx commented on a change in pull request #13034:
URL: https://github.com/apache/shardingsphere/pull/13034#discussion_r728881662
##########
File path:
shardingsphere-proxy/shardingsphere-proxy-backend/src/main/java/org/apache/shardingsphere/proxy/backend/text/admin/mysql/executor/information/AbstractSelectInformationExecutor.java
##########
@@ -153,7 +153,14 @@ protected Object getSourceData(final String schemaName)
throws SQLException {
ShardingSphereResource resource =
ProxyContext.getInstance().getContextManager().getMetaDataContexts().getMetaData(schemaName).getResource();
Optional<Entry<String, DataSource>> dataSourceEntry =
resource.getDataSources().entrySet().stream().findFirst();
log.info("Actual SQL: {} ::: {}",
dataSourceEntry.orElseThrow(DatabaseNotExistedException::new).getKey(), sql);
- return
dataSourceEntry.get().getValue().getConnection().prepareStatement(sql).executeQuery();
+ Connection conn = dataSourceEntry.get().getValue().getConnection();
+ try {
+ return conn.prepareStatement(sql).executeQuery();
+ } catch (SQLException e) {
+ throw e;
+ } finally {
+ conn.close();
+ }
Review comment:
Good idea, do you think we should modify the method name to make the
intent of the method better understandable?
For example, modify `getSourceData` to `constructRowData`, modify the
original `constructRowData` to `doConstruct`, or other better names
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]