For Helidon MP..
I am observing some problem, in field injection, when accessed in constructor.
In below scenario, getting the null value in constructor, with or without @Inject over the constructor
The GreetingProvider
class is annotate with ApplicationScoped
@Inject
@ConfigProperty(name = "app.greeting")
private String message;
@Inject //Getting the field as null with or without @Inject annotation
public GreetingProvider() {
LOG.debug("Message {}, message);
}
Can get the value in the event listener for ApplicationScoped
.
It works fine if I used constructor based injection.
@Inject
public GreetingProvider(@ConfigProperty(name = "app.greeting") String message) {
this.message.set(message);
}
Shouldn't the constructor get the initialised value from the field injection?
Expecting the initialised field injected with @ConfigProperty
to be accessible in constructor.
It is accessible in the method annotated with @PostConstruct
or method which observes the event activated(@Observes @Initialized(ApplicationScoped.class) final Object event)
.