Closed luneo7 closed 2 months ago
/cc @radcortez (config)
Shouldn't it fallback to the @WithDefault
value if there is no setting for the profile?
At least the https://quarkus.io/guides/config-mappings#defaults docs states:
The @WithDefault annotation allows to set a default property into a mapping (and prevent and error if the configuration value is not available in any ConfigSource):
Or are we required to do something like:
package org.acme.bazinga.extension.runtime;
import io.quarkus.runtime.annotations.ConfigPhase;
import io.quarkus.runtime.annotations.ConfigRoot;
import io.smallrye.config.ConfigMapping;
import java.util.Optional;
@ConfigMapping(prefix = "quarkus.bazinga")
@ConfigRoot(phase = ConfigPhase.RUN_TIME)
public interface BazingaConfig {
/**
* The Bazinga String
*/
String bazingaString();
/**
* The Bazinga Number
*/
Optional<Integer> bazingaNumber();
default int getBazingaNumber() {
return bazingaNumber().orElse(250);
}
}
now? cause doing this works...
the only thing with it is that... now it also accepts setting quarkus.bazinga.get-bazinga-number=500
although it does nothing :lol:
This was already fixed for mappings in https://github.com/quarkusio/quarkus/pull/40225. Can you please try using main
?
The PR https://github.com/quarkusio/quarkus/pull/40516 is to fix it for the old roots.
Hey @radcortez just tested the PR and main it works as expected, thanks =] Will that be ported to 3.10 or will we just have that with 3.11?
Unfortunately, we need to wait till 3.11. https://github.com/quarkusio/quarkus/pull/40225 is not a trivial change, and we shouldn't backport it.
As a workaround, you must set the default when running on a different profile between runtime / build time. Sorry for the inconvenience :(
Describe the bug
When setting an extension config property that has a
@WithDefault
inapplication.properties
for an specific profile,%prod
for instance, and later launching the application with a different profile renders aThe config property ... is required but it could not be found in any config source
(happens both in JVM and native)Expected behavior
As with Quarkus 3.8 it should load properties for the profile that was supplied during execution.
Actual behavior
App doesn't boot and throws exception
The config property ... is required but it could not be found in any config source
How to Reproduce?
mvn clean install package -Dnative
./app/target/bazinga-app-1.0.0-SNAPSHOT-runner -Dquarkus.profile=staging
You can also test JVM
mvn clean install package
java -Dquarkus.profile=staging -jar app/target/quarkus-app/quarkus-run.jar
Output of
uname -a
orver
Darwin C02C32WQMD6R 23.2.0 Darwin Kernel Version 23.2.0: Wed Nov 15 21:54:10 PST 2023; root:xnu-10002.61.3~2/RELEASE_X86_64 x86_64
Output of
java -version
openjdk version "21.0.2" 2024-01-16 OpenJDK Runtime Environment GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30) OpenJDK 64-Bit Server VM GraalVM CE 21.0.2+13.1 (build 21.0.2+13-jvmci-23.1-b30, mixed mode, sharing)
Quarkus version or git rev
3.10.0
Build tool (ie. output of
mvnw --version
orgradlew --version
)Apache Maven 3.9.5 (57804ffe001d7215b5e7bcb531cf83df38f93546) Maven home: /usr/local/Cellar/maven/3.9.5/libexec Java version: 21.0.2, vendor: GraalVM Community, runtime: /Library/Java/JavaVirtualMachines/graalvm-community-openjdk-21.0.2+13.1/Contents/Home Default locale: en_CA, platform encoding: UTF-8 OS name: "mac os x", version: "14.2.1", arch: "x86_64", family: "mac"
Additional information
Another thing that I noted is that integration tests are being run with
prod
profile and nottest
... shouldn't it be run withtest
profile? that's why I've set<skipITs>true</skipITs>
in thenative
profile...