diff --git Jenkinsfile Jenkinsfile
index fceddb1..ad4c95b 100644
--- Jenkinsfile
+++ Jenkinsfile
@@ -171,7 +171,8 @@
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 itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
index 73620f2..d4d9002 100644
--- itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
+++ itests/hive-minikdc/src/test/java/org/apache/hive/minikdc/TestRemoteHiveMetaStoreDualAuthKerb.java
@@ -70,7 +70,7 @@
}
@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 standalone-metastore/metastore-common/pom.xml standalone-metastore/metastore-common/pom.xml
index a535737..521e92b 100644
--- standalone-metastore/metastore-common/pom.xml
+++ standalone-metastore/metastore-common/pom.xml
@@ -385,7 +385,7 @@
true
2048
-Djava.awt.headless=true -Xmx2048m -Xms512m
- ${basedir}/spotbugs/spotbugs-exclude.xml
+ ${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml
@@ -400,7 +400,7 @@
true
2048
-Djava.awt.headless=true -Xmx2048m -Xms512m
- ${basedir}/spotbugs/spotbugs-exclude.xml
+ ${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
index bcce1f1..7327391 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ColumnType.java
@@ -21,6 +21,7 @@
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 @@
);
// This map defines the progression of up casts in numeric types.
- public static final Map NumericCastOrder = new HashMap<>();
+ public static final Map 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 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 decoratedTypeNames = new HashSet<>();
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
index 71af793..54850ae 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/HiveMetaStoreClient.java
@@ -795,7 +795,7 @@
}
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 static String[] getProcessorCapabilities() {
- return processorCapabilities;
+ return processorCapabilities != null ? Arrays.copyOf(processorCapabilities, processorCapabilities.length) : null;
}
public static String getProcessorIdentifier() {
@@ -885,7 +885,7 @@
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 @@
Map 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 entry: fromClient.entrySet()) {
+ result.put(entry.getKey(), deepCopy(entry.getValue()));
}
}
return result;
@@ -2013,7 +2013,7 @@
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 @@
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 static final String KEY_CAPABILITIES = "OBJCAPABILITIES";
public TableCapabilityBuilder() {
- capabilitiesString = new String();
+ capabilitiesString = "";
}
public TableCapabilityBuilder add(String skill) {
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
index e46340e..c118bf9 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreAnonymousAuthenticationProviderImpl.java
@@ -26,7 +26,7 @@
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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
index d040461d..f7b605b 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreConfigAuthenticationProviderImpl.java
@@ -53,7 +53,7 @@
}
@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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
index 7698d9f..3916f64 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreCustomAuthenticationProviderImpl.java
@@ -63,8 +63,8 @@
}
@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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
index 568758a..51f0d1a 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStoreLdapAuthenticationProviderImpl.java
@@ -22,6 +22,8 @@
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 @@
}
@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 @@
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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
index 113f2ec..e921ee6 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePasswdAuthenticationProvider.java
@@ -35,5 +35,5 @@
* @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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
index dcc43e9..e4d35b9 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/MetaStorePlainSaslHelper.java
@@ -115,7 +115,7 @@
}
MetaStorePasswdAuthenticationProvider provider =
MetaStoreAuthenticationProviderFactory.getAuthenticationProvider(conf, authMethod);
- provider.Authenticate(username, password);
+ provider.authenticate(username, password);
if (ac != null) {
ac.setAuthorized(true);
}
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
index 690b1f3..110b335 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/ReplChangeManager.java
+++ 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 @@
// 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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
index 7092ee8..dcd9132 100755
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/Warehouse.java
@@ -778,15 +778,15 @@
public static String makePartName(List partCols,
List 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 colNames = new ArrayList<>();
for (FieldSchema col: partCols) {
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
index db1017b..25b2b07 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/conf/MetastoreConf.java
@@ -33,6 +33,7 @@
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 @@
"metastore.authentication.ldap.userMembershipKey";
private static final Map 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 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 @@
* 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 @@
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 @@
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 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 @@
* @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 @@
} 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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
index 1866446..4ea19fa 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/partition/spec/PartitionSpecProxy.java
@@ -24,6 +24,7 @@
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 @@
@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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
index 53ed214..fff3452 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge.java
@@ -23,6 +23,7 @@
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 @@
// 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 @@
}
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 @@
*
* 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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
index dc76535..2700054 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/security/HadoopThriftAuthBridge23.java
@@ -52,8 +52,10 @@
// 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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
index b731e38..1da9c08 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/FileUtils.java
@@ -243,7 +243,7 @@
}
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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
index 7711d6c..37d42a1 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/HdfsUtils.java
@@ -362,10 +362,7 @@
Iterables.removeIf(entries, new Predicate() {
@Override
public boolean apply(AclEntry input) {
- if (input.getName() == null) {
- return true;
- }
- return false;
+ return input == null || input.getName() == null;
}
});
}
diff --git standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
index 7d144c5..90b4288 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/MetaStoreUtils.java
@@ -20,9 +20,12 @@
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 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 static ClassLoader addToClassPath(ClassLoader cloader, String[] newPaths) throws Exception {
List curPath = getCurrentClassPaths(cloader);
- ArrayList 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 @@
}
}
- return new URLClassLoader(curPath.toArray(new URL[0]), cloader);
+ return AccessController.doPrivileged(new PrivilegedAction() {
+ @Override
+ public ClassLoader run() {
+ return new URLClassLoader(curPath.toArray(new URL[0]), cloader);
+ }
+ });
}
/**
@@ -887,7 +888,9 @@
* 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 standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
index 032eaf4..f237b36 100644
--- standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
+++ standalone-metastore/metastore-common/src/main/java/org/apache/hadoop/hive/metastore/utils/Retry.java
@@ -60,7 +60,7 @@
if (MAX_RETRIES == tries) {
throw e;
} else {
- Thread.sleep(DELAY * tries);
+ Thread.sleep((long) DELAY * tries);
return runWithDelay();
}
} else {
diff --git standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
index 002fd07..536dd51 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestMetaStoreLdapAuthenticationProviderImpl.java
@@ -74,21 +74,21 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
index c9ec6db..4f0ebca 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/TestRemoteHiveMetaStoreCustomAuth.java
@@ -153,7 +153,7 @@
}
@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 standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
index c73de77..a619c6d 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/conf/TestMetastoreConf.java
@@ -131,7 +131,7 @@
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 @@
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 standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
index 90e32bf..1a404a8 100644
--- standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
+++ standalone-metastore/metastore-server/src/test/java/org/apache/hadoop/hive/metastore/ldap/LdapAuthenticationTestCase.java
@@ -43,7 +43,7 @@
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 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 standalone-metastore/pom.xml standalone-metastore/pom.xml
index f296055..b0267aa 100644
--- standalone-metastore/pom.xml
+++ standalone-metastore/pom.xml
@@ -104,6 +104,7 @@
4.2.0
3.5.5
8.1.1
+ 4.0.3
you-must-set-this-to-run-thrift
@@ -378,6 +379,15 @@
+
+
+ com.github.spotbugs
+ spotbugs-annotations
+ ${spotbugs.version}
+ provided
+
+
+
@@ -474,5 +484,47 @@
+
+ spotbugs
+
+
+
+
+ com.github.spotbugs
+ spotbugs-maven-plugin
+ 4.0.0
+
+
+
+ com.github.spotbugs
+ spotbugs
+ ${spotbugs.version}
+
+
+
+ true
+ 2048
+ -Djava.awt.headless=true -Xmx2048m -Xms512m
+ ${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml
+
+
+
+
+
+
+
+ com.github.spotbugs
+ spotbugs-maven-plugin
+ 4.0.0
+
+ true
+ 2048
+ -Djava.awt.headless=true -Xmx2048m -Xms512m
+ ${basedir}/${standalone.metastore.path.to.root}/spotbugs/spotbugs-exclude.xml
+
+
+
+
+
diff --git standalone-metastore/spotbugs/spotbugs-exclude.xml standalone-metastore/spotbugs/spotbugs-exclude.xml
index e2c76d0..da4b99b 100644
--- standalone-metastore/spotbugs/spotbugs-exclude.xml
+++ standalone-metastore/spotbugs/spotbugs-exclude.xml
@@ -21,4 +21,10 @@
+
+
+
+
+
+