diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java index ff04ffe47a2ad..6667b2d67474a 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java @@ -47,8 +47,9 @@ import org.apache.hadoop.yarn.webapp.NotFoundException; import org.apache.http.NameValuePair; import org.apache.http.client.utils.URLEncodedUtils; - import javax.servlet.http.HttpServletRequest; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; @Private @Evolving @@ -61,6 +62,7 @@ public class WebAppUtils { "ssl.server.keystore.keypassword"; public static final String HTTPS_PREFIX = "https://"; public static final String HTTP_PREFIX = "http://"; + public static final Logger LOG = LoggerFactory.getLogger(WebAppUtils.class); public static void setRMWebAppPort(Configuration conf, int port) { String hostname = getRMWebAppURLWithoutScheme(conf); @@ -509,11 +511,16 @@ static String getPassword(Configuration conf, String alias) { char[] passchars = conf.getPassword(alias); if (passchars != null) { password = new String(passchars); + LOG.debug("Successful password retrival for alias: {}", alias); + } else { + LOG.warn("Password retrieval failed, no password found for alias: {}", alias); } } catch (IOException ioe) { password = null; + LOG.error("Unable to retrieve password for alias: {}", alias, ioe); } + return password; } diff --git a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java index 2d9c39aba8b8d..166a4841ac6f9 100644 --- a/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java +++ b/hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java @@ -109,6 +109,15 @@ void testGetPassword() throws Exception { assertNull(WebAppUtils.getPassword(conf, "invalid-alias")); } + @Test + void testGetPasswordIOException() throws Exception { + Configuration mockConf = Mockito.mock(Configuration.class); + + Mockito.when(mockConf.getPassword("error-alias")).thenThrow(new IOException("Simulated IO error")); + + assertNull(WebAppUtils.getPassword(mockConf, "error-alias")); + } + @Test void testLoadSslConfiguration() throws Exception { Configuration conf = provisionCredentialsForSSL();