Uploaded image for project: 'HBase'
  1. HBase
  2. HBASE-16529

PathFilter accept implementations must be exception free

    XMLWordPrintableJSON

Details

    • Umbrella
    • Status: Open
    • Major
    • Resolution: Unresolved
    • None
    • None
    • None
    • None

    Description

      As an example of a wrong PathFilter implementation:

      FSUtils.ReferenceFileFilter

          @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;
            }
          }
      

      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.

      See HBASE-16527.

      FSUtils contains several path filters for starter.

      Attachments

        Activity

          People

            Unassigned Unassigned
            vrodionov Vladimir Rodionov
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: