drill-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "ASF GitHub Bot (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DRILL-2618) BasicFormatMatcher calls getFirstPath(...) without checking # of paths is not zero
Date Fri, 20 Nov 2015 01:45:11 GMT

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

ASF GitHub Bot commented on DRILL-2618:
---------------------------------------

Github user hnfgns commented on a diff in the pull request:

    https://github.com/apache/drill/pull/270#discussion_r45427577
  
    --- Diff: exec/java-exec/src/main/java/org/apache/drill/exec/store/dfs/FileSelection.java
---
    @@ -19,82 +19,72 @@
     
     import java.io.IOException;
     import java.net.URI;
    -import java.util.Collections;
     import java.util.List;
    -import java.util.concurrent.TimeUnit;
    -
    -import com.google.common.base.Stopwatch;
    -import org.apache.commons.lang3.ArrayUtils;
    -import org.apache.commons.lang3.StringUtils;
    -import org.apache.drill.exec.store.parquet.Metadata.ParquetTableMetadata_v1;
    -import org.apache.hadoop.fs.FileStatus;
    -import org.apache.hadoop.fs.Path;
    +import javax.annotation.Nullable;
     
     import com.fasterxml.jackson.annotation.JsonIgnore;
    +import com.google.common.base.Preconditions;
    +import com.google.common.base.Predicate;
    +import com.google.common.base.Strings;
    +import com.google.common.collect.Iterables;
     import com.google.common.collect.Lists;
    +import org.apache.hadoop.fs.FileStatus;
    +import org.apache.hadoop.fs.Path;
     
     /**
    - * Jackson serializable description of a file selection. Maintains an internal set of
file statuses. However, also
    - * serializes out as a list of Strings. All accessing methods first regenerate the FileStatus
objects if they are not
    - * available.  This allows internal movement of FileStatus and the ability to serialize
if need be.
    + * Jackson serializable description of a file selection.
      */
     public class FileSelection {
       static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(FileSelection.class);
     
       @JsonIgnore
    -  private List<FileStatus> statuses;
    +  public List<FileStatus> statuses;
     
       public List<String> files;
       public String selectionRoot;
     
    -  // this is a temporary location for the reference to Parquet metadata
    -  // TODO: ideally this should be in a Parquet specific derived class.
    -  private ParquetTableMetadata_v1 parquetMeta = null;
    -
    -  public FileSelection() {
    -  }
    -
    -  public FileSelection(List<String> files, String selectionRoot, boolean dummy)
{
    -    this.files = files;
    -    this.selectionRoot = selectionRoot;
    -  }
    -
    -  public FileSelection(List<String> files, boolean dummy) {
    -    this.files = files;
    -  }
    -
    -  public FileSelection(List<FileStatus> statuses) {
    -    this(statuses, null);
    -  }
    -
    -  public FileSelection(List<String> files, String selectionRoot,
    -      ParquetTableMetadata_v1 meta) {
    +  /**
    +   * Creates a {@link FileSelection selection} out of given file statuses/files and selection
root.
    +   *
    +   * @param statuses  list of file statuses
    +   * @param files  list of files
    +   * @param selectionRoot  root path for selections
    +   *
    +   * @throws IllegalArgumentException if the list of statuses and files are null or empty.
    +   */
    +  protected FileSelection(List<FileStatus> statuses, List<String> files,
String selectionRoot) {
    +    final boolean emptySelection = (statuses == null || statuses.size() == 0) &&
(files == null || files.size() == 0);
    +    Preconditions.checkArgument(!emptySelection, "Either statuses or files must be supplied
not both/node of them");
    --- End diff --
    
    done.


> BasicFormatMatcher calls getFirstPath(...) without checking # of paths is not zero
> ----------------------------------------------------------------------------------
>
>                 Key: DRILL-2618
>                 URL: https://issues.apache.org/jira/browse/DRILL-2618
>             Project: Apache Drill
>          Issue Type: Bug
>          Components: Storage - Other
>            Reporter: Daniel Barclay (Drill)
>            Assignee: Deneche A. Hakim
>             Fix For: 1.4.0
>
>
> {{BasicFormatMatcher.isReadable(...)}} calls {{getFirstPath(...)}} without checking that
there is at least one path.  This can cause an IndexOutOfBoundsException.
> To reproduce, create an empty directory {{/tmp/CaseInsensitiveColumnNames}} and run {{exec/java-exec/src/test/java/org/apache/drill/TestExampleQueries.java}}.



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

Mime
View raw message