You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-issues@hadoop.apache.org by "teamconfx (via GitHub)" <gi...@apache.org> on 2024/04/05 08:08:30 UTC
Re: [PR] HDFS-17449. catch the IndexOutOfBounds and throw IllegalArgument instead [hadoop]
teamconfx commented on code in PR #6691:
URL: https://github.com/apache/hadoop/pull/6691#discussion_r1553156626
##########
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:
I've made the change accordingly. Thanks for the advice!
--
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: common-issues-unsubscribe@hadoop.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: common-issues-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-issues-help@hadoop.apache.org