A file is marked with deleteOnExit, which keeps its name in memory until the JVM stops

tx0/java:exit-time-deletionrecommendedwarningsmell

What it finds

file.deleteOnExit() remembers the path until the virtual machine shuts down, and there is no way to forget it again; in a server that runs for months, every call adds to a list that only grows, and the files stay on disk if the JVM crashes. Deleting the file when it is no longer needed avoids both.

Reported is a call of deleteOnExit().

From the rule's source, delete_on_exit.rs.

Example from the rule's tests
import java.io.File; class Temp {  void mark(File file) {    file.deleteOnExit();tx0 reports: keeps the path in memory  }}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs from the recommended tier up. To turn it on in a lower tier, give it a level in tx0.toml:

tx0.toml
[rules]
"tx0/java:exit-time-deletion" = "warning"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:exit-time-deletion] reason="..."

tx0 explain tx0/java:exit-time-deletion shows the same in the terminal. Found a false positive? Report it.