Hadoop Common
  1. Hadoop Common
  2. HADOOP-10364

JsonGenerator in Configuration#dumpConfiguration() is not closed

    Details

    • Type: Bug Bug
    • Status: Patch Available
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: conf
    • Labels:
      None

      Description

          JsonGenerator dumpGenerator = dumpFactory.createJsonGenerator(out);
      

      dumpGenerator is not closed in Configuration#dumpConfiguration()

      Looking at the source code of org.codehaus.jackson.impl.WriterBasedGenerator#close(), there is more than flushing the buffer.

      1. HADOOP-10364.2.patch
        3 kB
        Sanghyun Yun
      2. HADOOP-10364.patch
        0.6 kB
        Sanghyun Yun

        Activity

        Ted Yu created issue -
        Ted Yu made changes -
        Field Original Value New Value
        Component/s conf [ 12310711 ]
        Hide
        Sanghyun Yun added a comment -

        I modify "flush()" at the end to "close()".
        close function will force flushing of output and close underlying output stream.

        Show
        Sanghyun Yun added a comment - I modify "flush()" at the end to "close()". close function will force flushing of output and close underlying output stream.
        Sanghyun Yun made changes -
        Attachment HADOOP-10364.patch [ 12662723 ]
        Sanghyun Yun made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Hide
        Tsuyoshi Ozawa added a comment -

        HI Sanghyun Yun, thanks for your contribution. To avoid a resource leak, we should add try {} finally {} block and close dumpGenerator in finally block.

        +    dumpGenerator.close();
        

        We should use IOUtils instead of using close() method directory, because close() can throw IOException and null check.

        Show
        Tsuyoshi Ozawa added a comment - HI Sanghyun Yun , thanks for your contribution. To avoid a resource leak, we should add try {} finally {} block and close dumpGenerator in finally block. + dumpGenerator.close(); We should use IOUtils instead of using close() method directory, because close() can throw IOException and null check.
        Hide
        Tsuyoshi Ozawa added a comment -

        s/directory/directly/

        Show
        Tsuyoshi Ozawa added a comment - s/directory/directly/
        Hide
        Sanghyun Yun added a comment -

        Tsuyoshi Ozawa Thanks for your review! I added try-finally block and modified code using IOUtils.cleanup() method.

        Show
        Sanghyun Yun added a comment - Tsuyoshi Ozawa Thanks for your review! I added try-finally block and modified code using IOUtils.cleanup() method.
        Sanghyun Yun made changes -
        Attachment HADOOP-10364.2.patch [ 12665692 ]
        Hide
        Hadoop QA added a comment -

        -1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12665692/HADOOP-10364.2.patch
        against trunk revision 258c7d0.

        +1 @author. The patch does not contain any @author tags.

        -1 tests included. The patch doesn't appear to include any new or modified tests.
        Please justify why no new tests are needed for this patch.
        Also please list what manual steps were performed to verify this patch.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 javadoc. There were no new javadoc warning messages.

        +1 eclipse:eclipse. The patch built with eclipse:eclipse.

        +1 findbugs. The patch does not introduce any new Findbugs (version 2.0.3) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        -1 core tests. The test build failed in hadoop-common-project/hadoop-common

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/4615//testReport/
        Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/4615//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - -1 overall . Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12665692/HADOOP-10364.2.patch against trunk revision 258c7d0. +1 @author . The patch does not contain any @author tags. -1 tests included . The patch doesn't appear to include any new or modified tests. Please justify why no new tests are needed for this patch. Also please list what manual steps were performed to verify this patch. +1 javac . The applied patch does not increase the total number of javac compiler warnings. +1 javadoc . There were no new javadoc warning messages. +1 eclipse:eclipse . The patch built with eclipse:eclipse. +1 findbugs . The patch does not introduce any new Findbugs (version 2.0.3) warnings. +1 release audit . The applied patch does not increase the total number of release audit warnings. -1 core tests . The test build failed in hadoop-common-project/hadoop-common +1 contrib tests . The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/4615//testReport/ Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/4615//console This message is automatically generated.
        Hide
        Tsuyoshi Ozawa added a comment -

        It looks good to me(non-binding).

        Show
        Tsuyoshi Ozawa added a comment - It looks good to me(non-binding).
        Hide
        Sanghyun Yun added a comment -

        Thank you, Tsuyoshi Ozawa.

        Show
        Sanghyun Yun added a comment - Thank you, Tsuyoshi Ozawa .

          People

          • Assignee:
            Unassigned
            Reporter:
            Ted Yu
          • Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

            • Created:
              Updated:

              Development