hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ewan Higgs (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-11221) Have StorageDirectory return Optional<File> instead of File/null
Date Mon, 09 Jan 2017 12:42:59 GMT

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

Ewan Higgs commented on HDFS-11221:

Yes, but instead of using {{protected}}, I meant replacing the existing {{public}} function.
However, as there are 70 places where {{getCurrentDir}} is used, it may make sense to have
both functions so each call site doesn't need to call {{getRoot}} first.


public Optional<File> getCurrentDir() {
  if (root == null) {
    return Optional.empty();
  } else {
    return Optional.of(getCurrentDir(root));

public File getCurrentDir(File root) {
  return new File(root, STORAGE_DIR_CURRENT);

> Have StorageDirectory return Optional<File> instead of File/null
> ----------------------------------------------------------------
>                 Key: HDFS-11221
>                 URL: https://issues.apache.org/jira/browse/HDFS-11221
>             Project: Hadoop HDFS
>          Issue Type: Task
>            Reporter: Ewan Higgs
>            Assignee: Jiajia Li
>            Priority: Minor
>         Attachments: HDFS-11221-v1.patch
> In HDFS-10675, {{StorageDirectory.root}} can be {{null}} because {{PROVIDED}} storage
locations will not have any directories associated with them. Hence, we need to add checks
to StorageDirectory to make sure we handle this. This would also lead to changes in code that
call {{StorageDirectory.getRoot}}, {{StorageDirectory.getCurrentDir}}, {{StorageDirectory.getVersionFile}}
etc. as the return value can be {{nul}}l (if {{StorageDirectory.root}} is null).
> The proposal to handle this is to change the return type of the above functions to {{Optional<File>}}.
According to my preliminary check, this will result in changes in ~70 places, which is why
it's not appropriate to put it in the patch for HDFS-10675. But it is certainly a valuable

This message was sent by Atlassian JIRA

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

View raw message