quarkusio / quarkus

Quarkus: Supersonic Subatomic Java.
https://quarkus.io
Apache License 2.0
13.73k stars 2.67k forks source link

Programmatic Redis Hosts - getHosts() method is not executed #33809

Closed geniusit closed 1 year ago

geniusit commented 1 year ago

Describe the bug

I need to generate a token as my redis password. So I ve followed this guide : Programmatic Redis Hosts

Unfortunately the getHosts() method is not executed

I ve also seen a similar issue here

Expected behavior

The getHosts() methods must be executed in order to get my password from an external service. I ve add a log.info statement on the first line of the getHosts() method and I should see it on the console after the application is started

Actual behavior

The getHosts() method is not executed.

How to Reproduce?

  1. Create a new Quarkus Project
  2. Add the quarkus-redis-client extension
  3. Create a class that implements RedisHostsProvider interface
  4. Add the appropriate configuration line in the application.properties file
  5. mvn compile quarkus:dev
  6. The log statement in the getHosts() method isn't show on the console

redis.zip

Output of uname -a or ver

No response

Output of java -version

openjdk version "17.0.1" 2021-10-19 LTS

GraalVM version (if different from Java)

No response

Quarkus version or git rev

Tested with 2.x.x.Final and 3.1.0.Final

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

Apache Maven 3.8.4

Additional information

I use lombok for logging (@Slf4j)

quarkus-bot[bot] commented 1 year ago

/cc @cescoffier (redis), @gsmet (redis), @machi1990 (redis)

cescoffier commented 1 year ago

It's because of the dev service that override the value. If you run in prod mode, I got the expected output:

I got:

2023-06-04 10:03:17,070 INFO  [red.ExampleRedisHostProvider] (main) getHosts is never executed ... why ?

Disable the dev service, and it works in dev mode:

quarkus.redis.devservices.enabled=false