terrymanu commented on a change in pull request #12324:
URL: https://github.com/apache/shardingsphere/pull/12324#discussion_r705967916
##########
File path:
shardingsphere-kernel/shardingsphere-authority/shardingsphere-authority-core/src/main/java/org/apache/shardingsphere/authority/provider/natived/builder/dialect/MySQLPrivilegeHandler.java
##########
@@ -56,12 +56,13 @@
@Override
public Collection<ShardingSphereUser> diff(final
Collection<ShardingSphereUser> users, final DataSource dataSource) throws
SQLException {
Collection<Grantee> grantees = new LinkedList<>();
- try (Connection connection = dataSource.getConnection()) {
- Statement statement = connection.createStatement();
- try (ResultSet resultSet =
statement.executeQuery(getGlobalPrivilegesSQL(users))) {
- while (resultSet.next()) {
- grantees.add(new Grantee(resultSet.getString("user"),
resultSet.getString("host")));
- }
+ try (
+ Connection connection = dataSource.getConnection();
+ Statement statement = connection.createStatement();
+ ResultSet resultSet =
statement.executeQuery(getGlobalPrivilegesSQL(users))
+ ) {
+ while (resultSet.next()) {
+ grantees.add(new Grantee(resultSet.getString("user"),
resultSet.getString("host")));
Review comment:
Why the original code may resource leak?
The connection, statement and resultSet are all in try with resource
--
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]