Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: quarkusio/quarkus
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 5a47e492e18f98c61cb90ac09b24aa41ed5b3980
Choose a base ref
..
head repository: quarkusio/quarkus
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6e6494174d02b3138858c84338c3f9cab99ee6a6
Choose a head ref
Original file line number Diff line number Diff line change
@@ -15,14 +15,15 @@ public class StaticInitConfigInjectionFailureTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot(root -> root
.addClasses(StaticInitBean.class, UnsafeConfigSource.class)
.addClasses(StaticInitBean.class, StaticInitEagerBean.class, UnsafeConfigSource.class)
.addAsServiceProvider(ConfigSource.class, UnsafeConfigSource.class)
// the value from application.properties should be injected during STATIC_INIT
.addAsResource(new StringAsset("apfelstrudel=jandex"), "application.properties"))
.assertException(t -> {
assertThat(t).isInstanceOf(IllegalStateException.class)
.hasMessageContainingAll("Injected config property value mismatch detected",
"the runtime value of 'apfelstrudel' is [gizmo] but the value [jandex] was injected into io.quarkus.arc.test.config.staticinit.StaticInitBean#value");
"the runtime value of 'apfelstrudel' is [gizmo] but the value [jandex] was injected into io.quarkus.arc.test.config.staticinit.StaticInitBean#value",
"the runtime value of 'apfelstrudel' is [gizmo] but the value [jandex] was injected into io.quarkus.arc.test.config.staticinit.StaticInitEagerBean#value");
});

@Test
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package io.quarkus.arc.test.config.staticinit;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Singleton;

import org.eclipse.microprofile.config.inject.ConfigProperty;

@Singleton
public class StaticInitEagerBean {

@ConfigProperty(name = "apfelstrudel")
Instance<String> value;

// bean is instantiated during STATIC_INIT
void onInit(@Observes @Initialized(ApplicationScoped.class) Object event) {
// this should trigger the failure
value.get();
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.quarkus.arc.test.config.staticinit;

import jakarta.enterprise.context.ApplicationScoped;
import jakarta.enterprise.context.Initialized;
import jakarta.enterprise.event.Observes;
import jakarta.enterprise.inject.Instance;
import jakarta.inject.Singleton;

import org.eclipse.microprofile.config.inject.ConfigProperty;

@Singleton
public class StaticInitLazyBean {

@ConfigProperty(name = "apfelstrudel")
Instance<String> value;

// bean is instantiated during STATIC_INIT
void onInit(@Observes @Initialized(ApplicationScoped.class) Object event) {
// value is not obtained...
}

}
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public class StaticInitSafeConfigInjectionTest {
@RegisterExtension
static final QuarkusUnitTest config = new QuarkusUnitTest()
.withApplicationRoot(root -> root
.addClasses(StaticInitSafeBean.class, UnsafeConfigSource.class)
.addClasses(StaticInitSafeBean.class, StaticInitLazyBean.class, UnsafeConfigSource.class)
.addAsServiceProvider(ConfigSource.class, UnsafeConfigSource.class)
// the value from application.properties should be injected during STATIC_INIT
.addAsResource(new StringAsset("apfelstrudel=jandex"), "application.properties"));