RFR: 8265465: jcmd VM.cds should keep already dumped archive when exceptions happens [v2]
Ioi Lam
iklam at openjdk.java.net
Wed May 5 19:27:52 UTC 2021
On Wed, 5 May 2021 18:42:20 GMT, Yumin Qi <minqi at openjdk.org> wrote:
>> src/java.base/share/classes/jdk/internal/misc/CDS.java line 284:
>>
>>> 282:
>>> 283: String tempFileName = getArchiveFileName(archiveFileName);
>>> 284: File tempArchiveFile = new File(tempFileName);
>>
>> I think the logic is too complicated. We can always write the archive to a temp file, and then rename it to the actual file. Also, to be consistent with the other variables, it should be `tempArchiveFileName`
>>
>>
>> String tempArchiveFileName = archiveFileName + ".tmp";
>
> getArchiveFileName also operates on create/delete temp file, so if that fails, throw exception back to caller. Do you think the logic should be kept?
How about:
File tempArchiveFile = new File(tempArchiveFileName);
tempArchiveFile.createNewFile(); // will throw exception if we cannot write to the directory.
tempArchiveFile.delete();
-------------
PR: https://git.openjdk.java.net/jdk/pull/3886
More information about the core-libs-dev
mailing list