hadoop-common-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eli Collins (JIRA)" <j...@apache.org>
Subject [jira] Commented: (HADOOP-6796) FileStatus allows null srcPath but crashes if that's done
Date Wed, 02 Jun 2010 18:53:44 GMT

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

Eli Collins commented on HADOOP-6796:
-------------------------------------

I think classes like FileStatus (eg writables) are special cases where the user has to know
that they're using a constructor that leaves the object partially constructed. All the fields
are invalid when using the default constructor, by the same logic we should also set a default
owner, group etc instead of using null and converting to "". The path is not special (other
parts of the system are not happy with "" users). While objects like this are less user friendly
(they violate the rule that a constructor leaves an object in a valid state) they prevent
you from allocating a bunch of objects that you're just going to overwrite.  The default constructor
for most of the other objects that implement writable (eg FsPermission) leave their fields
as null as well. Its a trade off between performance and user friendlyness, the code currently
sacrifies user friendlyness for performance.  If we didn't do that you can see someone doing
some profiling and following a jira that notices "we create a lot of objects in the default
constructors that we immediately overwrite, let's avoid that".  Not vetoing your patch, just
pointing out that there's a reason the code works the way it does. This isn't a one off case
where it's different, so we should be consistent.

Assertions are only enabled when the unit tests run, so there's no performance impact. I think
asserts are good practice, not a maintenance burden, by that's my 2c.


> 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.


Mime
View raw message