[ 
https://issues.apache.org/jira/browse/HDFS-13155?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16493574#comment-16493574
 ] 

Zsolt Venczel commented on HDFS-13155:
--------------------------------------

Thank you [~gabor.bota] for your review.

My motivation in introducing a ternary operator here was threefold:
 # I think having one liners where one line truly fits in one line (less then 
80 characters) can be more clear than multiple lines.
 # I felt that it's kind of a pattern to use such snipet for null checking.
 # I have taken a look at the code and did see similar constructs being used 
already.

This can be a matter of taste as well. What do you think?

> BlockPlacementPolicyDefault.chooseTargetInOrder Not Checking Return Value for 
> NULL
> ----------------------------------------------------------------------------------
>
>                 Key: HDFS-13155
>                 URL: https://issues.apache.org/jira/browse/HDFS-13155
>             Project: Hadoop HDFS
>          Issue Type: Improvement
>          Components: namenode
>    Affects Versions: 3.0.0
>            Reporter: BELUGA BEHR
>            Assignee: Zsolt Venczel
>            Priority: Minor
>         Attachments: HDFS-13155.01.patch
>
>
> {code:title=BlockPlacementPolicyDefault.java}
> protected Node chooseTargetInOrder(int numOfReplicas, 
>                                  Node writer,
>                                  final Set<Node> excludedNodes,
>                                  final long blocksize,
>                                  final int maxNodesPerRack,
>                                  final List<DatanodeStorageInfo> results,
>                                  final boolean avoidStaleNodes,
>                                  final boolean newBlock,
>                                  EnumMap<StorageType, Integer> storageTypes)
>                                  throws NotEnoughReplicasException {
>     final int numOfResults = results.size();
>     if (numOfResults == 0) {
>       writer = chooseLocalStorage(writer, excludedNodes, blocksize,
>           maxNodesPerRack, results, avoidStaleNodes, storageTypes, true)
>           .getDatanodeDescriptor();
>       if (--numOfReplicas == 0) {
>         return writer;
>       }
>     }
> ...
> {code}
> The method {{chooseLocalStorage}} can return a _null_ value but it's not 
> being checked here and the method {{getDatanodeDescriptor()}} is immediately 
> being called on the result.  Please check for a _null_ value first.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: hdfs-issues-unsubscr...@hadoop.apache.org
For additional commands, e-mail: hdfs-issues-h...@hadoop.apache.org

Reply via email to