hbase-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Vladimir Rodionov (JIRA)" <j...@apache.org>
Subject [jira] [Updated] (HBASE-16529) PathFilter accept implementations must be exception free
Date Tue, 30 Aug 2016 04:25:20 GMT

     [ https://issues.apache.org/jira/browse/HBASE-16529?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Vladimir Rodionov updated HBASE-16529:
--------------------------------------
    Description: 
As an example of a wrong PathFilter implementation:

FSUtils.ReferenceFileFilter

{code}
    @Override
    protected boolean accept(Path p, @CheckForNull Boolean isDir) {
      if (!StoreFileInfo.isReference(p)) {
        return false;
      }

      try {
        // only files can be references.
        return isFile(fs, isDir, p);
      } catch (IOException ioe) {
        // Maybe the file was moved or the fs was disconnected.
        LOG.warn("Skipping file " + p +" due to IOException", ioe);
        return false;
      }
    }
{code}

That is wrong. We can't say if path passes the filter or not if Exception is thrown. The general
rule: DO NOT USE ANY CALLS WHICH MAY THROW EXCEPTION INSIDE ACCEPT METHOD IMPLEMENTATION.

FSUtils contains several path filters for starter.




> PathFilter accept implementations must be exception free
> --------------------------------------------------------
>
>                 Key: HBASE-16529
>                 URL: https://issues.apache.org/jira/browse/HBASE-16529
>             Project: HBase
>          Issue Type: Umbrella
>            Reporter: Vladimir Rodionov
>
> As an example of a wrong PathFilter implementation:
> FSUtils.ReferenceFileFilter
> {code}
>     @Override
>     protected boolean accept(Path p, @CheckForNull Boolean isDir) {
>       if (!StoreFileInfo.isReference(p)) {
>         return false;
>       }
>       try {
>         // only files can be references.
>         return isFile(fs, isDir, p);
>       } catch (IOException ioe) {
>         // Maybe the file was moved or the fs was disconnected.
>         LOG.warn("Skipping file " + p +" due to IOException", ioe);
>         return false;
>       }
>     }
> {code}
> That is wrong. We can't say if path passes the filter or not if Exception is thrown.
The general rule: DO NOT USE ANY CALLS WHICH MAY THROW EXCEPTION INSIDE ACCEPT METHOD IMPLEMENTATION.
> FSUtils contains several path filters for starter.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message