From 21c66614610a3c3c9189832faeb120a2ba8069bb Mon Sep 17 00:00:00 2001 From: Xiao Chen Date: Thu, 15 Mar 2018 20:14:22 -0700 Subject: [PATCH] HADOOP-15234. Throw meaningful message on null when initializing KMSWebApp. Contributed by fang zhenyi. --- .../org/apache/hadoop/crypto/key/kms/server/KMSWebApp.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSWebApp.java b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSWebApp.java index 1817a13a77..cb4bf7e15a 100644 --- a/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSWebApp.java +++ b/hadoop-common-project/hadoop-kms/src/main/java/org/apache/hadoop/crypto/key/kms/server/KMSWebApp.java @@ -28,6 +28,7 @@ import com.codahale.metrics.JmxReporter; import com.codahale.metrics.Meter; import com.codahale.metrics.MetricRegistry; +import com.google.common.base.Preconditions; import org.apache.hadoop.classification.InterfaceAudience; import org.apache.hadoop.conf.Configuration; import org.apache.hadoop.crypto.key.CachingKeyProvider; @@ -159,6 +160,11 @@ public void contextInitialized(ServletContextEvent sce) { } KeyProvider keyProvider = KeyProviderFactory.get(new URI(providerString), kmsConf); + Preconditions.checkNotNull(keyProvider, String.format("No" + + " KeyProvider has been initialized, please" + + " check whether %s '%s' is configured correctly in" + + " kms-site.xml.", KMSConfiguration.KEY_PROVIDER_URI, + providerString)); if (kmsConf.getBoolean(KMSConfiguration.KEY_CACHE_ENABLE, KMSConfiguration.KEY_CACHE_ENABLE_DEFAULT)) { long keyTimeOutMillis =