Describe the bug
Using the annotation @ClientHeaderParam in a Rest Client as follows
@RegisterRestClient
@ClientHeaderParam(name = "Authorization", value = "{lookupAuth}")
public interface LookupAuthorizationPongClient {
@GET
@Path("/rest-pong")
@Produces(MediaType.TEXT_PLAIN)
String getPong();
default String lookupAuth() {
// ...
return "Bearer XXX";
}
}
The above example fails running using in Native mode. In JVM, it works file.
Expected behavior
It should work as in the JVM mode.
Actual behavior
The above example fails running using in Native mode. In JVM, it works file.
To Reproduce
Find in this link a small reproducer in a JUnit test (it's currently disabled as it's not working). The JVM version can be found in the same module.
In order to run the suite in native mode, run:
mvn clean verify -Dnative -Dquarkus.native.container-build=true -Dquarkus.native.native-image-xmx=4g
Environment (please complete the following information):
uname -a or ver: Linux localhost.localdomain 5.9.10-100.fc32.x86_64 #1 SMP Mon Nov 23 18:12:36 UTC 2020 x86_64 x86_64 x86_64 GNU/Linuxjava -version: openjdk version "11.0.9" 2020-10-20mvnw --version or gradlew --version): Additional context
(Add any other context about the problem here.)
/cc @phillip-kruger
As a workaround to provide the token this way, you could move this logic into another class:
@RegisterForReflection
public class HeaderGenerator {
public static String authorizationHeader() {
return "Basic XXXXXXX";
}
}
As this class is marked with the @RegisterForReflection annotation, it will be included in the native image. Then, using this method:
@RegisterRestClient
@ClientHeaderParam(name = "Authorization", value = "{io.quarkus.qe.ping.clients.HeaderGenerator.authorizationHeader}")
public interface SwaggerPetstore {
// ...
}
maybe @geoand could take a look, he is a pro when it comes to Native and REST world 馃槈
I remember seeing this before.
IIRC, the problem is that we under the hood the rest client needs to use MethodHandle to invoke the default method, but those don't work in native mode.
@michalszynkiewicz am I correct?
I'm 90% sure that's the case.
IIRC, with https://github.com/resteasy/Resteasy/commit/c4a1715c8b389d5ec202a35f47370053c4dc27c1 we should be able to fix it but last I checked this commit didn't make into any released version of Resteasy...
OTOH, when/if we switch to MP Rest Client to Reactive RestEasy we should be able to fix this problem regardless of ^
A) will this switch happen for Quarkus 1.11 ?
B) We still need it fixed for quarkus-resteasy. @asoldano / @ronsigal when do you plan to cut 4.5.9.Final or 4.6.0.Final?
https://github.com/resteasy/Resteasy/releases/tag/4.5.8.Final says it was created few month ago (on Sep 26)
Quarkus 1.11 is gonna be important from product perspective, it should include RESTEasy version with the latest updates.
A) will this switch happen for Quarkus 1.11 ?
Definitely not :)
A) will this switch happen for Quarkus 1.11 ?
B) We still need it fixed for quarkus-resteasy. @asoldano / @ronsigal when do you plan to cut 4.5.9.Final or 4.6.0.Final?
The plan is to release 4.6.0.Final as soon as MicroProfile 4 goes final
Most helpful comment
I'm 90% sure that's the case.
IIRC, with https://github.com/resteasy/Resteasy/commit/c4a1715c8b389d5ec202a35f47370053c4dc27c1 we should be able to fix it but last I checked this commit didn't make into any released version of Resteasy...
OTOH, when/if we switch to MP Rest Client to Reactive RestEasy we should be able to fix this problem regardless of ^