ChinmaySKulkarni commented on a change in pull request #460: PHOENIX-5184: 
HBase and Phoenix connection leaks in Indexing code path, OrphanViewTool and 
PhoenixConfigurationUtil
URL: https://github.com/apache/phoenix/pull/460#discussion_r264939137
 
 

 ##########
 File path: 
phoenix-core/src/main/java/org/apache/phoenix/mapreduce/PhoenixRecordWriter.java
 ##########
 @@ -52,10 +52,20 @@ public PhoenixRecordWriter(final Configuration 
configuration) throws SQLExceptio
     }
     
     public PhoenixRecordWriter(final Configuration configuration, Set<String> 
propsToIgnore) throws SQLException {
-        this.conn = 
ConnectionUtil.getOutputConnectionWithoutTheseProps(configuration, 
propsToIgnore);
-        this.batchSize = PhoenixConfigurationUtil.getBatchSize(configuration);
-        final String upsertQuery = 
PhoenixConfigurationUtil.getUpsertStatement(configuration);
-        this.statement = this.conn.prepareStatement(upsertQuery);
+        Connection connection = null;
+        try {
+            connection = 
ConnectionUtil.getOutputConnectionWithoutTheseProps(configuration, 
propsToIgnore);
+            this.batchSize = 
PhoenixConfigurationUtil.getBatchSize(configuration);
+            final String upsertQuery = 
PhoenixConfigurationUtil.getUpsertStatement(configuration);
+            this.statement = connection.prepareStatement(upsertQuery);
 
 Review comment:
   No exception can be thrown after instantiating the statement object, so that 
shouldn't be necessary. Besides, we close both the statement and the connection 
in the `close` method

----------------------------------------------------------------
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]


With regards,
Apache Git Services

Reply via email to