Skip to content
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

MP REST Client configuration at runtime does not work since quarkus 2.4.0-final #21341

Closed
franden opened this issue Nov 10, 2021 · 3 comments · Fixed by #21530
Closed

MP REST Client configuration at runtime does not work since quarkus 2.4.0-final #21341

franden opened this issue Nov 10, 2021 · 3 comments · Fixed by #21530
Labels
area/rest-client env/windows Impacts Windows machines kind/bug Something isn't working
Milestone

Comments

@franden
Copy link

franden commented Nov 10, 2021

Describe the bug

In versions before quarkus 2.4.0-final the configuration of MP REST clients was possible during the runtime of the application. It was very helpful e.g to switch an client to a backup system if the productive system was not available. since quarkus 2.4.0-final the mutation of the Microprofile Rest Client properties during the runtime does not have effect.

Example:

Resource:

@RequestScoped
@Path("/hello")
public class GreetingResource {

    public static final String GREETING_MESSAGE = "Hello From GreetingResource";
    public static final String CONFIG_NAME_SALUTATION = "greetings.salutation";

    @ConfigProperty(name = CONFIG_NAME_SALUTATION, defaultValue = "Hoi!!")
    String salutation;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello() {
        return salutation + " " + GREETING_MESSAGE;
    }
}

Client:

@RequestScoped
@RegisterRestClient(configKey = "greetings.client")
public interface GreetingsClient {

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello();
}

⚠️Test is failing since quarkus 2.4.0-final:

@QuarkusTest
public class GreetingResourceTest {

    @Inject
    @RestClient
    GreetingsClient greetingsClient;

    @Test
    @SetSystemProperty(key = "greetings.client/mp-rest/url", value = "https://www.google.de")
    public void testWithRestClientWithWrongUrl_ViaMP() {
        String message = greetingsClient.hello();
        assertThat(message, not(containsString(GreetingResource.GREETING_MESSAGE))); //⚠️failing since quarkus 2.4.0-final
    }
}

Expected behavior

After the mutation of MP REST client configuration the newly created instance must use the changed configuration

Actual behavior

MP REST Client configuration at runtime does not work since quarkus 2.4.0-final

How to Reproduce?

https://github.com/franden/issue-rest-client-configuration
run GreetingResourceTest.testWithRestClientWithWrongUrl_ViaMP test

Output of uname -a or ver

Microsoft Windows [Version 10.0.19042.1288]

Output of java -version

openjdk version "11.0.10" 2021-01-19 OpenJDK Runtime Environment AdoptOpenJDK (build 11.0.10+9) OpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.10+9, mixed mode)

GraalVM version (if different from Java)

No response

Quarkus version or git rev

2.4.1-final

Build tool (ie. output of mvnw --version or gradlew --version)

Apache Maven 3.8.1 (05c21c65bdfed0f71a2f2ada8b84da59348c4c5d) Maven home: C:\Users\ivfrk.m2\wrapper\dists\apache-maven-3.8.1-bin\2l5mhf2pq2clrde7f7qp1rdt5m\apache-maven-3.8.1 Java version: 11.0.10, vendor: AdoptOpenJDK, runtime: c:\Work\Tools\JDK\11\OpenJDK11U-jdk_x64_windows_hotspot_11.0.10_9\jdk-11.0.10+9 Default locale: de_DE, platform encoding: Cp1252 OS name: "windows 10", version: "10.0", arch: "amd64", family: "windows"

Additional information

No response

@franden franden added the kind/bug Something isn't working label Nov 10, 2021
@quarkus-bot
Copy link

quarkus-bot bot commented Nov 10, 2021

/cc @michalszynkiewicz

@quarkus-bot quarkus-bot bot added area/rest-client env/windows Impacts Windows machines labels Nov 10, 2021
@geoand
Copy link
Contributor

geoand commented Nov 10, 2021

@radcortez @michalszynkiewicz I think we have had similar reports, right (#21345 seems related, but I think I remember more)?

Is this related to the new rest client config stuff?

Can we make this a priority to fix since it seems to be affecting a lot of people?

@radcortez
Copy link
Member

Is this related to the new rest client config stuff?

Yes.

The problem here is that since the Rest Client configuration is now handled by the RestClientsConfig ConfigRoot, this is only loaded at application start and any changes to the configuration have no further effects (like setting the system property in the test).

I think I'm going to open a separate issue to group all these problems so we don't have the discussion spread between several issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/rest-client env/windows Impacts Windows machines kind/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants