ayushtkn commented on code in PR #6691:
URL: https://github.com/apache/hadoop/pull/6691#discussion_r1544792799


##########
hadoop-hdfs-project/hadoop-hdfs/src/test/java/org/apache/hadoop/hdfs/util/HostsFileWriter.java:
##########
@@ -106,9 +106,14 @@ public void initOutOfServiceHosts(List<String> 
decommissionHostNameAndPorts,
         for (String hostNameAndPort : decommissionHostNameAndPorts) {
           DatanodeAdminProperties dn = new DatanodeAdminProperties();
           String[] hostAndPort = hostNameAndPort.split(":");
-          dn.setHostName(hostAndPort[0]);
-          dn.setPort(Integer.parseInt(hostAndPort[1]));
-          dn.setAdminState(AdminStates.DECOMMISSIONED);
+          try {
+            dn.setHostName(hostAndPort[0]);
+            dn.setPort(Integer.parseInt(hostAndPort[1]));
+            dn.setAdminState(AdminStates.DECOMMISSIONED);
+          } catch (Exception e) {
+            throw new IllegalArgumentException("The decommision host name and 
port format is "
+                + "invalid. The format should be in <host>:<port>, not " + 
hostNameAndPort, e);
+          }

Review Comment:
   it would be better if we do a check above for the size of ``hostAndPort`` 
and throw exception above only, rather than doing this catch stuff, it will 
anyway catch all the exceptions not just IOBE 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to