You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by GitBox <gi...@apache.org> on 2022/11/26 10:48:53 UTC

[GitHub] [shardingsphere] zhaojinchao95 opened a new issue, #22441: Maybe ResultSet need to close with `try-with-resource`

zhaojinchao95 opened a new issue, #22441:
URL: https://github.com/apache/shardingsphere/issues/22441

   `master` https://github.com/apache/shardingsphere/commit/a9c3c1878e1e1e0d73656f1c3537f34608ead815
   
   I think the ResultSet need to with `try-with-resource`. Because if not close in time, The resources held by resultSet will not be released until the `GC`. 
   
   For example : 
   
   ```
    private ExecuteResult executeSQL(final String sql, final Statement statement, final ConnectionMode connectionMode, final boolean withMetaData, final DatabaseType storageType) throws SQLException {
           databaseCommunicationEngine.add(statement);
           if (execute(sql, statement, isReturnGeneratedKeys)) {
               ResultSet resultSet = statement.getResultSet();
               databaseCommunicationEngine.add(resultSet);
               return createQueryResult(resultSet, connectionMode, storageType);
           }
           return new UpdateResult(statement.getUpdateCount(), isReturnGeneratedKeys ? getGeneratedKey(statement) : 0L);
       }
   ```
   
   ```
       private long getGeneratedKey(final Statement statement) throws SQLException {
           ResultSet resultSet = statement.getGeneratedKeys();
           return resultSet.next() ? getGeneratedKeyIfInteger(resultSet) : 0L;
       }
   ```
   
   This is just a part, there are many places


-- 
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: notifications-unsubscribe@shardingsphere.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 closed issue #22441: Maybe ResultSet need to close with `try-with-resource`

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 closed issue #22441: Maybe ResultSet need to close with `try-with-resource`
URL: https://github.com/apache/shardingsphere/issues/22441


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [shardingsphere] zhaojinchao95 commented on issue #22441: Maybe ResultSet need to close with `try-with-resource`

Posted by GitBox <gi...@apache.org>.
zhaojinchao95 commented on issue #22441:
URL: https://github.com/apache/shardingsphere/issues/22441#issuecomment-1328483279

   The streaming merge not allow close `ResultSet`, This can only be guaranteed by the developers.


-- 
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: notifications-unsubscribe@shardingsphere.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org