You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by ha...@apache.org on 2012/07/11 01:02:05 UTC

svn commit: r1359945 - /hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java

Author: hashutosh
Date: Tue Jul 10 23:02:05 2012
New Revision: 1359945

URL: http://svn.apache.org/viewvc?rev=1359945&view=rev
Log:
HIVE-3232 : Resource Leak: Fix the File handle leak in EximUtil.java (Kanna Karanam via Ashutosh Chauhan)

Modified:
    hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java

Modified: hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java
URL: http://svn.apache.org/viewvc/hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java?rev=1359945&r1=1359944&r2=1359945&view=diff
==============================================================================
--- hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java (original)
+++ hive/trunk/ql/src/java/org/apache/hadoop/hive/ql/parse/EximUtil.java Tue Jul 10 23:02:05 2012
@@ -79,11 +79,11 @@ public class EximUtil {
       // generate absolute path relative to home directory
       if (!path.startsWith("/")) {
         if (testMode) {
-          path = new Path(System.getProperty("build.dir.hive"),
-              path).toString();
+          path = (new Path(System.getProperty("build.dir.hive"),
+              path)).toUri().getPath();
         } else {
-          path = new Path(new Path("/user/" + System.getProperty("user.name")),
-              path).toString();
+          path = (new Path(new Path("/user/" + System.getProperty("user.name")),
+              path)).toUri().getPath();
         }
       }
       // set correct scheme and authority
@@ -144,8 +144,8 @@ public class EximUtil {
       String authority = uri.getAuthority();
       String path = uri.getPath();
       if (!path.startsWith("/")) {
-          path = new Path(System.getProperty("build.dir.hive"),
-              path).toString();
+          path = (new Path(System.getProperty("build.dir.hive"),
+              path)).toUri().getPath();
       }
       if (StringUtils.isEmpty(scheme)) {
           scheme = "pfile";
@@ -201,11 +201,12 @@ public class EximUtil {
     }
   }
 
-  public static Map.Entry<Table, List<Partition>> 
-      readMetaData(FileSystem fs, Path metadataPath) 
+  public static Map.Entry<Table, List<Partition>>
+      readMetaData(FileSystem fs, Path metadataPath)
       throws IOException, SemanticException {
+    FSDataInputStream mdstream = null;
     try {
-      FSDataInputStream mdstream = fs.open(metadataPath);
+      mdstream = fs.open(metadataPath);
       byte[] buffer = new byte[1024];
       ByteArrayOutputStream sb = new ByteArrayOutputStream();
       int read = mdstream.read(buffer);
@@ -238,6 +239,10 @@ public class EximUtil {
       throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("Error in serializing metadata"), e);
     } catch (TException e) {
       throw new SemanticException(ErrorMsg.GENERIC_ERROR.getMsg("Error in serializing metadata"), e);
+    } finally {
+      if (mdstream != null) {
+        mdstream.close();
+      }
     }
   }