|
So this is all really inconsistent. And to make it consistent I would vote for throwing rather than returning null, but throwing FileNotFoundException instead of the base IOException. Then it would make implementation of exists() rather simple. Hairong has addressed these inconsistencies in
Yes, the implementation of exists() in terms of getFileStatus() would be simple. However it is considered bad style to use exceptions for normal control flow, and exists() returning false is a normal condition. We might just have to live with that... > Hairong has addressed these inconsistencies in isDir() will be removed in
Talked to Konstantine regarding this. Even though the idea of catching exception and returning bool does not look correct, for time being that approach was felt acceptable. The attached patch implements exists(Path) in terms of getFileStatus(Path). This patch also deprecates ClientProtocol#exists and Serverside exists.
-1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12379012/HADOOP-2634-1.patch against trunk revision 643282. @author +1. The patch does not contain any @author tags. tests included -1. The patch doesn't appear to include any new or modified tests. javadoc +1. The javadoc tool did not generate any warning messages. javac +1. The applied patch does not generate any new javac compiler warnings. release audit +1. The applied patch does not generate any new release audit warnings. findbugs +1. The patch does not introduce any new Findbugs warnings. core tests +1. The patch passed core unit tests. contrib tests +1. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/2115/testReport/ This message is automatically generated. This patch deprecates exists() in ClientProtocol so does not include any testcase.
The rest looks good. +1 Thanks Konstantine. Attaching new patch handling this case.
-1 overall. Here are the results of testing the latest attachment
http://issues.apache.org/jira/secure/attachment/12379203/HADOOP-2634-2.patch against trunk revision 643282. @author +1. The patch does not contain any @author tags. tests included -1. The patch doesn't appear to include any new or modified tests. javadoc +1. The javadoc tool did not generate any warning messages. javac +1. The applied patch does not generate any new javac compiler warnings. release audit +1. The applied patch does not generate any new release audit warnings. findbugs +1. The patch does not introduce any new Findbugs warnings. core tests +1. The patch passed core unit tests. contrib tests +1. The patch passed contrib unit tests. Test results: http://hudson.zones.apache.org/hudson/job/Hadoop-Patch/2131/testReport/ This message is automatically generated. I just committed this. Thanks, Lohit!
Integrated in Hadoop-trunk #450 (See http://hudson.zones.apache.org/hudson/job/Hadoop-trunk/450/
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
FileSystem#exists() should probably be made a concrete method in FileSystem.java, defined in terms of getFileStatus(), most existing implementations can probably be removed, and it could probably be deprecated.
BTW, what is getFileStatus() supposed to do when a file does not exist? Throw an IOException or return null? The former is generally preferable, but the latter makes implementing exists() easier, since we should not use exception handling for normal program flow.
I don't see a need to do this the day before 0.16 feature freeze, and it could be destabilizing.