TemporaryFolder default name generation inconsistent
See original GitHub issueTemporaryFolder relies on java.io.File$TempDirectory.
The generateFile method uses SecureRandom to generate a long to ascribe to the file name.
This can cause varying lengths of temporary folder name.
filePath: /tmp/junit2375994787548427572/test.txt
--> long is 19 chars
filePath: /tmp/junit3617134405501405307/test.txt
--> long is 19 chars again
filePath: /tmp/junit343221902873074958/test.txt
--> long is 18 chars
This was discovered during serialisation of path names and byte length checks in tests causing intermittent issues.
A switch to using a UUID.randomUuid() and actually implementing temp folder creation in junit might be a way to fix this (I don’t see an api on java.io.File which allows passing the random part of the filename).
junit: 4.12 os: ubuntu 20.04
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (4 by maintainers)
Top GitHub Comments
I also don’t see this as a compelling reason to revisit that decision.
TemporaryFolder
used to have its own implementation for creating the directory. We intentionally moved away from that in the recent release of JUnit. I’m not sure this is a compelling reason to revisit that decision.