Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-8407

libhdfs hdfsListDirectory must set errno to 0 on success

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 2.8.0, 3.0.0-alpha1
    • native
    • None

    Description

      The documentation says it returns NULL on error, but it could also return NULL when the directory is empty.
      /**

      • hdfsListDirectory - Get list of files/directories for a given
      • directory-path. hdfsFreeFileInfo should be called to deallocate memory.
      • @param fs The configured filesystem handle.
      • @param path The path of the directory.
      • @param numEntries Set to the number of files/directories in path.
      • @return Returns a dynamically-allocated array of hdfsFileInfo
      • objects; NULL on error.
        */
            hdfsFileInfo *pathList = NULL; 
            ...
            //Figure out the number of entries in that directory
            jPathListSize = (*env)->GetArrayLength(env, jPathList);
            if (jPathListSize == 0) {
                ret = 0;
                goto done;
            }
            ...
            if (ret) {
                hdfsFreeFileInfo(pathList, jPathListSize);
                errno = ret;
                return NULL;
            }
            *numEntries = jPathListSize;
            return pathList;
        
        

      Either change the implementation to match the doc, or fix the doc to match the implementation.

      Attachments

        1. HDFS-8407.003.patch
          5 kB
          Masatake Iwasaki
        2. HDFS-8407.002.patch
          4 kB
          Masatake Iwasaki
        3. HDFS-8407.001.patch
          2 kB
          Masatake Iwasaki

        Activity

          People

            iwasakims Masatake Iwasaki
            jyu@cloudera.com Juan Yu
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: