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

Output streams closed with IOUtils suppressing write errors

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • None
    • 3.1.0, 2.10.0, 2.9.1, 3.0.1, 2.8.4, 2.7.6
    • None
    • None
    • Reviewed

    Description

      There are a few places in HDFS code that are closing an output stream with IOUtils.cleanupWithLogger like this:

        try {
          ...write to outStream...
        } finally {
          IOUtils.cleanupWithLogger(LOG, outStream);
        }
      

      This suppresses any IOException that occurs during the close() method which could lead to partial/corrupted output without throwing a corresponding exception. The code should either use try-with-resources or explicitly close the stream within the try block so the exception thrown during close() is properly propagated as exceptions during write operations are.

      Attachments

        1. HDFS-12881.001.patch
          43 kB
          Ajay Kumar
        2. HDFS-12881.002.patch
          10 kB
          Ajay Kumar
        3. HDFS-12881.003.patch
          12 kB
          Ajay Kumar
        4. HDFS-12881.004.patch
          3 kB
          Ajay Kumar
        5. HDFS-12881-branch-2.10.0.001.patch
          3 kB
          Ajay Kumar

        Issue Links

          Activity

            People

              ajayydv Ajay Kumar
              jlowe Jason Darrell Lowe
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: