-
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
Allow configuration of rest client default scope #2940
Conversation
Thanks @machi1990! I will take a look most likely tomorrow. Perhaps @michalszynkiewicz would also like to review it |
One comment, I think we should keep this to a single commit. |
Okay thanks @geoand . I still have a failing TCK, I thought opening a PR would help with figuring out why. |
FWIW, here is an example of how I was debugging tests when I ran things locally:
|
5c9e9fe
to
b7f99fb
Compare
@machi1990 do you need any help with this one? |
Hey @geoand, thanks. Sure. I am yet to figure out why the test are failing for Linux Build and passing for the other platforms. Also, I got one TCK for default scope passing and not the other. But the integration test I added for the cases are passing. Any ideas? |
I'll have to take a closer look later on today or tomorrow morning. If you find any fixes in the meantime, feel free to push :) |
@machi1990 seems like you are making progress, 👍 . However I am guessing that there is still some corner case not addressed since |
hey @geoand , thanks for checking my progress. Yes, I was able to take a look yesternight: had a day away from comp (was in conference). So here is what I am observing locally, only running the failing test (which I believe to be just
If I only run the two tests which were excluded before this PR, they work just fine as well:
However, If I run the same tests by adding
Thoughts? |
That's interesting for sure! I don't know enough about the tests to know what is going on, but what I would do is debug the tests (as described here) and try to figure out exactly what is happening. |
@@ -127,6 +112,27 @@ public boolean skipValidation(InjectionTargetInfo target, ValidationRule rule) { | |||
} | |||
} | |||
|
|||
private Collection<ClassInfo> collectTargetClass() { |
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.
Modified because to be able to create a default noArgConstructor
for AppScope
and RequestScope
once. Otherwise, TCK tests in HasRequestScopeTest
and HasAppScopeTest
were failing with a <cinit>
error.
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 would need validation from @mkouba on this one
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.
It wouldn't hurt to describe what's actually changed and why? ;-)
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.
Why
While working on this PR, I noticed the following error:
Caused by: java.lang.RuntimeException: Failed to start quarkus
at io.quarkus.runner.ApplicationImpl1.<clinit>(ApplicationImpl1.zig:205)
... 112 more
Caused by: java.lang.ClassFormatError: Duplicate method name "<init>" with signature "()V" in class file org/eclipse/microprofile/rest/client/tck/cditests/HasAppScopeTest$MyAppScopedApi
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:763)
at java.lang.ClassLoader.defineClass(ClassLoader.java:642)
at io.quarkus.runner.RuntimeClassLoader.findClass(RuntimeClassLoader.java:217)
at io.quarkus.runner.RuntimeClassLoader.loadClass(RuntimeClassLoader.java:163)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.eclipse.microprofile.rest.client.tck.cditests.HasAppScopeTest_MyAppScopedApi_4a90cb1eedbe1d7e3f457833a0ee883318179f2e_Synthetic_Bean.<init>(HasAppScopeTest_MyAppScopedApi_4a90cb1eedbe1d7e3f457833a0ee883318179f2e_Synthetic_Bean.zig:120)
at io.quarkus.arc.setup.Default_ComponentsProvider.getComponents(Default_ComponentsProvider.zig:222)
at io.quarkus.arc.ArcContainerImpl.<init>(ArcContainerImpl.java:84)
at io.quarkus.arc.Arc.initialize(Arc.java:18)
at io.quarkus.arc.runtime.ArcDeploymentTemplate.getContainer(ArcDeploymentTemplate.java:33)
at io.quarkus.deployment.steps.ArcAnnotationProcessor$build7.deploy_0(ArcAnnotationProcessor$build7.zig:53)
at io.quarkus.deployment.steps.ArcAnnotationProcessor$build7.deploy(ArcAnnotationProcessor$build7.zig:141)
at io.quarkus.runner.ApplicationImpl1.<clinit>(ApplicationImpl1.zig:191)
... 112 more
When running rest-client
tck tests notably when running and HasAppScopeTest
or HasRequestScopeTest
. My understanding is, we tried to generate a no arg constructor twice and looking at the modified code, an HashSet
is used while ClassInfo
does not declare an hashCode
method leading to MyAppScopedApi.class
being recorded twice.
What changed
Record a normal scoped bean class once based on its DotName
which has a hashCode
. The DotName
is provided by ClassInfo.name()
.
Is that the way to go about it? Open to changing this to something different. @mkouba @geoand
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.
Seems reasonable to me, @mkouba WDYT?
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.
@machi1990 otherwise the PR looks good! So pls revert the changes in NoArgsConstructorProcessor
and just ignore the interfaces there.
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.
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.
@mkouba did all the meaningful analysis 😆
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.
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.
I'll let @mkouba review since he was the one that found the problem
2bb30d3
to
8631726
Compare
<class name="org.eclipse.microprofile.rest.client.tck.cditests.HasRequestScopeTest"> | ||
|
||
|
||
<!-- excluded because of race scope configuration on SimpleGetApi interface --> |
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.
@mkouba I added a comment about here. If you run the tests one by one, they all pass. If you run them together, they fail randomly: one pass and not the other, etc.
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.
That's really weird and we should probably try to find the real cause first. I'll try to run the tests locally.
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.
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.
So I think that the problem is that ConfigProvider.getConfig()
caches the ConfigProviderResolver
in a static field. We do work around this limitation in QuarkusConfigProducer by using ConfigProviderResolver.instance().getConfig()
instead. I'll try to update the code and run the tests.
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.
Hm, it didn't help most probably because the rest client beans are registered in STATIC_INIT and ConfigProviderResolver
is re-set during RUNTIME_INIT...
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.
Hey @mkouba, thanks for the investigation. How do you advise we proceed regarding 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.
I've created #3089 - pls add this link to the relevant comment in the tck-suite.xml.
Then I think we can merge this PR.
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.
Done
…est/scope. Fixes quarkusio#2797. Makes Dependent default scope. Fixes quarkusio#2798
Fixes #2798
/cc @geoand