tajo-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (TAJO-1877) Adopt try-resource statement to AbstractDBStore
Date Wed, 21 Oct 2015 01:38:27 GMT

    [ https://issues.apache.org/jira/browse/TAJO-1877?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14966092#comment-14966092
] 

ASF GitHub Bot commented on TAJO-1877:
--------------------------------------

Github user jihoonson commented on a diff in the pull request:

    https://github.com/apache/tajo/pull/808#discussion_r42575461
  
    --- Diff: tajo-catalog/tajo-catalog-server/src/main/java/org/apache/tajo/catalog/store/AbstractDBStore.java
---
    @@ -678,29 +635,20 @@ public void dropDatabase(String databaseName) throws UndefinedDatabaseException
       }
     
       private Collection<String> getAllDatabaseNamesInternal(@Nullable String whereCondition)
{
    -    Connection conn = null;
    -    PreparedStatement pstmt = null;
    -    ResultSet resultSet = null;
    -
         List<String> databaseNames = new ArrayList<>();
     
    -    try {
    -      String sql = "SELECT DB_NAME FROM " + TB_DATABASES;
    +    String sql = "SELECT DB_NAME FROM " + TB_DATABASES;
     
    -      if (whereCondition != null) {
    -        sql += " WHERE " + whereCondition;
    -      }
    +    if (whereCondition != null) {
    +      sql += " WHERE " + whereCondition;
    +    }
     
    -      conn = getConnection();
    -      pstmt = conn.prepareStatement(sql);
    -      resultSet = pstmt.executeQuery();
    +    try (ResultSet resultSet = getConnection().prepareStatement(sql).executeQuery())
{
    --- End diff --
    
    PreparedStatement is not closed.


> Adopt try-resource statement to AbstractDBStore
> -----------------------------------------------
>
>                 Key: TAJO-1877
>                 URL: https://issues.apache.org/jira/browse/TAJO-1877
>             Project: Tajo
>          Issue Type: Sub-task
>          Components: Catalog
>            Reporter: Hyunsik Choi
>            Assignee: Dongkyu Hwangbo
>              Labels: newbie
>
> See https://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html.
JDK 7 introduced try-resource statement for better resource allocation and deallocation. We
can also adopt this feature to AbstractDBStore.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message