JDK-8067964 : Native2ascii doesn't close one of the streams it opens
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio.charsets
  • Affected Version: 8,9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2014-12-19
  • Updated: 2017-05-04
  • Resolved: 2014-12-23
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 6 JDK 7 JDK 8 JDK 9
6u131Fixed 7u121Fixed 8u112Fixed 9 b45Fixed
Related Reports
Duplicate :  
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.


Comments
Review thread: http://mail.openjdk.java.net/pipermail/core-libs-dev/2014-December/030461.html
23-12-2014

The streams should always be closed. This is a minor cleanup issue.
23-12-2014