Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067964

Native2ascii doesn't close one of the streams it opens

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Fixed
    • Affects Version/s: 8, 9
    • Fix Version/s: 9
    • Component/s: tools
    • Labels:
      None
    • Resolved In Build:
      b45

      Backports

        Description

        From the 1.8 open jdk sources:
        159 } else {
        160 //N2A
        161 String inLine;
        162 BufferedReader in = getN2AInput(inputFileName);
        163 BufferedWriter out = getN2AOutput(outputFileName);
        164
        165 while ((inLine = in.readLine()) != null) {
        166 out.write(inLine.toCharArray());
        167 out.write(lineBreak);
        168 if (outputFileName == null) { // flush stdout
        169 out.flush();
        170 }
        171 }
        172 out.close();
        173}

        Notice 'in' is never closed. This causes problems on NFS mounts where .nfsXXXX files are left behind.
        There is also no protection against exceptions, streams should be closed in finally blocks or by using try/resources.

          Issue Links

            Activity

            Hide
            chegar Chris Hegarty added a comment -
            The streams should always be closed. This is a minor cleanup issue.
            Show
            chegar Chris Hegarty added a comment - The streams should always be closed. This is a minor cleanup issue.
            Show
            bpb Brian Burkhalter added a comment - Review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-December/030461.html
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/a2b51b18ae9d
            User: bpb
            Date: 2014-12-23 20:40:56 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/dev/jdk/rev/a2b51b18ae9d User: bpb Date: 2014-12-23 20:40:56 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/a2b51b18ae9d
            User: lana
            Date: 2014-12-30 21:55:54 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/a2b51b18ae9d User: lana Date: 2014-12-30 21:55:54 +0000

              People

              • Assignee:
                bpb Brian Burkhalter
                Reporter:
                kbronkho Keimpe Bronkhorst
              • Votes:
                0 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: