[ https://issues.apache.org/jira/browse/HDFS-9337?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14999921#comment-14999921 ]
Vinayakumar B commented on HDFS-9337: ------------------------------------- We can have a generic method as below. {code} @SuppressWarnings("rawtypes") private void validateOpParams(HttpOpParam<?> op, Param... params) { for (Param param : params) { if (param == null || param.getValueString().isEmpty()) { throw new IllegalArgumentException( "One or more required params for op: " + op.getValueString() + " is null or empty"); } } }{code} And call wherever validation required with required params. We need to be careful here while choosing required params. Some ops will take default values in NameNode side itself when there is null/empty value passed. Such params are not 'required' params. Ex for rename snapshot validation is as below. {code} case RENAMESNAPSHOT: { validateOpParams(op, oldSnapshotName, snapshotName); np.renameSnapshot(fullpath, oldSnapshotName.getValue(), snapshotName.getValue()); return Response.ok().type(MediaType.APPLICATION_OCTET_STREAM).build(); }{code} > In webhdfs Nullpoint exception will be thrown in renamesnapshot when > oldsnapshotname is not given > ------------------------------------------------------------------------------------------------- > > Key: HDFS-9337 > URL: https://issues.apache.org/jira/browse/HDFS-9337 > Project: Hadoop HDFS > Issue Type: Bug > Reporter: Jagadesh Kiran N > Assignee: Jagadesh Kiran N > Attachments: HDFS-9337_00.patch, HDFS-9337_01.patch, > HDFS-9337_02.patch > > > {code} > curl -i -X PUT > "http://10.19.92.127:50070/webhdfs/v1/kiran/sreenu?op=RENAMESNAPSHOT&snapshotname=SNAPSHOTNAME" > {code} > Null point exception will be thrown > {code} > {"RemoteException":{"exception":"NullPointerException","javaClassName":"java.lang.NullPointerException","message":null}} > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332)