[
https://issues.apache.org/jira/browse/HADOOP-6796?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12874338#action_12874338
]
Eli Collins commented on HADOOP-6796:
-------------------------------------
In cases where you want to explicitly tolerate objects that are only partially
constructed after calling the constructor (ie the user is responsible for
initializing the internals) it's often useful to provide an isValid method that
returns true if all the requisite fields have been initialized and public
methods assert isValid before they're called. This way there's no side effects
(ie you forget to set the src path but it happens to work because a default
value was specified, but the user doesn't know what that is without looking at
the object's internals) and the assert clearly indicates what field needs to be
set. This feels like overkill to me. Objects that can be partially constructed
are special cases where the user needs to know what fields are required, to me
it's better to get an NPE indicating the user needs to set the source path than
automatically constructing a path object for them using a value they may not be
aware of.
> FileStatus allows null srcPath but crashes if that's done
> ---------------------------------------------------------
>
> Key: HADOOP-6796
> URL: https://issues.apache.org/jira/browse/HADOOP-6796
> Project: Hadoop Common
> Issue Type: Bug
> Components: fs
> Affects Versions: 0.22.0
> Reporter: Rodrigo Schmidt
> Assignee: Rodrigo Schmidt
> Priority: Minor
> Fix For: 0.22.0
>
> Attachments: HADOOP-6796.patch
>
>
> FileStatus allows constructor invocation with a null srcPath but many methods
> like write, readFields, compareTo, equals, and hashCode depend on this
> property.
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.