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

hashutosh pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/hive.git


The following commit(s) were added to refs/heads/master by this push:
     new bf6a610  HIVE-21372 : Use Apache Commons IO To Read Stream To String 
(Beluga Behr via Ashutosh Chauhan)
bf6a610 is described below

commit bf6a6102dfcc8f1eade23e25f5fb6940e2f6aea6
Author: BELUGA BEHR <dam6...@gmail.com>
AuthorDate: Sun Apr 7 21:30:18 2019 -0700

    HIVE-21372 : Use Apache Commons IO To Read Stream To String (Beluga Behr 
via Ashutosh Chauhan)
    
    Signed-off-by: Ashutosh Chauhan <hashut...@apache.org>
---
 ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java 
b/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java
index 8c34a61..76c69cf 100644
--- a/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java
+++ b/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java
@@ -18,6 +18,7 @@
 
 package org.apache.hadoop.hive.ql.parse;
 
+import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.hadoop.fs.FSDataInputStream;
 import org.apache.hadoop.fs.FileSystem;
@@ -49,11 +50,11 @@ import org.json.JSONException;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.nio.charset.StandardCharsets;
 import java.util.Collection;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -320,14 +321,7 @@ public class EximUtil {
   public static String readAsString(final FileSystem fs, final Path 
fromMetadataPath)
       throws IOException {
     try (FSDataInputStream stream = fs.open(fromMetadataPath)) {
-      byte[] buffer = new byte[1024];
-      ByteArrayOutputStream sb = new ByteArrayOutputStream();
-      int read = stream.read(buffer);
-      while (read != -1) {
-        sb.write(buffer, 0, read);
-        read = stream.read(buffer);
-      }
-      return new String(sb.toByteArray(), "UTF-8");
+      return IOUtils.toString(stream, StandardCharsets.UTF_8);
     }
   }
 

Reply via email to