8302685: Some javac unit tests aren't reliably closing open files

Reviewed-by: darcy, vromero
This commit is contained in:
Archie L. Cobbs 2023-02-27 16:21:57 +00:00 committed by Vicente Romero
parent f5a12768fb
commit 55e6bb6b85
58 changed files with 240 additions and 391 deletions

View file

@ -429,11 +429,8 @@ class Example implements Comparable<Example> {
*/
private String read(File f) throws IOException {
byte[] bytes = new byte[(int) f.length()];
DataInputStream in = new DataInputStream(new FileInputStream(f));
try {
try (DataInputStream in = new DataInputStream(new FileInputStream(f))) {
in.readFully(bytes);
} finally {
in.close();
}
return new String(bytes);
}