Closed diversit closed 1 week ago
/cc @radcortez (config)
cc @mkouba
Expected the Quarkus Config Converters to be available and used when running a QuarkusComponentTest test or to have some kind of mechanism with which custom converters can be registered.
@diversit You're right that we don't register any Quarkus-specific converter and there's also no way to modify the underlying SmallRyeConfigBuilder
. And I think that we should support both.
Describe the bug
A QuarkusComponentTest fails for components which rely on MicroProfile Config Converters provided by Quarkus. E.g.
io.quarkus.runtime.configuration.DurationConverter
.Testing a component using
fails with an exception:
java.lang.RuntimeException: Error injecting java.time.Duration io.quarkus.issue.MyComponent.myDuration
.Running the application works fine since then the Quarkus Config Converters are available.
Expected behavior
Expected the Quarkus Config Converters to be available and used when running a QuarkusComponentTest test or to have some kind of mechanism with which custom converters can be registered.
Actual behavior
None of the Quarkus Config Converters are registered.
The exception is caused by the default Duration converter provided by SmallRye's
io.smallrye.config.ImplicitConverters
which tries to use thejava.time.Duration.parse
function to parse the value but this does not support the syntax:60s
.Full stack trace:
How to Reproduce?
Component:
Component Test:
Output of
uname -a
orver
Darwin MacBook-Pro-8.local 22.5.0 Darwin Kernel Version 22.5.0: Mon Apr 24 20:53:19 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6020 arm64
Output of
java -version
openjdk version "22" 2024-03-19 OpenJDK Runtime Environment Temurin-22+36 (build 22+36) OpenJDK 64-Bit Server VM Temurin-22+36 (build 22+36, mixed mode)
Quarkus version or git rev
3.11.1
Build tool (ie. output of
mvnw --version
orgradlew --version
)Maven home: /Users/user/.m2/wrapper/dists/apache-maven-3.9.3-bin/326f10f4/apache-maven-3.9.3 Java version: 22, vendor: Eclipse Adoptium, runtime: /Users/user/.sdkman/candidates/java/22-tem Default locale: en_GB, platform encoding: UTF-8 OS name: "mac os x", version: "13.4", arch: "aarch64", family: "mac"
Additional information
I tried adding the converter manually in test code by
or adding in the test method itself but this does not work. The actual used
Config
from which theConverter
is obtained is different than the one created in the test. When trying to use the correct ClassLoaderthe test failed since a
Config
is already registered for that class loader.