You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@hive.apache.org by kg...@apache.org on 2020/06/15 08:56:58 UTC

[hive] 02/05: HIVE-23687: Fix Spotbugs issues in hive-standalone-metastore-common (Mustafa Iman via Zoltan Haindrich)

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

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

commit 8fac12e718375c351135176324c9b388da1bd71b
Author: Mustafa Iman <mu...@gmail.com>
AuthorDate: Mon Jun 15 08:01:14 2020 +0000

    HIVE-23687: Fix Spotbugs issues in hive-standalone-metastore-common (Mustafa Iman via Zoltan Haindrich)
    
    Signed-off-by: Zoltan Haindrich <ki...@rxd.hu>
    
    Closes apache/hive#1107
---
 Jenkinsfile                                        |  3 +-
 .../TestRemoteHiveMetaStoreDualAuthKerb.java       |  2 +-
 standalone-metastore/metastore-common/pom.xml      |  4 +-
 .../apache/hadoop/hive/metastore/ColumnType.java   | 19 +++---
 .../hadoop/hive/metastore/HiveMetaStoreClient.java | 16 ++---
 ...taStoreAnonymousAuthenticationProviderImpl.java |  2 +-
 .../MetaStoreConfigAuthenticationProviderImpl.java |  2 +-
 .../MetaStoreCustomAuthenticationProviderImpl.java |  4 +-
 .../MetaStoreLdapAuthenticationProviderImpl.java   |  6 +-
 .../MetaStorePasswdAuthenticationProvider.java     |  2 +-
 .../hive/metastore/MetaStorePlainSaslHelper.java   |  2 +-
 .../hadoop/hive/metastore/ReplChangeManager.java   |  3 +-
 .../apache/hadoop/hive/metastore/Warehouse.java    | 10 +--
 .../hadoop/hive/metastore/conf/MetastoreConf.java  | 79 +++++++++++-----------
 .../partition/spec/PartitionSpecProxy.java         |  3 +-
 .../metastore/security/HadoopThriftAuthBridge.java |  7 +-
 .../security/HadoopThriftAuthBridge23.java         |  4 +-
 .../hadoop/hive/metastore/utils/FileUtils.java     |  2 +-
 .../hadoop/hive/metastore/utils/HdfsUtils.java     |  5 +-
 .../hive/metastore/utils/MetaStoreUtils.java       | 27 ++++----
 .../apache/hadoop/hive/metastore/utils/Retry.java  |  2 +-
 ...estMetaStoreLdapAuthenticationProviderImpl.java | 28 ++++----
 .../TestRemoteHiveMetaStoreCustomAuth.java         |  2 +-
 .../hive/metastore/conf/TestMetastoreConf.java     |  4 +-
 .../metastore/ldap/LdapAuthenticationTestCase.java |  4 +-
 standalone-metastore/pom.xml                       | 52 ++++++++++++++
 standalone-metastore/spotbugs/spotbugs-exclude.xml |  6 ++
 27 files changed, 184 insertions(+), 116 deletions(-)

diff --git a/Jenkinsfile b/Jenkinsfile
index fceddb1..ad4c95b 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -171,7 +171,8 @@ jobWrappers {
       stage('Prechecks') {
         def spotbugsProjects = [
             ":hive-shims",
-            ":hive-storage-api"
+            ":hive-storage-api",
+            ":hive-standalone-metastore-common"
         ]
         buildHive("-Pspotbugs -pl " + spotbugsProjects.join(",") + " -am compile com.github.spotbugs:spotbugs-maven-plugin:4.0.0:check")
       }
diff --git a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
index 73620f2..d4d9002 100644
--- a/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
+++ b/itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
@@ -70,7 +70,7 @@ public class TestRemoteHiveMetaStoreDualAuthKerb extends RemoteHiveMetaStoreDual
     }
 
     @Override
-    public void Authenticate(String user, String password) throws AuthenticationException {
+    public void authenticate(String user, String password) throws AuthenticationException {
 
       if(!userMap.containsKey(user)) {
         throw new AuthenticationException("Invalid user : "+user);
diff --git a/standalone-metastore/metastore-common/pom.xml b/standalone-metastore/metastore-common/pom.xml
index a535737..521e92b 100644
--- a/standalone-metastore/metastore-common/pom.xml
+++ b/standalone-metastore/metastore-common/pom.xml
@@ -385,7 +385,7 @@
               <fork>true</fork>
               <maxHeap>2048</maxHeap>
               <jvmArgs>-Djava.awt.headless=true -Xmx2048m -Xms512m</jvmArgs>
-              <excludeFilterFile>${basedir}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
+              <excludeFilterFile>${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
             </configuration>
           </plugin>
         </plugins>
@@ -400,7 +400,7 @@
               <fork>true</fork>
               <maxHeap>2048</maxHeap>
               <jvmArgs>-Djava.awt.headless=true -Xmx2048m -Xms512m</jvmArgs>
-              <excludeFilterFile>${basedir}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
+              <excludeFilterFile>${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
             </configuration>
           </plugin>
         </plugins>
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
index bcce1f1..7327391 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
@@ -21,6 +21,7 @@ import org.apache.hadoop.classification.InterfaceAudience;
 import org.apache.hadoop.classification.InterfaceStability;
 import org.apache.hadoop.hive.metastore.utils.StringUtils;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -133,16 +134,18 @@ public class ColumnType {
   );
 
   // This map defines the progression of up casts in numeric types.
-  public static final Map<String, Integer> NumericCastOrder = new HashMap<>();
+  public static final Map<String, Integer> NumericCastOrder;
 
   static {
-    NumericCastOrder.put(TINYINT_TYPE_NAME, 1);
-    NumericCastOrder.put(SMALLINT_TYPE_NAME, 2);
-    NumericCastOrder.put(INT_TYPE_NAME, 3);
-    NumericCastOrder.put(BIGINT_TYPE_NAME, 4);
-    NumericCastOrder.put(DECIMAL_TYPE_NAME, 5);
-    NumericCastOrder.put(FLOAT_TYPE_NAME, 6);
-    NumericCastOrder.put(DOUBLE_TYPE_NAME, 7);
+    Map<String, Integer> map = new HashMap<>();
+    map.put(TINYINT_TYPE_NAME, 1);
+    map.put(SMALLINT_TYPE_NAME, 2);
+    map.put(INT_TYPE_NAME, 3);
+    map.put(BIGINT_TYPE_NAME, 4);
+    map.put(DECIMAL_TYPE_NAME, 5);
+    map.put(FLOAT_TYPE_NAME, 6);
+    map.put(DOUBLE_TYPE_NAME, 7);
+    NumericCastOrder = Collections.unmodifiableMap(map);
   }
 
   private static final Set<String> decoratedTypeNames = new HashSet<>();
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 71af793..54850ae 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -795,7 +795,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
   }
 
   public static void setProcessorCapabilities(final String[] capabilities) {
-    processorCapabilities = capabilities;
+    processorCapabilities = capabilities != null ? Arrays.copyOf(capabilities, capabilities.length) : null;
   }
 
   public static void setProcessorIdentifier(final String id) {
@@ -803,7 +803,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
   }
 
   public static String[] getProcessorCapabilities() {
-    return processorCapabilities;
+    return processorCapabilities != null ? Arrays.copyOf(processorCapabilities, processorCapabilities.length) : null;
   }
 
   public static String getProcessorIdentifier() {
@@ -885,7 +885,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     if (new_parts == null || new_parts.contains(null)) {
       throw new MetaException("Partitions cannot be null.");
     }
-    if (new_parts != null && !new_parts.isEmpty() && !new_parts.get(0).isSetCatName()) {
+    if (!new_parts.isEmpty() && !new_parts.get(0).isSetCatName()) {
       final String defaultCat = getDefaultCatalog(conf);
       new_parts.forEach(p -> p.setCatName(defaultCat));
     }
@@ -1754,8 +1754,8 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     Map<String, Type> fromClient = client.get_type_all(name);
     if (fromClient != null) {
       result = new LinkedHashMap<>();
-      for (String key : fromClient.keySet()) {
-        result.put(key, deepCopy(fromClient.get(key)));
+      for (Map.Entry<String, Type> entry: fromClient.entrySet()) {
+        result.put(entry.getKey(), deepCopy(entry.getValue()));
       }
     }
     return result;
@@ -2013,7 +2013,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     if (catalogName != null)
       request.setCatalogName(catalogName);
     if (processorCapabilities != null) {
-      request.setProcessorCapabilities(Arrays.asList(processorCapabilities));
+      request.setProcessorCapabilities(new ArrayList<>(Arrays.asList(processorCapabilities)));
     }
     if (processorIdentifier != null) {
       request.setProcessorIdentifier(processorIdentifier);
@@ -3539,7 +3539,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     NotificationEventRequest rqst = new NotificationEventRequest(lastEventId);
     rqst.setMaxEvents(maxEvents);
     NotificationEventResponse rsp = client.get_next_notification(rqst);
-    LOG.debug("Got back {} events", rsp.getEventsSize());
+    LOG.debug("Got back {} events", rsp!= null ? rsp.getEventsSize() : 0);
     NotificationEventResponse filtered = new NotificationEventResponse();
     if (rsp != null && rsp.getEvents() != null) {
       long nextEventId = lastEventId + 1;
@@ -4327,7 +4327,7 @@ public class HiveMetaStoreClient implements IMetaStoreClient, AutoCloseable {
     public static final String KEY_CAPABILITIES = "OBJCAPABILITIES";
 
     public TableCapabilityBuilder() {
-      capabilitiesString = new String();
+      capabilitiesString = "";
     }
 
     public TableCapabilityBuilder add(String skill) {
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
index e46340e..c118bf9 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
@@ -26,7 +26,7 @@ import javax.security.sasl.AuthenticationException;
 public class MetaStoreAnonymousAuthenticationProviderImpl implements MetaStorePasswdAuthenticationProvider {
 
   @Override
-  public void Authenticate(String user, String password) throws AuthenticationException {
+  public void authenticate(String user, String password) throws AuthenticationException {
     // no-op authentication
   }
 
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
index d040461d..f7b605b 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
@@ -53,7 +53,7 @@ public class MetaStoreConfigAuthenticationProviderImpl implements MetaStorePassw
   }
 
   @Override
-  public void Authenticate(String authUser, String authPassword) throws AuthenticationException {
+  public void authenticate(String authUser, String authPassword) throws AuthenticationException {
     if (!userName.equals(authUser)) {
       LOG.debug("Invalid user " + authUser);
       throw new AuthenticationException("Invalid credentials");
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
index 7698d9f..3916f64 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
@@ -63,8 +63,8 @@ public class MetaStoreCustomAuthenticationProviderImpl implements MetaStorePassw
   }
 
   @Override
-  public void Authenticate(String user, String password) throws AuthenticationException {
-    customProvider.Authenticate(user, password);
+  public void authenticate(String user, String password) throws AuthenticationException {
+    customProvider.authenticate(user, password);
   }
 
 }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
index 568758a..51f0d1a 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
@@ -22,6 +22,8 @@ import javax.naming.NamingException;
 import com.google.common.annotations.VisibleForTesting;
 import com.google.common.collect.ImmutableList;
 import java.io.IOException;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Iterator;
 import java.util.List;
 import org.apache.commons.lang3.StringUtils;
@@ -70,7 +72,7 @@ public class MetaStoreLdapAuthenticationProviderImpl implements MetaStorePasswdA
   }
 
   @Override
-  public void Authenticate(String user, String password) throws AuthenticationException {
+  public void authenticate(String user, String password) throws AuthenticationException {
     DirSearch search = null;
     String bindUser = MetastoreConf.getVar(this.conf,
             MetastoreConf.ConfVars.METASTORE_PLAIN_LDAP_BIND_USER);
@@ -117,7 +119,7 @@ public class MetaStoreLdapAuthenticationProviderImpl implements MetaStorePasswdA
       throw new AuthenticationException("Error validating LDAP user:"
           + " a null or blank user name has been provided");
     }
-    if (StringUtils.isBlank(password) || password.getBytes()[0] == 0) {
+    if (StringUtils.isBlank(password) || password.getBytes(StandardCharsets.UTF_8)[0] == 0) {
       throw new AuthenticationException("Error validating LDAP user:"
           + " a null or blank password has been provided");
     }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
index 113f2ec..e921ee6 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
@@ -35,5 +35,5 @@ public interface MetaStorePasswdAuthenticationProvider {
    * @throws AuthenticationException When a user is found to be
    *                                 invalid by the implementation
    */
-  void Authenticate(String user, String password) throws AuthenticationException;
+  void authenticate(String user, String password) throws AuthenticationException;
 }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
index dcc43e9..e4d35b9 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
@@ -115,7 +115,7 @@ public final class MetaStorePlainSaslHelper {
       }
       MetaStorePasswdAuthenticationProvider provider =
         MetaStoreAuthenticationProviderFactory.getAuthenticationProvider(conf, authMethod);
-      provider.Authenticate(username, password);
+      provider.authenticate(username, password);
       if (ac != null) {
         ac.setAuthorized(true);
       }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
index 690b1f3..110b335 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
@@ -19,6 +19,7 @@
 package org.apache.hadoop.hive.metastore;
 
 import java.io.IOException;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.Executors;
@@ -293,7 +294,7 @@ public class ReplChangeManager {
         // xattr has limited capacity. We shall revisit and store all original
         // locations if orig-loc becomes important
         try {
-          fs.setXAttr(cmPath, ORIG_LOC_TAG, path.toString().getBytes());
+          fs.setXAttr(cmPath, ORIG_LOC_TAG, path.toString().getBytes(StandardCharsets.UTF_8));
         } catch (UnsupportedOperationException e) {
           LOG.warn("Error setting xattr for {}", path.toString());
         }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
index 7092ee8..dcd9132 100755
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
@@ -778,15 +778,15 @@ public class Warehouse {
   public static String makePartName(List<FieldSchema> partCols,
       List<String> vals, String defaultStr) throws MetaException {
     if ((partCols.size() != vals.size()) || (partCols.size() == 0)) {
-      String errorStr = "Invalid partition key & values; keys [";
+      StringBuilder errorStrBuilder = new StringBuilder("Invalid partition key & values; keys [");
       for (FieldSchema fs : partCols) {
-        errorStr += (fs.getName() + ", ");
+        errorStrBuilder.append(fs.getName()).append(", ");
       }
-      errorStr += "], values [";
+      errorStrBuilder.append("], values [");
       for (String val : vals) {
-        errorStr += (val + ", ");
+        errorStrBuilder.append(val).append(", ");
       }
-      throw new MetaException(errorStr + "]");
+      throw new MetaException(errorStrBuilder.append("]").toString());
     }
     List<String> colNames = new ArrayList<>();
     for (FieldSchema col: partCols) {
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index db1017b..25b2b07 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -33,6 +33,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
 import org.apache.hadoop.conf.Configuration;
 import org.apache.hadoop.hive.common.ZooKeeperHiveHelper;
 import org.apache.hadoop.hive.metastore.utils.StringUtils;
@@ -99,14 +100,22 @@ public class MetastoreConf {
           "metastore.authentication.ldap.userMembershipKey";
 
   private static final Map<String, ConfVars> metaConfs = new HashMap<>();
+  private static volatile URL hiveSiteURL = null;
   private static URL hiveDefaultURL = null;
-  private static URL hiveSiteURL = null;
   private static URL hiveMetastoreSiteURL = null;
   private static URL metastoreSiteURL = null;
   private static AtomicBoolean beenDumped = new AtomicBoolean();
 
   private static Map<String, ConfVars> keyToVars;
 
+  static {
+    keyToVars = new HashMap<>(ConfVars.values().length * 2);
+    for (ConfVars var : ConfVars.values()) {
+      keyToVars.put(var.varname, var);
+      keyToVars.put(var.hiveName, var);
+    }
+  }
+
   @VisibleForTesting
   static final String TEST_ENV_WORKAROUND = "metastore.testing.env.workaround.dont.ever.set.this.";
 
@@ -145,6 +154,7 @@ public class MetastoreConf {
    * TODO - I suspect the vast majority of these don't need to be here.  But it requires testing
    * before just pulling them out.
    */
+  @SuppressFBWarnings(value = "MS_MUTABLE_ARRAY")
   public static final MetastoreConf.ConfVars[] metaVars = {
       ConfVars.WAREHOUSE,
       ConfVars.REPLDIR,
@@ -1341,7 +1351,7 @@ public class MetastoreConf {
     STR_LIST_ENTRY("test.str.list", "hive.test.str.list", "a,b,c",
         "no comment"),
     LONG_TEST_ENTRY("test.long", "hive.test.long", 42, "comment"),
-    DOUBLE_TEST_ENTRY("test.double", "hive.test.double", 3.141592654, "comment"),
+    DOUBLE_TEST_ENTRY("test.double", "hive.test.double", Math.PI, "comment"),
     TIME_TEST_ENTRY("test.time", "hive.test.time", 1, TimeUnit.SECONDS, "comment"),
     TIME_VALIDATOR_ENTRY_INCLUSIVE("test.time.validator.inclusive", "hive.test.time.validator.inclusive", 1,
         TimeUnit.SECONDS,
@@ -1619,28 +1629,30 @@ public class MetastoreConf {
     if (result == null) {
       // Nope, so look to see if our conf dir has been explicitly set
       result = seeIfConfAtThisLocation("METASTORE_CONF_DIR", name, false);
-      if (result == null) {
-        // Nope, so look to see if our home dir has been explicitly set
-        result = seeIfConfAtThisLocation("METASTORE_HOME", name, true);
-        if (result == null) {
-          // Nope, so look to see if Hive's conf dir has been explicitly set
-          result = seeIfConfAtThisLocation("HIVE_CONF_DIR", name, false);
-          if (result == null) {
-            // Nope, so look to see if Hive's home dir has been explicitly set
-            result = seeIfConfAtThisLocation("HIVE_HOME", name, true);
-            if (result == null) {
-              // Nope, so look to see if we can find a conf file by finding our jar, going up one
-              // directory, and looking for a conf directory.
-              URI jarUri = null;
-              try {
-                jarUri = MetastoreConf.class.getProtectionDomain().getCodeSource().getLocation().toURI();
-              } catch (Throwable e) {
-                LOG.warn("Cannot get jar URI", e);
-              }
-              result = seeIfConfAtThisLocation(new File(jarUri).getParent(), name, true);
-            }
-          }
-        }
+    }
+    if (result == null) {
+      // Nope, so look to see if our home dir has been explicitly set
+      result = seeIfConfAtThisLocation("METASTORE_HOME", name, true);
+    }
+    if (result == null) {
+      // Nope, so look to see if Hive's conf dir has been explicitly set
+      result = seeIfConfAtThisLocation("HIVE_CONF_DIR", name, false);
+    }
+    if (result == null) {
+      // Nope, so look to see if Hive's home dir has been explicitly set
+      result = seeIfConfAtThisLocation("HIVE_HOME", name, true);
+    }
+    if (result == null) {
+      // Nope, so look to see if we can find a conf file by finding our jar, going up one
+      // directory, and looking for a conf directory.
+      URI jarUri = null;
+      try {
+        jarUri = MetastoreConf.class.getProtectionDomain().getCodeSource().getLocation().toURI();
+      } catch (Throwable e) {
+        LOG.warn("Cannot get jar URI", e);
+      }
+      if (jarUri != null) {
+        result = seeIfConfAtThisLocation(new File(jarUri).getParent(), name, true);
       }
     }
 
@@ -1754,7 +1766,7 @@ public class MetastoreConf {
   public static long getLongVar(Configuration conf, ConfVars var) {
     assert var.defaultVal.getClass() == Long.class;
     String val = conf.get(var.varname);
-    return val == null ? conf.getLong(var.hiveName, (Long)var.defaultVal) : Long.valueOf(val);
+    return val == null ? conf.getLong(var.hiveName, (Long)var.defaultVal) : Long.parseLong(val);
   }
 
   /**
@@ -1987,18 +1999,6 @@ public class MetastoreConf {
    * @return the value set
    */
   public static String get(Configuration conf, String key) {
-    // Map this key back to the ConfVars it is associated with.
-    if (keyToVars == null) {
-      synchronized (MetastoreConf.class) {
-        if (keyToVars == null) {
-          keyToVars = new HashMap<>(ConfVars.values().length * 2);
-          for (ConfVars var : ConfVars.values()) {
-            keyToVars.put(var.varname, var);
-            keyToVars.put(var.hiveName, var);
-          }
-        }
-      }
-    }
     ConfVars var = keyToVars.get(key);
     if (var == null) {
       // Ok, this isn't one we track.  Just return whatever matches the string
@@ -2030,9 +2030,8 @@ public class MetastoreConf {
     } else if (var.defaultVal.getClass() == Double.class) {
       return Double.toString(getDoubleVar(conf, var));
     } else if (var.defaultVal.getClass() == TimeValue.class) {
-      TimeUnit timeUnit = (var.defaultVal.getClass() == TimeValue.class) ?
-          ((TimeValue)var.defaultVal).unit : null;
-      return Long.toString(getTimeVar(conf, var, timeUnit)) + timeAbbreviationFor(timeUnit);
+      TimeUnit timeUnit = ((TimeValue)var.defaultVal).unit;
+      return getTimeVar(conf, var, timeUnit) + timeAbbreviationFor(timeUnit);
     } else {
       throw new RuntimeException("Unknown type for getObject " + var.defaultVal.getClass().getName());
     }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
index 1866446..4ea19fa 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
@@ -24,6 +24,7 @@ import org.apache.hadoop.hive.metastore.api.PartitionSpec;
 
 import java.util.List;
 import java.util.Map;
+import java.util.NoSuchElementException;
 
 /**
  * Polymorphic proxy class, equivalent to org.apache.hadoop.hive.metastore.api.PartitionSpec.
@@ -213,7 +214,7 @@ public abstract class PartitionSpecProxy {
     @Override public String getLocation() { return partition.getSd().getLocation(); }
     @Override public void setCreateTime(long time) { partition.setCreateTime((int)time);}
     @Override public boolean hasNext() { return false; } // No next partition.
-    @Override public Partition next() { return null; } // No next partition.
+    @Override public Partition next() { throw new NoSuchElementException(); } // No next partition.
     @Override public void remove() {} // Do nothing.
   } // P
 
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
index 53ed214..fff3452 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
@@ -23,6 +23,7 @@ import java.io.IOException;
 import java.net.InetAddress;
 import java.net.Socket;
 import java.net.UnknownHostException;
+import java.nio.charset.StandardCharsets;
 import java.security.PrivilegedAction;
 import java.security.PrivilegedExceptionAction;
 import java.util.Base64;
@@ -74,7 +75,7 @@ public abstract class HadoopThriftAuthBridge {
 
   // We want to have only one auth bridge.  In the past this was handled by ShimLoader, but since
   // we're no longer using that we'll do it here.
-  private static HadoopThriftAuthBridge self = null;
+  private static volatile HadoopThriftAuthBridge self = null;
 
   public static HadoopThriftAuthBridge getBridge() {
     if (self == null) {
@@ -302,7 +303,7 @@ public abstract class HadoopThriftAuthBridge {
       }
 
       static String encodeIdentifier(byte[] identifier) {
-        return new String(Base64.getEncoder().encode(identifier));
+        return new String(Base64.getEncoder().encode(identifier), StandardCharsets.UTF_8);
       }
 
       static char[] encodePassword(byte[] password) {
@@ -579,7 +580,7 @@ public abstract class HadoopThriftAuthBridge {
      *
      * This is used on the server side to set the UGI for each specific call.
      */
-    protected class TUGIAssumingProcessor implements TProcessor {
+    protected static class TUGIAssumingProcessor implements TProcessor {
       final TProcessor wrapped;
       DelegationTokenSecretManager secretManager;
       boolean useProxy;
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
index dc76535..2700054 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
@@ -52,8 +52,10 @@ public class HadoopThriftAuthBridge23 extends HadoopThriftAuthBridge {
       // HADOOP-10221, HADOOP-10451)
       try {
         RES_GET_INSTANCE_METHOD = SASL_PROPERTIES_RESOLVER_CLASS.getMethod("getInstance",
-            Configuration.class);
+                Configuration.class);
         GET_DEFAULT_PROP_METHOD = SASL_PROPERTIES_RESOLVER_CLASS.getMethod("getDefaultProperties");
+      } catch (RuntimeException e) {
+        throw e;
       } catch (Exception e) {
         // this must be hadoop 2.4 , where getDefaultProperties was protected
       }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
index b731e38..1da9c08 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
@@ -243,7 +243,7 @@ public class FileUtils {
   }
 
   private static boolean needsEscaping(char c) {
-    return c >= 0 && c < charToEscape.size() && charToEscape.get(c);
+    return c < charToEscape.size() && charToEscape.get(c);
   }
 
   public static String escapePathName(String path) {
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
index 7711d6c..37d42a1 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
@@ -362,10 +362,7 @@ public class HdfsUtils {
     Iterables.removeIf(entries, new Predicate<AclEntry>() {
       @Override
       public boolean apply(AclEntry input) {
-        if (input.getName() == null) {
-          return true;
-        }
-        return false;
+        return input == null || input.getName() == null;
       }
     });
   }
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
index 7d144c5..90b4288 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
@@ -20,9 +20,12 @@ package org.apache.hadoop.hive.metastore.utils;
 import java.io.File;
 import java.net.URL;
 import java.net.URLClassLoader;
+import java.security.AccessController;
+import java.security.PrivilegedAction;
 import java.text.DateFormat;
 import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.Iterator;
 import java.util.List;
@@ -195,15 +198,15 @@ public class MetaStoreUtils {
    */
   public static boolean validateName(String name, Configuration conf) {
     Pattern tpat;
-    String allowedSpecialCharacters = "";
+    StringBuilder allowedSpecialCharacters = new StringBuilder();
     if (conf != null
         && MetastoreConf.getBoolVar(conf,
         MetastoreConf.ConfVars.SUPPORT_SPECICAL_CHARACTERS_IN_TABLE_NAMES)) {
       for (Character c : SPECIAL_CHARACTERS_IN_TABLE_NAMES) {
-        allowedSpecialCharacters += c;
+        allowedSpecialCharacters.append(c);
       }
     }
-    tpat = Pattern.compile("[\\w" + Pattern.quote(allowedSpecialCharacters) + "]+");
+    tpat = Pattern.compile("[\\w" + Pattern.quote(allowedSpecialCharacters.toString()) + "]+");
     Matcher m = tpat.matcher(name);
     return m.matches();
   }
@@ -405,13 +408,6 @@ public class MetaStoreUtils {
    */
   public static ClassLoader addToClassPath(ClassLoader cloader, String[] newPaths) throws Exception {
     List<URL> curPath = getCurrentClassPaths(cloader);
-    ArrayList<URL> newPath = new ArrayList<>(curPath.size());
-
-    // get a list with the current classpath components
-    for (URL onePath : curPath) {
-      newPath.add(onePath);
-    }
-    curPath = newPath;
 
     for (String onestr : newPaths) {
       URL oneurl = urlFromPathString(onestr);
@@ -420,7 +416,12 @@ public class MetaStoreUtils {
       }
     }
 
-    return new URLClassLoader(curPath.toArray(new URL[0]), cloader);
+    return AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() {
+      @Override
+      public ClassLoader run() {
+        return new URLClassLoader(curPath.toArray(new URL[0]), cloader);
+      }
+    });
   }
 
   /**
@@ -887,7 +888,9 @@ public class MetaStoreUtils {
    * database name with the proper delimiters.
    */
   public static String[] parseDbName(String dbName, Configuration conf) throws MetaException {
-    if (dbName == null) return nullCatalogAndDatabase;
+    if (dbName == null) {
+      return Arrays.copyOf(nullCatalogAndDatabase, nullCatalogAndDatabase.length);
+    }
     if (hasCatalogName(dbName)) {
       if (dbName.endsWith(CATALOG_DB_SEPARATOR)) {
         // This means the DB name is null
diff --git a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
index 032eaf4..f237b36 100644
--- a/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
+++ b/standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
@@ -60,7 +60,7 @@ public abstract class Retry<T> {
         if (MAX_RETRIES == tries) {
           throw e;
         } else {
-          Thread.sleep(DELAY * tries);
+          Thread.sleep((long) DELAY * tries);
           return runWithDelay();
         }
       } else {
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
index 002fd07..536dd51 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
@@ -74,21 +74,21 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
   public void authenticateGivenBlankPassword() throws Exception {
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, new LdapSearchFactory());
     expectAuthenticationExceptionForInvalidPassword();
-    auth.Authenticate("user", "");
+    auth.authenticate("user", "");
   }
 
   @Test
   public void authenticateGivenStringWithNullCharacterForPassword() throws Exception {
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, new LdapSearchFactory());
     expectAuthenticationExceptionForInvalidPassword();
-    auth.Authenticate("user", "\0");
+    auth.authenticate("user", "\0");
   }
 
   @Test
   public void authenticateGivenNullForPassword() throws Exception {
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, new LdapSearchFactory());
     expectAuthenticationExceptionForInvalidPassword();
-    auth.Authenticate("user", null);
+    auth.authenticate("user", null);
   }
 
   @Test
@@ -104,7 +104,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(factory.getInstance(conf, "cn=user1,ou=Users,dc=mycorp,dc=com", "Blah")).thenThrow(AuthenticationException.class);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate("user1", "Blah");
+    auth.authenticate("user1", "Blah");
 
     verify(factory, times(2)).getInstance(isA(Configuration.class), anyString(), eq("Blah"));
     verify(search, atLeastOnce()).close();
@@ -282,7 +282,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.isUserMemberOfGroup("user1", groupDn)).thenReturn(true);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate("user1", "Blah");
+    auth.authenticate("user1", "Blah");
 
     verify(factory, times(1)).getInstance(isA(Configuration.class), anyString(), eq("Blah"));
     verify(search, times(1)).findGroupDn(anyString());
@@ -304,7 +304,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.isUserMemberOfGroup("user1", groupDn)).thenReturn(false);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate("user1", "Blah");
+    auth.authenticate("user1", "Blah");
   }
 
   @Test
@@ -327,7 +327,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.isUserMemberOfGroup("user1", "cn=HIVE-USERS2,ou=Groups,ou=branch1,dc=mycorp,dc=com")).thenReturn(true);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate("user1", "Blah");
+    auth.authenticate("user1", "Blah");
 
     verify(factory, times(1)).getInstance(isA(Configuration.class), anyString(), eq("Blah"));
     verify(search, times(2)).findGroupDn(anyString());
@@ -352,7 +352,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.findUserDn(eq(authUser))).thenReturn(authFullUser);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
 
     verify(factory, times(1)).getInstance(isA(Configuration.class), eq(bindUser), eq(bindPass));
     verify(factory, times(1)).getInstance(isA(Configuration.class), eq(authFullUser), eq(authPass));
@@ -370,7 +370,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     conf.set(CredentialProviderFactory.CREDENTIAL_PROVIDER_PATH, credentialsPath);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
 
     verify(factory, times(1)).getInstance(isA(Configuration.class), eq(authUser), eq(authPass));
   }
@@ -388,7 +388,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.findUserDn(eq(authUser))).thenReturn(authFullUser);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
 
     verify(factory, times(1)).getInstance(isA(Configuration.class), eq(bindUser), eq(bindPass));
     verify(factory, times(1)).getInstance(isA(Configuration.class), eq(authFullUser), eq(authPass));
@@ -411,7 +411,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.findUserDn(eq(authUser))).thenReturn(authFullUser);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
   }
 
   @Test
@@ -428,7 +428,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(search.findUserDn(eq(authUser))).thenThrow(NamingException.class);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
   }
 
   @Test
@@ -444,7 +444,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
     when(factory.getInstance(any(Configuration.class), eq(bindUser), eq(bindPass))).thenThrow(AuthenticationException.class);
 
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
-    auth.Authenticate(authUser, authPass);
+    auth.authenticate(authUser, authPass);
   }
 
   private void expectAuthenticationExceptionForInvalidPassword() {
@@ -455,7 +455,7 @@ public class TestMetaStoreLdapAuthenticationProviderImpl {
   private void authenticateUserAndCheckSearchIsClosed(String user) throws IOException {
     auth = new MetaStoreLdapAuthenticationProviderImpl(conf, factory);
     try {
-      auth.Authenticate(user, "password doesn't matter");
+      auth.authenticate(user, "password doesn't matter");
     } finally {
       verify(search, atLeastOnce()).close();
     }
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
index c9ec6db..4f0ebca 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
@@ -153,7 +153,7 @@ public class TestRemoteHiveMetaStoreCustomAuth extends TestRemoteHiveMetaStore {
     }
 
     @Override
-    public void Authenticate(String user, String password) throws AuthenticationException {
+    public void authenticate(String user, String password) throws AuthenticationException {
 
       if(!userMap.containsKey(user)) {
         throw new AuthenticationException("Invalid user : " + user);
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
index c73de77..a619c6d 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
@@ -131,7 +131,7 @@ public class TestMetastoreConf {
     conf = MetastoreConf.newMetastoreConf();
     Assert.assertEquals("defaultval", MetastoreConf.getVar(conf, ConfVars.STR_TEST_ENTRY));
     Assert.assertEquals(42, MetastoreConf.getLongVar(conf, ConfVars.LONG_TEST_ENTRY));
-    Assert.assertEquals(3.141592654, MetastoreConf.getDoubleVar(conf, ConfVars.DOUBLE_TEST_ENTRY),
+    Assert.assertEquals(Math.PI, MetastoreConf.getDoubleVar(conf, ConfVars.DOUBLE_TEST_ENTRY),
         0.0000001);
     Assert.assertTrue(MetastoreConf.getBoolVar(conf, ConfVars.BOOLEAN_TEST_ENTRY));
     Assert.assertEquals(1, MetastoreConf.getTimeVar(conf, ConfVars.TIME_TEST_ENTRY, TimeUnit.SECONDS));
@@ -148,7 +148,7 @@ public class TestMetastoreConf {
     Assert.assertEquals("defaultval", MetastoreConf.get(conf, ConfVars.STR_TEST_ENTRY.getHiveName()));
     Assert.assertEquals("defaultval", MetastoreConf.getAsString(conf, ConfVars.STR_TEST_ENTRY));
     Assert.assertEquals("42", MetastoreConf.getAsString(conf, ConfVars.LONG_TEST_ENTRY));
-    Assert.assertEquals("3.141592654", MetastoreConf.getAsString(conf, ConfVars.DOUBLE_TEST_ENTRY));
+    Assert.assertEquals("" + Math.PI, MetastoreConf.getAsString(conf, ConfVars.DOUBLE_TEST_ENTRY));
     Assert.assertEquals("true", MetastoreConf.getAsString(conf, ConfVars.BOOLEAN_TEST_ENTRY));
   }
 
diff --git a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
index 90e32bf..1a404a8 100644
--- a/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
+++ b/standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
@@ -43,7 +43,7 @@ public final class LdapAuthenticationTestCase {
 
   public void assertAuthenticatePasses(Credentials credentials) {
     try {
-      ldapProvider.Authenticate(credentials.getUser(), credentials.getPassword());
+      ldapProvider.authenticate(credentials.getUser(), credentials.getPassword());
     } catch (AuthenticationException e) {
       String message = String.format("Authentication failed for user '%s' with password '%s'",
           credentials.getUser(), credentials.getPassword());
@@ -61,7 +61,7 @@ public final class LdapAuthenticationTestCase {
 
   public void assertAuthenticateFails(String user, String password) {
     try {
-      ldapProvider.Authenticate(user, password);
+      ldapProvider.authenticate(user, password);
       Assert.fail(String.format("Expected authentication to fail for %s", user));
     } catch (AuthenticationException expected) {
       Assert.assertNotNull("Expected authentication exception", expected);
diff --git a/standalone-metastore/pom.xml b/standalone-metastore/pom.xml
index f296055..b0267aa 100644
--- a/standalone-metastore/pom.xml
+++ b/standalone-metastore/pom.xml
@@ -104,6 +104,7 @@
     <curator.version>4.2.0</curator.version>
     <zookeeper.version>3.5.5</zookeeper.version>
     <cron-utils.version>8.1.1</cron-utils.version>
+    <spotbugs.version>4.0.3</spotbugs.version>
 
     <!-- Thrift properties -->
     <thrift.home>you-must-set-this-to-run-thrift</thrift.home>
@@ -378,6 +379,15 @@
     </dependencies>
   </dependencyManagement>
 
+  <dependencies>
+    <dependency>
+      <groupId>com.github.spotbugs</groupId>
+      <artifactId>spotbugs-annotations</artifactId>
+      <version>${spotbugs.version}</version>
+      <scope>provided</scope>
+    </dependency>
+  </dependencies>
+
   <build>
     <pluginManagement>
       <plugins>
@@ -474,5 +484,47 @@
       </os>
     </activation>
     </profile>
+    <profile>
+      <id>spotbugs</id>
+      <build>
+        <plugins>
+          <!-- Execute as: com.github.spotbugs:spotbugs-maven-plugin:4.0.0:spotbugs -->
+          <plugin>
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-maven-plugin</artifactId>
+            <version>4.0.0</version>
+            <dependencies>
+              <!-- Specify the version of spotbugs -->
+              <dependency>
+                <groupId>com.github.spotbugs</groupId>
+                <artifactId>spotbugs</artifactId>
+                <version>${spotbugs.version}</version>
+              </dependency>
+            </dependencies>
+            <configuration>
+              <fork>true</fork>
+              <maxHeap>2048</maxHeap>
+              <jvmArgs>-Djava.awt.headless=true -Xmx2048m -Xms512m</jvmArgs>
+              <excludeFilterFile>${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
+            </configuration>
+          </plugin>
+        </plugins>
+      </build>
+      <reporting>
+        <plugins>
+          <plugin>
+            <groupId>com.github.spotbugs</groupId>
+            <artifactId>spotbugs-maven-plugin</artifactId>
+            <version>4.0.0</version>
+            <configuration>
+              <fork>true</fork>
+              <maxHeap>2048</maxHeap>
+              <jvmArgs>-Djava.awt.headless=true -Xmx2048m -Xms512m</jvmArgs>
+              <excludeFilterFile>${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml</excludeFilterFile>
+            </configuration>
+          </plugin>
+        </plugins>
+      </reporting>
+    </profile>
   </profiles>
 </project>
diff --git a/standalone-metastore/spotbugs/spotbugs-exclude.xml b/standalone-metastore/spotbugs/spotbugs-exclude.xml
index e2c76d0..da4b99b 100644
--- a/standalone-metastore/spotbugs/spotbugs-exclude.xml
+++ b/standalone-metastore/spotbugs/spotbugs-exclude.xml
@@ -21,4 +21,10 @@
     <Match>
         <Class name="~org.apache.hadoop.hive.metastore.api.*" />
     </Match>
+    <Match>
+        <Or>
+            <Class name="~org.apache.hadoop.hive.metastore.Metastore" />
+            <Class name="~org.apache.hadoop.hive.metastore.Metastore.*" />
+        </Or>
+    </Match>
 </FindBugsFilter>