New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8265465: jcmd VM.cds should keep already dumped archive when exception happens #3886
Conversation
|
Webrevs
|
fileArchive.delete(); | ||
} | ||
String tempFileName = getArchiveFileName(archiveFileName); | ||
File tempArchiveFile = new File(tempFileName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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";
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about:
File tempArchiveFile = new File(tempArchiveFileName);
tempArchiveFile.createNewFile(); // will throw exception if we cannot write to the directory.
tempArchiveFile.delete();
|
||
public static void main(String... args) throws Exception { | ||
if (Platform.isWindows()) { | ||
// ON windows, File operation resulted difference from other OS. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you explain what the differences are?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will add detail explanation.
* @build JCmdTestLingeredApp JCmdTestFileSecurity | ||
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox | ||
* @run main/othervm/timeout=480 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI JCmdTestFileSecurity | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Security" is usually used for Java language security. I think it's better to call this test JCmdTestFileSafety.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure.
String localFileName = "MyStaticDump.jsa"; | ||
test(localFileName, pid, noBoot, EXPECT_PASS); | ||
File targetFile = CDSTestUtils.getOutputDirAsFile(); | ||
targetFile.setWritable(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
getOutputDirAsFile returns the current directory. Other test code may write to this directory. I think it's better to specify:
localFileName = "subdir" + File.separator() + "MyStaticDump.jsa";
and set subdir
to be non-writeable.
Also, the local variable should be targetDir
instead of targetFile
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will try this, not sure if the subdir and the file can be created with current code. May be some extra code needed.
Thanks for the review!
// Set target dir not writable, do dynamic dump | ||
print2ln(test_count++ + " Set target dir not writable, do dynamic dump"); | ||
setKeepArchive(true); | ||
outputDirFile.setWritable(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the comment be // Set target dir writable ...
? (since you're setting the dir to writable at line 78)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment is for the testing item --- that is consistent with println contents.
The first set 'true' is for get the archive and keep the archive, the real test is after set it to 'false', the test will fail and we check the previous archive still available.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see.
// cannot dynamically dump twice, restart | ||
app = createLingeredApp("-cp", allJars, "-XX:+RecordDynamicDumpInfo"); | ||
pid = app.getPid(); | ||
outputDirFile.setWritable(false); | ||
test(localFileName, pid, noBoot, EXPECT_FAIL); | ||
outputDirFile.setWritable(true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would the test fail without setting the dir not writable at line 87?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See reply above.
/integrate |
@iklam @calvinccheung Thanks for review! |
@yminqi This PR has not yet been marked as ready for integration. |
/label remove core-libs |
@yminqi |
@yminqi This change now passes all automated pre-integration checks. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 24 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details.
|
/integrate |
@yminqi Since your change was applied there have been 24 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 43ad24f. |
Hi, Please review
When using jcmd to dump shared archive, if the archive name exists, it will be deleted first. If exception happens during dumping process, there is no new archive created. This PR changes to first dump the archive with a temporary file name. With successful dump, the temporary file will be rename to its given name. This way the old archive will not be touched on exception.
The newly added test case skipped testing on Windows since File operation result is not same as on Linux.
Tests: tier1,tier2,tier3,tier4
Thanks
Yumin
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/3886/head:pull/3886
$ git checkout pull/3886
Update a local copy of the PR:
$ git checkout pull/3886
$ git pull https://git.openjdk.java.net/jdk pull/3886/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 3886
View PR using the GUI difftool:
$ git pr show -t 3886
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/3886.diff