hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From na...@apache.org
Subject svn commit: r1302550 - /hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
Date Mon, 19 Mar 2012 17:30:02 GMT
Author: namit
Date: Mon Mar 19 17:30:01 2012
New Revision: 1302550

URL: http://svn.apache.org/viewvc?rev=1302550&view=rev
Log:
HIVE-2864 If hive history file's directory doesn't exist don't crash
(Kevin Wilfong via namit)


Modified:
    hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java

Modified: hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java
URL: http://svn.apache.org/viewvc/hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java?rev=1302550&r1=1302549&r2=1302550&view=diff
==============================================================================
--- hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java (original)
+++ hive/trunk/cli/src/java/org/apache/hadoop/hive/cli/CliDriver.java Mon Mar 19 17:30:01
2012
@@ -658,8 +658,21 @@ public class CliDriver {
 
     String line;
     final String HISTORYFILE = ".hivehistory";
-    String historyFile = System.getProperty("user.home") + File.separator + HISTORYFILE;
-    reader.setHistory(new History(new File(historyFile)));
+    String historyDirectory = System.getProperty("user.home");
+    try {
+      if ((new File(historyDirectory)).exists()) {
+        String historyFile = historyDirectory + File.separator + HISTORYFILE;
+        reader.setHistory(new History(new File(historyFile)));
+      } else {
+        System.err.println("WARNING: Directory for Hive history file: " + historyDirectory
+
+                           " does not exist.   History will not be available during this
session.");
+      }
+    } catch (Exception e) {
+      System.err.println("WARNING: Encountered an error while trying to initialize Hive's
" +
+                         "history file.  History will not be available during this session.");
+      System.err.println(e.getMessage());
+    }
+
     int ret = 0;
 
     String prefix = "";



Mime
View raw message