-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Runtime init the cleaner instance in ResourceCleaner #31452
Conversation
Thanks for your pull request! The title of your pull request does not follow our editorial rules. Could you have a look?
|
f4454a7
to
6ecf3ca
Compare
Mandrel workflow with this is running here: https://github.com/graalvm/mandrel/actions/runs/4285051293 |
6ecf3ca
to
3267400
Compare
It should probably be in the resteasy-common extension rather than resteasy-client as I had it before. |
@zakkak Please take a look when you get a chance! Thanks. |
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, but did you try just reinitializing the class instead?
...ntime/src/main/java/io/quarkus/resteasy/common/runtime/graal/ResourceCleanerReplacement.java
Outdated
Show resolved
Hide resolved
3267400
to
b9d8f4f
Compare
I did not. Then again, wouldn't for runtime-reinited classes the same restrictions apply (instances of those classes are disallowed in the image heap)? I'll have a look and will report back. |
No, fields of reinited classes are treated differently. The issue with instances of certain classes being present in the native heap is that those instances were generated at build time and they are thus not valid at runtime. When reiniting a class the said fields are "uninitialized" in the initial native heap and get initialized at run time which is valid. |
I thought this is for runtime initialized classes. Runtime re-inited classes are initialized both at build time and again at runtime: Anyway, in this case both seem to work. Runtime-reinit: Shall I update this patch with the last (runtime-init) option? |
Correct, they are initialized at build time for the build to proceed and to increase the level of optimization, but the values from the static fields are not used at runtime (if I am not mistaken they are not even placed in the generated native heap), instead they get re-initialized at run time. Because of this they are allowed to be present in the heap.
I didn't suggest pure runtime initialization because I thought the class needed to be build-time initialized. Great that you tried both.
Yes, please. |
@jerboaa I suggest doing the runtime initialization registration in https://github.com/quarkusio/quarkus/blob/main/extensions/resteasy-classic/resteasy-common/deployment/src/main/java/io/quarkus/resteasy/common/deployment/ResteasyCommonProcessor.java instead of creating a new class. |
b9d8f4f
to
a42ae92
Compare
@zakkak Done now. Thanks for the reviews. I've also rescheduled a run of the mandrel tests with this: |
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, thanks!
ResourceCleaner contains a static reference to a java.lang.ref.Cleaner instance which are disallowed in the native image heap. Runtime initializing that class instead fixes this issue. Closes: quarkusio#31440
a42ae92
to
37b5375
Compare
@gsmet Hi! Could you please help approving the workflow and getting this integrated? It fixes many broken integration tests on the mandrel CI side. Thanks! |
@zakkak just to be sure, you have the permission to approve a workflow run, right? Wondering if it's only admins. |
Yes, I was the one who approved it this morning. I am also going to merge this once the CI completes. @jerboaa was probably not aware that I have the power to do both :) Probably it didn't help that I didn't notice that the workflow was blocked for some unknown (since this is not the first contribution of @jerboaa) reason. |
Failing Jobs - Building 37b5375
Full information is available in the Build summary check run. Failures⚙️ Devtools Tests - JDK 17 #- Failing: integration-tests/devtools
📦 integration-tests/devtools✖
|
The failure is unrelated to the PR. Merging it. |
Marking this for backport since although the Cleaner instances were disallowed only recently the issue is actually present in older versions as well. Not sure if it's worth backporting to 2.7 as well. |
Actually, AFAICS, |
Indeed, the ResourceCleaner was added in 6.1.0.Final and 2.16 is using 4.7.7. |
org.jboss.resteasy.spi.ResourceCleaner needs to be runtime initialized both in resteasy-classic and resteasy-reactive. Follow-up to quarkusio#31452
Inject an accessor for the ResourceCleaner.CLEANER static variable so that the associated cleaner won't get initialized at build time and ends up being in the native image heap.
Closes: #31440