You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@phoenix.apache.org by gj...@apache.org on 2019/07/02 23:26:42 UTC

[phoenix] branch 4.14-HBase-1.4 updated: PHOENIX-5379 : Avoid possible NPE while closing CSVParser

This is an automated email from the ASF dual-hosted git repository.

gjacoby pushed a commit to branch 4.14-HBase-1.4
in repository https://gitbox.apache.org/repos/asf/phoenix.git


The following commit(s) were added to refs/heads/4.14-HBase-1.4 by this push:
     new 598b216  PHOENIX-5379 : Avoid possible NPE while closing CSVParser
598b216 is described below

commit 598b2164252331c982667c89de0c751e73ecd6e3
Author: Viraj Jasani <vj...@salesforce.com>
AuthorDate: Fri Jun 28 21:51:37 2019 +0530

    PHOENIX-5379 : Avoid possible NPE while closing CSVParser
    
    Signed-off-by: Geoffrey Jacoby <gj...@apache.org>
---
 .../apache/phoenix/pherf/result/impl/CSVFileResultHandler.java   | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVFileResultHandler.java b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVFileResultHandler.java
index 8ddae67..a2dcab3 100644
--- a/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVFileResultHandler.java
+++ b/phoenix-pherf/src/main/java/org/apache/phoenix/pherf/result/impl/CSVFileResultHandler.java
@@ -47,11 +47,10 @@ public class CSVFileResultHandler extends CSVResultHandler {
     }
 
     public synchronized List<Result> read() throws IOException {
-        CSVParser parser = null;
         util.ensureBaseResultDirExists();
-        try {
-            File file = new File(resultFileName);
-            parser = CSVParser.parse(file, Charset.defaultCharset(), CSVFormat.DEFAULT);
+        File file = new File(resultFileName);
+        try (CSVParser parser = CSVParser
+                .parse(file, Charset.defaultCharset(), CSVFormat.DEFAULT)) {
             List<CSVRecord> records = parser.getRecords();
             List<Result> results = new ArrayList<>();
             String header = null;
@@ -70,8 +69,6 @@ public class CSVFileResultHandler extends CSVResultHandler {
                 results.add(result);
             }
             return results;
-        } finally {
-            parser.close();
         }
     }