You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Matthias Pohl (Jira)" <ji...@apache.org> on 2023/10/27 14:40:00 UTC
[jira] [Comment Edited] (FLINK-33367) Invalid Check in DefaultFileFilter
[ https://issues.apache.org/jira/browse/FLINK-33367?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17780409#comment-17780409 ]
Matthias Pohl edited comment on FLINK-33367 at 10/27/23 2:39 PM:
-----------------------------------------------------------------
Makes sense. But to answer the questions:
{quote}1) Can a file name ever be null?
{quote}
I assume not. But the JavaDoc is not precise on that one. So, it's fair to add a null check to be on the safe side, I guess.
{quote}2) What will be the behavior with return true? Should it be return false rather?
{quote}
{{DefaultFileFilter}} is meant to filter out hidden files (i.e. starting with '.' or '_'). Any other files should pass through. If you check the JavaDoc of the Java stream filter method, you will see that it filters elements that don't satisfy the passed Predicate. Considering this, returning {{true}} for files that don't have a name (because they cannot have a leading '.' or '_') seems to be reasonable.
was (Author: mapohl):
But to answer the questions:
{quote}
1) Can a file name ever be null?
{quote}
I assume not. But the JavaDoc is not precise on that one. So, it's fair to add a null check to be on the safe side, I guess.
{quote}
2) What will be the behavior with return true? Should it be return false rather?
{quote}
{{DefaultFileFilter}} is meant to filter out hidden files (i.e. starting with '.' or '_'). Any other files should pass through. If you check the JavaDoc of the Java stream filter method, you will see that it filters elements that don't satisfy the passed Predicate. Considering this, returning {{true}} for files that don't have a name (because they cannot have a leading '.' or '_') seems to be reasonable.
> Invalid Check in DefaultFileFilter
> ----------------------------------
>
> Key: FLINK-33367
> URL: https://issues.apache.org/jira/browse/FLINK-33367
> Project: Flink
> Issue Type: Bug
> Components: Connectors / FileSystem
> Affects Versions: 1.16.2
> Reporter: Chirag Dewan
> Priority: Minor
>
> There is a null check in DefaultFileFilter:
>
> if (fileName == null || fileName.length() == 0)
> { return true; }
>
> So 2 questions here -
> 1) Can a file name ever be null?
> 2) What will be the behavior with return true? Should it be return false rather?
--
This message was sent by Atlassian Jira
(v8.20.10#820010)