zhaoyim commented on a change in pull request #2037:
URL: https://github.com/apache/hadoop/pull/2037#discussion_r450003649
##########
File path:
hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/tools/DFSAdmin.java
##########
@@ -201,8 +201,19 @@ public void run(Path path) throws IOException {
super(conf);
CommandFormat c = new CommandFormat(2, Integer.MAX_VALUE);
List<String> parameters = c.parse(args, pos);
- this.quota =
-
StringUtils.TraditionalBinaryPrefix.string2long(parameters.remove(0));
+ String str = parameters.get(0).trim();
+ try {
+ this.quota = StringUtils.TraditionalBinaryPrefix
+ .string2long(parameters.remove(0));
+ } catch(NumberFormatException e){
+ throw new IllegalArgumentException("\"" + str +
+ "\" is not a valid value for a quota.");
+ }
+ if (HdfsConstants.QUOTA_DONT_SET == this.quota) {
+ System.out.print("WARN: \"" + this.quota +
Review comment:
I tried return directly before, but there is an extra invalid message
throw ```setQuota: null```. checked the code it is not easy to change, because
the warn message is in the ```SetSpaceQuotaCommand``` constructor. Maybe throw
an exception or current solution are both OK. any ideas? Thanks!
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]