diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/HostsFileWriter.java b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/HostsFileWriter.java index e171e2bbdc..9dd788d166 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/HostsFileWriter.java +++ b/hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/HostsFileWriter.java @@ -106,6 +106,10 @@ public void initOutOfServiceHosts(List decommissionHostNameAndPorts, for (String hostNameAndPort : decommissionHostNameAndPorts) { DatanodeAdminProperties dn = new DatanodeAdminProperties(); String[] hostAndPort = hostNameAndPort.split(":"); + if (hostAndPort.length != 2) { + throw new IllegalArgumentException("The decommision host name and port format is " + + "invalid. The format should be in :, not " + hostNameAndPort); + } dn.setHostName(hostAndPort[0]); dn.setPort(Integer.parseInt(hostAndPort[1])); dn.setAdminState(AdminStates.DECOMMISSIONED);