mojira.dev
MC-224349

Attempting to save multiple debug profiles during the same second fails to properly save all but the first profile

The bug

Attempting to save multiple debug profiles during the same second fails to properly save more than one profile. Instead, some are left as a .tmp file, like 2021-04-27_18.28.10.tmp.

The following error is logged when attempting to save the second profile.

Caught exception in thread Thread[IO-Worker-128,5,main]
java.io.UncheckedIOException: java.nio.file.FileAlreadyExistsException: debug/profiling/2021-04-27_18.28.10.zip
	at eln.a(SourceFile:129)
	at eln.a(SourceFile:69)
	at ele.i(SourceFile:210)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)
Caused by: java.nio.file.FileAlreadyExistsException: debug/profiling/2021-04-27_18.28.10.zip
	at sun.nio.fs.UnixCopyFile.move(UnixCopyFile.java:429)
	at sun.nio.fs.UnixFileSystemProvider.move(UnixFileSystemProvider.java:262)
	at java.nio.file.Files.move(Files.java:1395)
	at eln.a(SourceFile:127)
	... 5 more

Additionally, when trying to save three or more profiles in the same second, the following error appears, for every individual file that would be generated within the profile.

Could not save profiler results to /profiling.txt
java.nio.file.FileAlreadyExistsException: profiling.txt
	at com.sun.nio.zipfs.ZipFileSystem.newOutputStream(ZipFileSystem.java:516)
	at com.sun.nio.zipfs.ZipPath.newOutputStream(ZipPath.java:790)
	at com.sun.nio.zipfs.ZipFileSystemProvider.newOutputStream(ZipFileSystemProvider.java:285)
	at java.nio.file.Files.newOutputStream(Files.java:216)
	at java.nio.file.Files.newBufferedWriter(Files.java:2860)
	at api.a(SourceFile:164)
	at eln.a(SourceFile:122)
	at eln.a(SourceFile:65)
	at ele.i(SourceFile:210)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
	at java.lang.Thread.run(Thread.java:745)

How to reproduce

  1. Hold down the F3 and L keys for a few seconds (you should see "Profiling started" in chat multiple times)

  2. Check the game log
    ❌ The errors mentioned above are shown

  3. Check the debug/profiling folder
    ❌ Some .tmp files remain

Comments 2

This is (probably) caused by the fact that multiple debug profiles are trying to be saved under the same name. This can be fixed by appending a number to the end of the file name, like how screenshots are stored.

This seems to have been fixed in 1.17 Prerelease 1.

[Mod] markderickson

(Unassigned)

Confirmed

Low

Debug

21w16a, 21w17a, 21w20a

1.17 Pre-release 1

Retrieved