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

Test config creation sometimes delegates to instance variable and sometimes to superclass, causing (v v minor) chaos #45652

Merged

Conversation

holly-cummins
Copy link
Contributor

@holly-cummins holly-cummins commented Jan 16, 2025

I just spent a while wondering if I was losing my mind, until the debugger helped me out.

I was staring at code in the TestConfigProviderResolver that did this:

                resolver.releaseConfig(classLoader);
                resolver.registerConfig(config, classLoader);

... and it was failing because the config hadn't been released. "How can it not be released? I can see the release call one line above the failing call, and there's no concurrency here!" I wailed.

Working through the problem in a debugger, I realised that the release and register call were being applied to different objects. At this point, I was hollering at the computer "What? how they be different objects? They're the same object, I can see it right there!"

The wrinkle in this case, is that TestConfigProviderResolver both extends from another resolver, and holds an instance of it as an instance variable. The superclass and instance variable are not at all guaranteed to be the same object. In this case, one method was going to the superclass, and one was going to the instance variable. I could only spot that by staring at screencaps of the debugger on the release and register calls.

It would be nice if TestConfigProviderResolver could implement an interface instead, since that avoids this kind of risk, but I assume that's not possible.

Copy link

quarkus-bot bot commented Jan 16, 2025

Thanks for your pull request!

Your pull request does not follow our editorial rules. Could you have a look?

  • title should not end up with ellipsis (make sure the title is complete)

This message is automatically generated by a bot.

@holly-cummins holly-cummins changed the title Make sure to delegate to instance variable for releasing config of a … Correct superclass - instance variable mismatch on test config delegation Jan 16, 2025

This comment has been minimized.

@holly-cummins holly-cummins force-pushed the fix-object-mismatch-in-test-config branch from 64a1cc4 to c1c3bdf Compare January 16, 2025 15:39
@holly-cummins holly-cummins changed the title Correct superclass - instance variable mismatch on test config delegation Test config sometimes delegates to instance variable and sometimes to superclass, causing (v minor) chaos Jan 16, 2025
@holly-cummins holly-cummins changed the title Test config sometimes delegates to instance variable and sometimes to superclass, causing (v minor) chaos Test config sometimes delegates to instance variable and sometimes to superclass, causing (v v minor) chaos Jan 16, 2025
@holly-cummins holly-cummins changed the title Test config sometimes delegates to instance variable and sometimes to superclass, causing (v v minor) chaos Test config creation sometimes delegates to instance variable and sometimes to superclass, causing (v v minor) chaos Jan 16, 2025
Copy link

quarkus-bot bot commented Jan 16, 2025

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit c1c3bdf.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@gsmet gsmet merged commit 4ef1702 into quarkusio:main Jan 17, 2025
52 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.19 - main milestone Jan 17, 2025
@gsmet
Copy link
Member

gsmet commented Jan 17, 2025

Let's backport to 3.18.

And yes I would be in favor of having an interface and a delegation model.

@radcortez
Copy link
Member

Yes, the problem here is that I needed specific methods from SmallRyeConfigProviderResolver, but these are not available in the MP Config interface ConfigProviderResolver, so to move forward I did it that way :)

I'll improve it.

@holly-cummins
Copy link
Contributor Author

I agree we should backport, since the change is (a) obviously correct and (b) low-risk. But I also think this is a very latent defect; as far as I know, we weren't seeing any symptoms until I started pushing the test classloading down new paths.

Probably the next time the current design would cause problems is if a new method gets added to the superclass and we don't remember to update the subclass. That's a risk, but not an immediate one. Improvement would be good, but I'd say it's definitely not the highest priority.

@holly-cummins holly-cummins deleted the fix-object-mismatch-in-test-config branch January 17, 2025 11:19
@gsmet gsmet modified the milestones: 3.19 - main, 3.18.0 Jan 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

Successfully merging this pull request may close these issues.

3 participants