-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Copy default methods of a RestClient Reactive interface to the genera…
…ted class RestClient Reactive generates a `...$$CDIWrapper` class for each RestClient interface, and creates an implementation of each RestClient method. This leaves non-RestClient methods (`default` methods) on the interface, which means that if they are annotated with an interceptor binding, the interceptor is not invoked. This is because interceptor bindings are not inherited from superinterfaces, only from superclasses (and while ArC has some support for intercepting `default` methods from superinterfaces, it doesn't extends that far). This PR doesn't attempt to support intercepting `default` methods in general, because that's a gray area. Instead, it fixes how RestClient Reactive generates the class for a RestClient interface (because RestClient interfaces are special in that they may define class-based beans if annotated `@RegisterRestClient`). In addition to RestClient methods, `default` methods from the RestClient interface are also copied to the generated class. (The "copy" delegates to the `default` method inherited from the superinterface, which had to be added to Gizmo, hence the Gizmo update.) That itself is enough for interceptors to start working.
- Loading branch information
Showing
6 changed files
with
98 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...st-client-reactive/src/main/java/io/quarkus/it/rest/client/main/FaultToleranceClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package io.quarkus.it.rest.client.main; | ||
|
||
import javax.ws.rs.Consumes; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.faulttolerance.Fallback; | ||
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient; | ||
|
||
@Path("/unprocessable") | ||
@RegisterRestClient(configKey = "w-fault-tolerance") | ||
public interface FaultToleranceClient { | ||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
@Consumes(MediaType.TEXT_PLAIN) | ||
String hello(); | ||
|
||
@Fallback(fallbackMethod = "fallback") | ||
default String helloWithFallback() { | ||
return hello(); | ||
} | ||
|
||
default String fallback() { | ||
return "Hello fallback!"; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
integration-tests/rest-client-reactive/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
w-exception-mapper/mp-rest/url=${test.url} | ||
w-fault-tolerance/mp-rest/url=${test.url} | ||
io.quarkus.it.rest.client.multipart.MultipartClient/mp-rest/url=${test.url} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters