[ 
https://issues.apache.org/jira/browse/HADOOP-5687?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12699848#action_12699848
 ] 

Philip Zeyliger commented on HADOOP-5687:
-----------------------------------------

Hi Konstantin,

Thanks for taking a look at this.

bq. I think NPE related to authority = null should be handled in 
NetUtils.createSocketAddr(). This is a general problem not just name-node's.

The best I could do in createSocketAddr() is throw IllegalArgumentException, 
instead of NPE.  (For readability, I like Preconditions.checkNotNull() from 
http://google-collections.googlecode.com/svn/trunk/javadoc/com/google/common/base/Preconditions.html#checkNotNull(T)
 (Google's Collections Library), but "if (x == null) { throw new 
IllegalArgumentException("..."); }" is the same.  That's reasonable, but not 
terribly useful by itself.  What I'd like to do is to give the user a good 
error message.

Would you prefer that I add the check to throw IllegalArgumentException in 
NetUtils?  I feel like I'd have to keep an if statement (or catch the 
IllegalArgumentException) in NameNode to keep the nice error message.

bq. Checking that URI has the hdfs scheme is basically an assert, otherwise 
this would not be called.

I don't think Hadoop checks for "hdfs" higher in the stack; I set 
fs.default.name to hdXXXXfs://doorstop.local/, and the check I proposed in the 
patch was triggered.  I take the view that assertions should be statements that 
the programmer feels must be true if the program has no bugs.  Just like a 
compiler doesn't throw an assertion for a syntax error in your program, Hadoop 
shouldn't assert for a configuration error.  (I'm thinking of the first 
definition in http://c2.com/cgi/wiki?WhatAreAssertions).

bq. use HDFS_URI_SCHEME instead of DFS_URI_SCHEME

Sure; done.

bq.  and place it in FSContants rather than DistributedFileSystem

Sure; done.

> Hadoop NameNode throws NPE if fs.default.name is the default value
> ------------------------------------------------------------------
>
>                 Key: HADOOP-5687
>                 URL: https://issues.apache.org/jira/browse/HADOOP-5687
>             Project: Hadoop Core
>          Issue Type: Improvement
>          Components: dfs
>            Reporter: Philip Zeyliger
>            Priority: Minor
>         Attachments: HADOOP-5687.patch, HADOOP-5687.patch
>
>
> Throwing NPE is confusing; instead, an exception with a useful string 
> description could be thrown instead.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to