Skip to content
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

7945: Avoid throwing NoSuchFieldException in ValueReaders$ReflectiveReader #447

Conversation

richardstartin
Copy link
Contributor

@richardstartin richardstartin commented Oct 25, 2022

When using jmc-common in a backend process we throw the following swallowed exception millions of times a day:

java.lang.NoSuchFieldException: package
	at java.base/java.lang.Class.getField(Class.java:2149)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.ValueReaders$ReflectiveReader.addField(ValueReaders.java:593)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager$TypeEntry.getReader(TypeManager.java:200)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.createFieldReader(TypeManager.java:493)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.access$000(TypeManager.java:86)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager$TypeEntry.getReader(TypeManager.java:198)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.createFieldReader(TypeManager.java:493)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.access$000(TypeManager.java:86)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager$TypeEntry.getReader(TypeManager.java:198)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.createFieldReader(TypeManager.java:493)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.access$000(TypeManager.java:86)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager$TypeEntry.getReader(TypeManager.java:198)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.createFieldReader(TypeManager.java:493)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.access$000(TypeManager.java:86)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager$EventTypeEntry.init(TypeManager.java:357)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.TypeManager.<init>(TypeManager.java:432)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.ChunkLoaderV1.call(ChunkLoaderV1.java:70)
	at org.openjdk.jmc.flightrecorder.internal.parser.v1.ChunkLoaderV1.call(ChunkLoaderV1.java:48)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
	at java.base/java.lang.Thread.run(Thread.java:833)

This adds a simple memoization to store the identifier to field mapping, with size bounded by the number of classes used in JFR events.


Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Error

 ⚠️ The pull request body must not be empty.

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jmc pull/447/head:pull/447
$ git checkout pull/447

Update a local copy of the PR:
$ git checkout pull/447
$ git pull https://git.openjdk.org/jmc pull/447/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 447

View PR using the GUI difftool:
$ git pr show -t 447

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jmc/pull/447.diff


Progress

  • Commit message must refer to an issue
  • Change must be properly reviewed (1 review required, with at least 1 Committer)

Issue

  • JMC-7945: Avoid throwing NoSuchFieldException in ValueReaders$ReflectiveReader

Reviewers

Reviewing

Using git

Checkout this PR locally:
$ git fetch https://git.openjdk.org/jmc pull/447/head:pull/447
$ git checkout pull/447

Update a local copy of the PR:
$ git checkout pull/447
$ git pull https://git.openjdk.org/jmc pull/447/head

Using Skara CLI tools

Checkout this PR locally:
$ git pr checkout 447

View PR using the GUI difftool:
$ git pr show -t 447

Using diff file

Download this PR as a diff file:
https://git.openjdk.org/jmc/pull/447.diff

@bridgekeeper
Copy link

bridgekeeper bot commented Oct 25, 2022

👋 Welcome back richardstartin! A progress list of the required criteria for merging this PR into master will be added to the body of your pull request. There are additional pull request commands available for use with this pull request.

@richardstartin richardstartin force-pushed the reflectivereader-field-cache branch 2 times, most recently from ea69f20 to ffa356d Compare October 25, 2022 09:03
@richardstartin richardstartin changed the title ReflectiveReader field cache 7945: Avoid throwing NoSuchFieldException in ValueReaders$ReflectiveReader Oct 25, 2022
@richardstartin richardstartin marked this pull request as ready for review October 25, 2022 09:08
@openjdk openjdk bot added the rfr label Oct 25, 2022
@mlbridge
Copy link

mlbridge bot commented Oct 25, 2022

Webrevs

@openjdk
Copy link

openjdk bot commented Oct 25, 2022

@richardstartin 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:

7945: Avoid throwing NoSuchFieldException in ValueReaders$ReflectiveReader

Reviewed-by: hirt, jbachorik

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 1 new commit pushed to the master branch:

  • bd35870: 7861: Bump Agent build to Java 11 compliance and cleanup POM

Please see this link for an up-to-date comparison between the source branch of this pull request and the master branch.
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 (@thegreystone) but any other Committer may sponsor as well.

➡️ To flag this PR as ready for integration with the above commit message, type /integrate in a new comment. (Afterwards, your sponsor types /sponsor in a new comment to perform the integration).

@openjdk openjdk bot added the ready label Oct 25, 2022
@richardstartin
Copy link
Contributor Author

rebased and updated copyright year

@richardstartin
Copy link
Contributor Author

/integrate

@openjdk openjdk bot added the sponsor label Oct 26, 2022
@openjdk
Copy link

openjdk bot commented Oct 26, 2022

@richardstartin
Your change (at version 2ce24b1) is now ready to be sponsored by a Committer.

@thegreystone
Copy link
Member

/sponsor

@openjdk
Copy link

openjdk bot commented Oct 26, 2022

Going to push as commit a4ee558.
Since your change was applied there has been 1 commit pushed to the master branch:

  • bd35870: 7861: Bump Agent build to Java 11 compliance and cleanup POM

Your commit was automatically rebased without conflicts.

@openjdk
Copy link

openjdk bot commented Oct 26, 2022

@thegreystone @richardstartin Pushed as commit a4ee558.

💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

3 participants