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
8261160: Add a deserialization JFR event #2479
Conversation
👋 Welcome back chegar! A progress list of the required criteria for merging this PR into |
/contributor add @coffeys |
@ChrisHegarty 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. |
@ChrisHegarty |
/contributor add @ChrisHegarty |
@ChrisHegarty |
Webrevs
|
The logging in ObjectInputStream remains conditional on whether a filter is installed, which that seems reasonable since the logging is filter specific, while the JRF event is not (but both carry effectively the same information). The new jdk.Deserialization event uses a String to carry the filterStatus value. The value could be represented by its enum ordinal, but then the tool consuming the event would need to map that back to its string value to be meaningful. |
@@ -48,6 +48,7 @@ | |||
* -Dexpected-jdk.serialFilter=java.** GlobalFilterTest | |||
* @run testng/othervm/policy=security.policy GlobalFilterTest | |||
* @run testng/othervm/policy=security.policy |
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.
You may want to add a "@requires vm.hasJFR" condition to this test
@ChrisHegarty This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. 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 353 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. ➡️ To integrate this PR with the above commit message to the |
import jdk.jfr.internal.MirrorEvent; | ||
|
||
@Category({"Java Development Kit", "Serialization"}) | ||
@Label("Deserialization events") |
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.
This seems to differ from the format of other event labels defined in this package, e.g:
@Label("Process Start")
@Label("File Read")
...
What would you think of changing it to one of:
@Label("Deserialization")
@Label("Deserialized Object")
} | ||
DeserializationEvent event = new DeserializationEvent(); | ||
if (event.shouldCommit()) { | ||
event.filterStatus = status == null ? "n/a" : status.name(); |
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.
We use null for missing value, so no need to have "n/a"
event.totalObjectRefs = totalObjectRefs; | ||
event.depth = depth; | ||
event.bytesRead = bytesRead; | ||
event.exception = Objects.toString(ex, "n/a"); |
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.
You may want to change the name of the field to "exceptionMessage" to make it clear it's the message, not the class.
public String filterStatus; | ||
|
||
@Label ("Class") | ||
public String clazz; |
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.
We typically use "type" when referring to a class (instead of clazz), or we prefix it, i.e exceptionClass
public String filterStatus; | ||
|
||
@Label ("Class") | ||
public String clazz; |
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.
Is it possible to make the field of type Class?
public int arrayLength; | ||
|
||
@Label ("Reference count") | ||
public long totalObjectRefs; |
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.
"Reference count" sounds a bit like resource counter? Is that the case? If not, perhaps "Object References" is better. We try to avoid abbreviations. How about naming the field "totalObjectReferences" or just "objectReferences"?
As proposed, events are only created if there is a serialFilter in effect (and enabled by JFR configuration). |
I updated the PR and addressed all comments so far. Specifically: @RogerRiggs The generation of the event is independent of whether the filter is set or not. I also added a piece of state to determine if a filter is set or not. I think it could be useful to analyse all Deserialisation events to, say, ensure that there are none operating without a filter ( and the @coffeys I would like GlobalFilterTest to run regardless of whether or not the jfr module is present, but of course running the test with jfr enabled is desirable too, so I added a separate at test tag for that case. @egahlin Excellent suggestions on the naming, etc. I adopted all. And added a test to ensure that the creation and generation of the event does not inadvertently trigger class initialization if the filter rejects the attempt ( thanks @dfuch ) @dfuch Thanks for the improved label suggestion, it is now merged in. |
@Label("Filter configured") | ||
public boolean filterConfigured; |
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 that be "Filter Configured" for consistency?
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.
Good catch. Fixed.
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.
LGTM
Speaking to Erik offline, he suggested to split the |
/integrate |
@ChrisHegarty Since your change was applied there have been 355 commits pushed to the
Your commit was automatically rebased without conflicts. Pushed as commit 3dc6f52. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
This issue adds a new event to improve diagnostic information of Java deserialization. The event captures the details of deserialization activity from ObjectInputStream. The event details are similar to that of the serial filter, but is agnostic of whether a filter is installed or not. The event also captures the filter status, if there is one.
Progress
Issue
Reviewers
Contributors
<coffeys@openjdk.org>
<chegar@openjdk.org>
Download
$ git fetch https://git.openjdk.java.net/jdk pull/2479/head:pull/2479
$ git checkout pull/2479