[ https://issues.apache.org/jira/browse/HADOOP-10521?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13982201#comment-13982201 ]
Uma Maheswara Rao G edited comment on HADOOP-10521 at 4/27/14 6:32 AM: ----------------------------------------------------------------------- Regarding to Enum#valueOf, how does below code piece look? Of course guava library does that Illegalargumentexception handling and return null to us, if there is no enum value exist. {code} private final static Function<String, ENCODE> encodeValueOfFunc = Enums .valueOfFunction(ENCODE.class); ......... ......... ......... if (en != null) { encode = encodeValueOfFunc.apply(en); } Preconditions.checkArgument(encode != null, "Invalid/unsupported econding option specified: en=" + en); Test: runCommand(new String[] { "-getfattr", "-e", "invalid","-n", "xattrname", "/file1" }); result: -getfattr: Invalid/unsupported encoding option specified: en=invalid {code} Also please cover this validation cases in your tests. tiny nit: "Can not specify both '-n name' and '-x name' *option.*" --> "Can not specify both '-n name' and '-x name' *options.*" ? was (Author: umamaheswararao): Regarding to Enum#valueOf, how does below code piece look? Of course guava library does that Illegalargumentexception handling and return null to us, if there is no enum value exist. {code} private final static Function<String, ENCODE> encodeValueOfFunc = Enums .valueOfFunction(ENCODE.class); ......... ......... ......... if (en != null) { encode = encodeValueOfFunc.apply(en); } Preconditions.checkArgument(encode != null, "Invalid/unsupported econding option specified: en=" + en); Test: runCommand(new String[] { "-getfattr", "-e", "invalid","-n", "xattrname", "/file1" }); result: -getfattr: Invalid/unsupported encoding option specified: en=invalid {code} tiny nit: "Can not specify both '-n name' and '-x name' *option.*" --> "Can not specify both '-n name' and '-x name' *options.*" ? > FsShell commands for extended attributes. > ----------------------------------------- > > Key: HADOOP-10521 > URL: https://issues.apache.org/jira/browse/HADOOP-10521 > Project: Hadoop Common > Issue Type: Sub-task > Components: fs > Affects Versions: HDFS XAttrs (HDFS-2006) > Reporter: Yi Liu > Assignee: Yi Liu > Attachments: HADOOP-10521.1.patch, HADOOP-10521.2.patch, > HADOOP-10521.3.patch, HADOOP-10521.patch > > > “setfattr” and “getfattr” commands are added to FsShell for XAttr, and these > are the same as in Linux. -- This message was sent by Atlassian JIRA (v6.2#6252)