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: core-libs
    • Labels:
      None

      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.

          Attachments

            Issue Links

              Activity

                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: