JShell runFile does not properly close the Scanner
Michal Vala
mvala at redhat.com
Thu Apr 26 13:32:46 UTC 2018
Hi,
while I've been playing with opening url in jshell, I've noticed that Scanner
that goes into run(...) at JShellTool#runFile(...) is not properly closed. See
following patch:
diff -r 4745598b307f
src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
--- a/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
Thu Apr 26 11:56:24 2018 +0200
+++ b/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java
Thu Apr 26 15:27:13 2018 +0200
@@ -3005,7 +3005,9 @@
: new FileReader(path.toString())
);
}
- run(new ScannerIOContext(scanner));
+ try (var scannerIOContext = new ScannerIOContext(scanner)) {
+ run(scannerIOContext);
+ }
return true;
} catch (FileNotFoundException e) {
errormsg("jshell.err.file.not.found", context, filename,
e.getMessage());
thoughts?
--
Michal Vala
OpenJDK QE
Red Hat Czech
More information about the kulla-dev
mailing list