HADOOP-15755. StringUtils#createStartupShutdownMessage throws NPE when args is null. Contributed by Lokesh Jain and Dinesh Chitlangia
(cherry picked from commit e71f61ecb8
)
Conflicts:
hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/util/TestStringUtils.java
This commit is contained in:
parent
373c7a0ceb
commit
f2eeba5c5b
|
@ -743,7 +743,7 @@ public class StringUtils {
|
||||||
return toStartupShutdownString("STARTUP_MSG: ", new String[] {
|
return toStartupShutdownString("STARTUP_MSG: ", new String[] {
|
||||||
"Starting " + classname,
|
"Starting " + classname,
|
||||||
" host = " + hostname,
|
" host = " + hostname,
|
||||||
" args = " + Arrays.asList(args),
|
" args = " + (args != null ? Arrays.asList(args) : new ArrayList<>()),
|
||||||
" version = " + VersionInfo.getVersion(),
|
" version = " + VersionInfo.getVersion(),
|
||||||
" classpath = " + System.getProperty("java.class.path"),
|
" classpath = " + System.getProperty("java.class.path"),
|
||||||
" build = " + VersionInfo.getUrl() + " -r "
|
" build = " + VersionInfo.getUrl() + " -r "
|
||||||
|
|
|
@ -476,6 +476,15 @@ public class TestStringUtils extends UnitTestcaseTimeLimit {
|
||||||
executorService.awaitTermination(50, TimeUnit.SECONDS);
|
executorService.awaitTermination(50, TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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
|
// Benchmark for StringUtils split
|
||||||
public static void main(String []args) {
|
public static void main(String []args) {
|
||||||
final String TO_SPLIT = "foo,bar,baz,blah,blah";
|
final String TO_SPLIT = "foo,bar,baz,blah,blah";
|
||||||
|
|
Loading…
Reference in New Issue