hive-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ekoif...@apache.org
Subject svn commit: r1654448 - in /hive/branches/branch-1.0/metastore/src: java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java
Date Sat, 24 Jan 2015 01:21:55 GMT
Author: ekoifman
Date: Sat Jan 24 01:21:55 2015
New Revision: 1654448

URL: http://svn.apache.org/r1654448
Log:
HIVE-9404 NPE in org.apache.hadoop.hive.metastore.txn.TxnHandler.determineDatabaseProduct()

Added:
    hive/branches/branch-1.0/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java
Modified:
    hive/branches/branch-1.0/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java

Modified: hive/branches/branch-1.0/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-1.0/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java?rev=1654448&r1=1654447&r2=1654448&view=diff
==============================================================================
--- hive/branches/branch-1.0/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
(original)
+++ hive/branches/branch-1.0/metastore/src/java/org/apache/hadoop/hive/metastore/txn/TxnHandler.java
Sat Jan 24 01:21:55 2015
@@ -902,7 +902,7 @@ public class TxnHandler {
     // so I've tried to capture the different error messages (there appear to be fewer different
     // error messages than SQL states).
     // Derby and newer MySQL driver use the new SQLTransactionRollbackException
-    if (dbProduct == null) {
+    if (dbProduct == null && conn != null) {
       determineDatabaseProduct(conn);
     }
     if (e instanceof SQLTransactionRollbackException ||

Added: hive/branches/branch-1.0/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java
URL: http://svn.apache.org/viewvc/hive/branches/branch-1.0/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java?rev=1654448&view=auto
==============================================================================
--- hive/branches/branch-1.0/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java
(added)
+++ hive/branches/branch-1.0/metastore/src/test/org/apache/hadoop/hive/metastore/txn/TestTxnHandlerNegative.java
Sat Jan 24 01:21:55 2015
@@ -0,0 +1,49 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hive.metastore.txn;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.hadoop.hive.conf.HiveConf;
+import org.apache.hadoop.hive.metastore.api.MetaException;
+import org.junit.Test;
+
+public class TestTxnHandlerNegative {
+  static final private Log LOG = LogFactory.getLog(TestTxnHandlerNegative.class);
+
+  /**
+   * this intentionally sets a bad URL for connection to test error handling logic
+   * in TxnHandler
+   * @throws Exception
+   */
+  @Test
+  public void testBadConnection() throws Exception {
+    HiveConf conf = new HiveConf();
+    conf.setVar(HiveConf.ConfVars.METASTORECONNECTURLKEY, "blah");
+    TxnHandler txnHandler1 = new TxnHandler(conf);
+    MetaException e = null;
+    try {
+      txnHandler1.getOpenTxns();
+    }
+    catch(MetaException ex) {
+      LOG.info("Expected error: " + ex.getMessage(), ex);
+      e = ex;
+    }
+    assert e != null : "did not get exception";
+  }
+}



Mime
View raw message