-
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
Extend reflection configuration for SmallRye FT #42229
Conversation
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 for the fault tolerance change. Someone else should approve the Vert.x changes, although they seem like a no-brainer.
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.
CI looks unhappy:
2024-07-30T20:52:39.8530794Z Caused by: org.graalvm.nativeimage.MissingReflectionRegistrationError: The program tried to reflectively invoke method public java.lang.String io.quarkus.it.rest.client.main.FaultToleranceClient$$CDIWrapper.fallback() without it being registered for runtime reflection. Add public java.lang.String io.quarkus.it.rest.client.main.FaultToleranceClient$$CDIWrapper.fallback() to the reflection metadata to solve this problem. See https://www.graalvm.org/latest/reference-manual/native-image/metadata/#reflection for help.
2024-07-30T20:52:39.8536648Z at org.graalvm.nativeimage.builder/com.oracle.svm.core.reflect.MissingReflectionRegistrationUtils.forQueriedOnlyExecutable(MissingReflectionRegistrationUtils.java:72)
2024-07-30T20:52:39.8538942Z at java.base@21.0.4/java.lang.reflect.Method.acquireMethodAccessor(Method.java:77)
2024-07-30T20:52:39.8540282Z at java.base@21.0.4/java.lang.reflect.Method.invoke(Method.java:577)
2024-07-30T20:52:39.8542250Z at io.smallrye.faulttolerance.core.invocation.NormalMethodInvoker.proceed(NormalMethodInvoker.java:46)
2024-07-30T20:52:39.8544470Z at io.smallrye.faulttolerance.FaultToleranceInterceptor.lambda$prepareFallbackFunction$13(FaultToleranceInterceptor.java:575)
2024-07-30T20:52:39.8546131Z ... 27 more
OK, that's weird. Since this PR only adds more reflection config to fault tolerance, that suggests there's more reflection configuration for the same class and they are not combined properly 🤷 |
@ApplicationScoped
@RestClient
@Typed({FaultToleranceClient.class})
@Path("/unprocessable")
public class FaultToleranceClient$$CDIWrapper extends RestClientReactiveCDIWrapperBase implements FaultToleranceClient {
public FaultToleranceClient$$CDIWrapper() {
ClassLoader var1 = Thread.currentThread().getContextClassLoader();
Class var2 = Class.forName("io.quarkus.it.rest.client.main.FaultToleranceClient", false, var1);
super(var2, "", "w-fault-tolerance", false);
}
@Consumes({"text/plain"})
@Produces({"text/plain"})
public String hello() {
return ((FaultToleranceClient)this.getDelegate()).hello();
}
public String fallback() {
return super.fallback();
}
@Fallback(
fallbackMethod = "fallback"
)
public String helloWithFallback() {
return super.helloWithFallback();
}
} Since Lines 124 to 159 in c9edbe6
I suspect/guess that the reason it's not happening is because the generated class is not indexed when processing the annotated methods. @Ladicek @gsmet any clues how I can overcome this and get the method registered? |
The added reflection seems to change the smallrye behavior though, since I wonder if this is a common pattern in places where the recorder is used, i.e. the recorder ensures things will be properly set up and work, while the library code silently fails when trying to configure things but without breaking things thanks to the recorder (similarly to #42140 (comment)). |
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.
The Vert.x changes LGTM.
c9edbe6
to
ee25435
Compare
...main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java
Outdated
Show resolved
Hide resolved
...main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java
Outdated
Show resolved
Hide resolved
10e2b31
to
25421b5
Compare
This is now ready for review. Some comments:
|
25421b5
to
39090e8
Compare
This comment has been minimized.
This comment has been minimized.
...main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java
Outdated
Show resolved
Hide resolved
...main/java/io/quarkus/smallrye/faulttolerance/deployment/SmallRyeFaultToleranceProcessor.java
Outdated
Show resolved
Hide resolved
5df5b55
to
55b7289
Compare
This comment has been minimized.
This comment has been minimized.
55b7289
to
da9bd5a
Compare
This comment has been minimized.
This comment has been minimized.
@Ladicek if you are still happy with the latest changes, I let you merge this one, thanks! |
Would it be possible to only register things for reflection as last resort? I feel we should always try, in order:
|
I'm not sure this is done, actually. I'd prefer to wait for @zakkak to return from PTO before doing anything with this PR. |
After discussing this with @Ladicek we concluded that:
With the above in mind I propose I move the VertX changes in a different PR and keep this PR as draft with just the smallrye-FT additions for future reference, hoping that eventually it might not be needed. Adding the metadata for all methods to be able to be queried doesn't affect correctness in this case, but just avoids the exception thrown when using |
Agreed. |
Doesn't seem to fix any functionality issues but prevents `MissingRegistrationErrors` from being thrown when `ThrowMissingRegistrationErrors` is enabled. Related to quarkusio#41995
Configures whether declared methods should be registered for reflection, for query purposes only, i.e. {@link Class#getMethods()}. Setting this enables getting all declared methods for the class but does not allow invoking them reflectively. Follow up to quarkusio#42035
da9bd5a
to
9812460
Compare
Doesn't seem to fix any functionality issues but prevents
MissingRegistrationErrors
from being thrown whenThrowMissingRegistrationErrors
is enabled.Related to #41995