Skip to content

Commit 8f7c101

Browse files
Hean ChhinlingHean Chhinling
authored andcommitted
Updating the log level to debug and warn instead of info level
1 parent d0ba380 commit 8f7c101

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/main/java/org/apache/hadoop/yarn/webapp/util/WebAppUtils.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,10 @@
4747
import org.apache.hadoop.yarn.webapp.NotFoundException;
4848
import org.apache.http.NameValuePair;
4949
import org.apache.http.client.utils.URLEncodedUtils;
50+
import javax.servlet.http.HttpServletRequest;
5051
import org.slf4j.Logger;
5152
import org.slf4j.LoggerFactory;
5253

53-
import javax.servlet.http.HttpServletRequest;
54-
5554
@Private
5655
@Evolving
5756
public class WebAppUtils {
@@ -512,18 +511,16 @@ static String getPassword(Configuration conf, String alias) {
512511
char[] passchars = conf.getPassword(alias);
513512
if (passchars != null) {
514513
password = new String(passchars);
515-
LOG.info("Successful password retrieval for alias: {}", alias);
514+
LOG.debug("Successful password retrival for alias: {}", alias);
515+
} else {
516+
LOG.warn("Password retrieval failed, no password found for alias: {}", alias);
516517
}
517518
}
518519
catch (IOException ioe) {
519520
password = null;
520521
LOG.error("Unable to retrieve password for alias: {}", alias, ioe);
521522
}
522523

523-
if (password == null) {
524-
LOG.error("Password does not exist for alias: {}", alias);
525-
}
526-
527524
return password;
528525
}
529526

hadoop-yarn-project/hadoop-yarn/hadoop-yarn-common/src/test/java/org/apache/hadoop/yarn/webapp/util/TestWebAppUtils.java

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
import java.util.Map;
2626
import javax.servlet.http.HttpServletRequest;
2727

28-
import org.apache.hadoop.yarn.util.TestBoundedAppender;
2928
import org.junit.jupiter.api.AfterAll;
3029
import org.junit.jupiter.api.BeforeAll;
3130
import org.junit.jupiter.api.Test;
@@ -44,7 +43,6 @@
4443
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
4544
import static org.junit.jupiter.api.Assertions.assertEquals;
4645
import static org.junit.jupiter.api.Assertions.assertNull;
47-
import static org.mockito.Mockito.when;
4846

4947
public class TestWebAppUtils {
5048
private static final String RM1_NODE_ID = "rm1";
@@ -115,7 +113,7 @@ void testGetPassword() throws Exception {
115113
void testGetPasswordIOException() throws Exception {
116114
Configuration mockConf = Mockito.mock(Configuration.class);
117115

118-
when(mockConf.getPassword("error-alias")).thenThrow(new IOException("Simulated IO error"));
116+
Mockito.when(mockConf.getPassword("error-alias")).thenThrow(new IOException("Simulated IO error"));
119117

120118
assertNull(WebAppUtils.getPassword(mockConf, "error-alias"));
121119
}
@@ -197,7 +195,7 @@ protected Configuration provisionCredentialsForSSL() throws IOException,
197195
void testAppendQueryParams() throws Exception {
198196
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
199197
String targetUri = "/test/path";
200-
when(request.getCharacterEncoding()).thenReturn(null);
198+
Mockito.when(request.getCharacterEncoding()).thenReturn(null);
201199
Map<String, String> paramResultMap = new HashMap<>();
202200
paramResultMap.put("param1=x", targetUri + "?" + "param1=x");
203201
paramResultMap
@@ -206,7 +204,7 @@ void testAppendQueryParams() throws Exception {
206204
targetUri + "?" + "param1=x&param2=y&param3=x+y");
207205

208206
for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
209-
when(request.getQueryString()).thenReturn(entry.getKey());
207+
Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
210208
String uri = WebAppUtils.appendQueryParams(request, targetUri);
211209
assertEquals(entry.getValue(), uri);
212210
}
@@ -216,8 +214,8 @@ void testAppendQueryParams() throws Exception {
216214
void testGetHtmlEscapedURIWithQueryString() throws Exception {
217215
HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
218216
String targetUri = "/test/path";
219-
when(request.getCharacterEncoding()).thenReturn(null);
220-
when(request.getRequestURI()).thenReturn(targetUri);
217+
Mockito.when(request.getCharacterEncoding()).thenReturn(null);
218+
Mockito.when(request.getRequestURI()).thenReturn(targetUri);
221219
Map<String, String> paramResultMap = new HashMap<>();
222220
paramResultMap.put("param1=x", targetUri + "?" + "param1=x");
223221
paramResultMap
@@ -226,7 +224,7 @@ void testGetHtmlEscapedURIWithQueryString() throws Exception {
226224
targetUri + "?" + "param1=x&amp;param2=y&amp;param3=x+y");
227225

228226
for (Map.Entry<String, String> entry : paramResultMap.entrySet()) {
229-
when(request.getQueryString()).thenReturn(entry.getKey());
227+
Mockito.when(request.getQueryString()).thenReturn(entry.getKey());
230228
String uri = WebAppUtils.getHtmlEscapedURIWithQueryString(request);
231229
assertEquals(entry.getValue(), uri);
232230
}

0 commit comments

Comments
 (0)