HADOOP-15755. StringUtils#createStartupShutdownMessage throws NPE when args is null. Contributed by Lokesh Jain and Dinesh Chitlangia
This commit is contained in:
parent
5896372761
commit
e71f61ecb8
@ -743,7 +743,7 @@ public static String createStartupShutdownMessage(String classname,
|
||||
return toStartupShutdownString("STARTUP_MSG: ", new String[] {
|
||||
"Starting " + classname,
|
||||
" host = " + hostname,
|
||||
" args = " + Arrays.asList(args),
|
||||
" args = " + (args != null ? Arrays.asList(args) : new ArrayList<>()),
|
||||
" version = " + VersionInfo.getVersion(),
|
||||
" classpath = " + System.getProperty("java.class.path"),
|
||||
" build = " + VersionInfo.getUrl() + " -r "
|
||||
|
@ -503,6 +503,15 @@ public void testEscapeHTML() {
|
||||
escapedStr, StringUtils.escapeHTML(htmlStr));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateStartupShutdownMessage() {
|
||||
//pass null args and method must still return a string beginning with
|
||||
// "STARTUP_MSG"
|
||||
String msg = StringUtils.createStartupShutdownMessage(
|
||||
this.getClass().getName(), "test.host", null);
|
||||
assertTrue(msg.startsWith("STARTUP_MSG:"));
|
||||
}
|
||||
|
||||
// Benchmark for StringUtils split
|
||||
public static void main(String []args) {
|
||||
final String TO_SPLIT = "foo,bar,baz,blah,blah";
|
||||
|
Loading…
Reference in New Issue
Block a user