-
Notifications
You must be signed in to change notification settings - Fork 3k
ArC: fix subclass generation with not visible decorators #50452
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
ArC: fix subclass generation with not visible decorators #50452
Conversation
|
I take it you use the fact that decorated types are all interfaces, and even abuse that by storing the "next" decorator into a field of type |
This comment has been minimized.
This comment has been minimized.
|
@Ladicek friendly ping in case it fell from your radar :) |
|
It's on my list as well. It's just that other items crept in... I will try to do it tomorrow though :) |
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.
Just small notes on the tests, otherwise it looks good.
...-projects/arc/tests/src/test/java/io/quarkus/arc/test/decorators/NonPublicDecoratorTest.java
Outdated
Show resolved
Hide resolved
...-projects/arc/tests/src/test/java/io/quarkus/arc/test/decorators/NonPublicDecoratorTest.java
Outdated
Show resolved
Hide resolved
| import io.quarkus.arc.test.decorators.other.Converter; | ||
| import io.quarkus.arc.test.decorators.other.ToUpperCaseConverter; | ||
|
|
||
| public class NonPublicDecoratorTest { |
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.
Just as an FYI for others reviewing this. The failure in this test is different than the one reported in the issue.
Here I was getting:
[ERROR] io.quarkus.arc.test.decorators.NonPublicDecoratorTest.testDecoration -- Time elapsed: 0.235 s <<< ERROR!
java.lang.IllegalArgumentException: Must be a Class or String, got T
at io.quarkus.gizmo.DescriptorUtils.objectToDescriptor(DescriptorUtils.java:133)
at io.quarkus.gizmo.MethodDescriptor.ofMethod(MethodDescriptor.java:98)
at io.quarkus.arc.processor.SubclassGenerator.processDecorator(SubclassGenerator.java:770)
at io.quarkus.arc.processor.SubclassGenerator.createConstructor(SubclassGenerator.java:206)
at io.quarkus.arc.processor.SubclassGenerator.generate(SubclassGenerator.java:126)
at io.quarkus.arc.processor.BeanProcessor.generateResources(BeanProcessor.java:480)
at io.quarkus.arc.processor.BeanProcessor.process(BeanProcessor.java:583)
at io.quarkus.arc.test.ArcTestContainer.init(ArcTestContainer.java:503)
at io.quarkus.arc.test.ArcTestContainer.beforeEach(ArcTestContainer.java:342)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
|
I have added a While this solution works, it might break some other cases we don't have covered although I haven't thought of any so far. |
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.
Looks good but I'd like to run the SingleDecoratorBenchmark, just in case...
5d821eb to
f1c8a08
Compare
This comment has been minimized.
This comment has been minimized.
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. I added an extra commit with a comment about decorators being interface-based and hence the decorator field can always be Object, but other than that, I have nothing to add. Great work here!
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Status for workflow
|
This fixes several visibility issues in the generated subclass if decorators are not visible from the decorated bean or an other decorator in the chain.
An example error looks like this:
The fix is to use the methods on the decorated types and not the decorator class.
A work around without the fix would be to make the decorator abstract (only works with a single decorator and not with a chain).