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

fix some misuses of InputStream#skip

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 2.0.0-alpha
    • None
    • namenode
    • None
    • Reviewed

    Description

      It seems that we have a few cases where programmers are calling InputStream#skip and not handling "short skips." Unfortunately, the skip method is documented and implemented so that it doesn't actually skip the requested number of bytes, but simply tries to skip at most that amount of bytes. A better name probably would have been trySkip or similar.

      It seems like most of the time when the argument to skip is small enough, we'll succeed almost all of the time. This is no doubt an implementation artifact of some of the popular stream implementations. This tends to hide the bug-- however, it is still waiting to emerge at some point if those implementations ever change or if buffer sizes are adjusted, etc.

      All of these cases can be fixed by calling IOUtils#skipFully to get the behavior that the programmer expects-- i.e., skipping by the specified amount.

      Attachments

        1. HDFS-3492.001.patch
          8 kB
          Colin McCabe
        2. HDFS-3492.002.patch
          8 kB
          Colin McCabe
        3. hdfs-3492.txt
          6 kB
          Eli Collins

        Issue Links

          Activity

            People

              cmccabe Colin McCabe
              cmccabe Colin McCabe
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: