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
8269886: Inaccurate error message for compressed hprof test #4685
Conversation
|
@linzang The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
The existing message is a generic message covering the general operation of the whole try block. It seems far more appropriate than your new message, which only seems to apply to the final step. ??? David |
Hi David,
IMO, the whole method named getStack() is used to get the stack trace for the hprof file. And the try block could throw exceptions by serveral reasons as decribed, so IMHO printing "Can not decompress the compressed hprof file" is not accurate. The proposed change is to print a generic error message that the getStack() fail when processing compressed hprof. And the extra 'e' argument in the changed line would give detailed reason. So may be change error message to "Can not process the compressed hprof file" is better? what do you think? BRs, |
Hi @dholmes-ora, BRs, |
These changes are fine in themselves.
This code is not very well written though - the file streams do not get closed and the decompressed output file doesn't seem to get deleted when I would expect.
Thanks,
David
@linzang 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 54 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@dholmes-ora, @plummercj) but any other Committer may sponsor as well.
|
Hi David,
Agree. I will create a seperate issue to fix it. BRs, |
/integrate |
You need 2 reviews. Please don't integrate yet. I'll provide more comments shortly. |
After decompressing, no error or exception is thrown if MAGIC_NUMBER is not found. It just silently fails to print the stack trace. Please use "cannot" instead of "can not". Both are grammatically correct, but "cannot" is what is normally used. |
Also remove unreachable code after exception is added.
Hi @plummercj , Thanks for reviewing, I have updated the PR based on your comments, and remove unreachable code introduced by the updated code. BRs, |
Either deleting the out file needs to be handled correctly in all cases or it should left as-is and fixed in a different RFE that also handles stream closing *try-with-resources?) etc. to clean up the code.
Otherwise the actual try/catch changes seem okay.
Thanks,
David
Hi @dholmes-ora
I have created an issue in JBS (https://bugs.openjdk.java.net/browse/JDK-8269909) to use the try-with-resource for stream closing, and will submit a PR shortly. For out.delete(), I prefer to fix it in this PR as the introduction of throwing exception in my last update makes the original out.delete() unreachable, so I have to add logic to handle it. I will update this PR with a finally block in a minute. Thanks, |
I would have added a single try/finally block that encompasses all the code after:
File out = new File(deCompressedFile);
but what you have also does the job.
Thanks,
David
There is still an inconsistency exception handling. For the outer bad MAGIC_NUMBER handling you have: 186 throw new IOException("Unrecognized magic number: " + i); But the decompressed handling results in: 178 throw new IOException("Unrecognized magic number of decompressed data: " + i); Which is caught and wrapped by: 181 throw new IOException("Cannot get stack trace from the compressed hprof file", e); Also, nothing is wrapping exceptions thrown by the following code: 143 HprofReader r But any exception thrown by the following code is wrapped and rethrown at line 181: 172 HprofReader r |
Hi @plummercj, |
Hi @plummercj, BRs, |
I will mark this PR with integrate. BRs, |
/integrate |
/sponsor |
Going to push as commit 4fbcce1.
Your commit was automatically rebased without conflicts. |
@dholmes-ora @linzang Pushed as commit 4fbcce1. |
Mailing list message from David Holmes on hotspot-runtime-dev: Hi Lin, On 6/07/2021 1:33 pm, Lin Zang wrote:
Yes that seems a good middle ground. Alternatively, but more effort, have different try/catch blocks for the Thanks, |
1 similar comment
Mailing list message from David Holmes on hotspot-runtime-dev: Hi Lin, On 6/07/2021 1:33 pm, Lin Zang wrote:
Yes that seems a good middle ground. Alternatively, but more effort, have different try/catch blocks for the Thanks, |
The current implementation of hprof Reader for testing always prompts "Can not decompress the compressed hprof file" when there is error for testing gzipped heap dump. This is inaccurate if the gzipped file was decompressed successfully but the hprof file format is incorrect. So the inaccurate error message could be misleading for issue analysis.
This trivial PR refine the error message by simply print "Can not get stack trace from the compressed hprof file", the underlying exception from GZIPInputStream() or HprofReader() would give accurate error info.
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.java.net/jdk pull/4685/head:pull/4685
$ git checkout pull/4685
Update a local copy of the PR:
$ git checkout pull/4685
$ git pull https://git.openjdk.java.net/jdk pull/4685/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 4685
View PR using the GUI difftool:
$ git pr show -t 4685
Using diff file
Download this PR as a diff file:
https://git.openjdk.java.net/jdk/pull/4685.diff