JDK-8162989 : jshell tool: /edit with external editor leaks files in /tmp
  • Type: Bug
  • Component: tools
  • Sub-Component: jshell
  • Affected Version: 9
  • Priority: P4
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2016-08-02
  • Updated: 2017-12-15
  • Resolved: 2017-12-12
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 10
10 b36Fixed
Related Reports
Duplicate :  
Relates :  
Description
Was: langtools/test/jdk/jshell/ToolRetainTest.java leaks files in /tmp

langtools/test/jdk/jshell/ToolRetainTest.java leaks files in /tmp.

If the files are being written by jshell, they should be cleaned up.

If the files are being written by the test itself, it would be more appropriate to use the jtreg scratch directory (i.e. current directory, when test is running.)

See attached script for running tests one at a time and checking for jshell files in /tmp.
Comments
Out for review 12/07/07 -- Please review... Bug: https://bugs.openjdk.java.net/browse/JDK-8162989 Webrev: http://cr.openjdk.java.net/~rfield/8162989v0.webrev/ Thanks, Robert
11-12-2017

That being said, it would think it is better to avoid using Files.createTempDirectory, and to then use the favor of createTempFile that creates files directly in the default temporary directory, and to explicitly delete the file when it is no longer required. public static Path createTempFile(String prefix, String suffix, FileAttribute<?>... attrs) throws IOException -- Jon
09-08-2016

According to source code of JShell, a new temp file is created in ExternalEditor when a code snippet is modified. jdk.internal.jshell.tool.ExternalEditor.java: method setupWatch: this.dir = Files.createTempDirectory("jshelltemp"); this.tmpfile = Files.createTempFile(dir, null, ".edit"); The created file is not removed. I reproduced the problem with vim: int h = 10; /set editor vim /edit h A file is created in tmp if /edit is executed. Best regards, Andrei Eremeev
09-08-2016

tmp files are created by jshell tool editor. Could be cleaned-up on exit.
08-08-2016

Extract of output from script: langtools/test/jdk/jshell/ToolLocaleMessageTest.java Test results: passed: 1 Report written to /w/jjg/work/dev/play/tmpfiles/report/html/report.html Results written to /w/jjg/work/dev/play/tmpfiles/work langtools/test/jdk/jshell/ToolRetainTest.java Test results: passed: 1 Report written to /w/jjg/work/dev/play/tmpfiles/report/html/report.html Results written to /w/jjg/work/dev/play/tmpfiles/work /tmp/jshelltemp606626845088632216: 4322790051119268639.edit /tmp/jshelltemp8153155933308410965: 4588940091270380714.edit langtools/test/jdk/jshell/IllegalArgumentExceptionTest.java Test results: passed: 1 Report written to /w/jjg/work/dev/play/tmpfiles/report/html/report.html Results written to /w/jjg/work/dev/play/tmpfiles/work langtools/test/jdk/jshell/StartOptionTest.java Test results: passed: 1 Report written to /w/jjg/work/dev/play/tmpfiles/report/html/report.html Results written to /w/jjg/work/dev/play/tmpfiles/work
02-08-2016