-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ensure YAML configuration is taken into account for DynamicFeatures #18238
Conversation
689ab72
to
ef3413f
Compare
This seems perfectly reasonable to me |
Not for @radcortez as he prefers a solution that would work with all @radcortez Do I close this PR? |
Of course Roberto is the subject matter expert here, so it's up to him |
If you can work around with my proposal, yes :) Did that work? |
@radcortez If your workaround is to initialize "manually" the Bean that I inject into my DynamicFeature as next: My class file
My file
The answer is no, it doesn't work as it still uses a My current workaround is to somehow fork the config-yaml extension with this fix, I could not found any better way for now 😞 |
No, that was not what I was thinking. You need to do the lookup in the |
Ah I see, your idea is to delay the initialization to make it happen during at worse the startup time but in my use case I cannot do that, I need my bean to be initialized when calling the configure method of my DynamicFeature which happens during the static init phase. |
Not exactly. You let the bean initialize without any value (or a default). Then inside the Something like: @Priority(1001)
public class GreetingFilter implements ContainerResponseFilter {
private AtomicReference<String> message = new AtomicReference();
private CountDownLatch init = new CountDownLatch(1);
@Override
public void filter(ContainerRequestContext containerRequestContext, ContainerResponseContext containerResponseContext)
throws IOException {
ensureInit();
containerResponseContext.getHeaders().add("X-MESSAGE", message);
}
private void ensureInit( {
if (message.compareAndSet(null, "some-default"))) {
ConfigProvider.getConfig().getOptionalValue("my.property", String.class).ifPresent(message::set);
init.countDown();
} else {
try {
init.await();
} catch (final InterruptedException e) {
// log
}
}
}
} I did by memory, so I hope I didn't forget anything, but I hope you get the idea :) |
@radcortez Yeah it is what I understood from your previous comment but unfortunately my real use case is not exactly what I put in the PR, I added a filter just to be able to easily test the value injected into the DynamicFeature. My real use case is more:
I'm afraid that your workaround is not applicable in my use case since the bean needs to be initialized when calling the configure method and the configure method is called during the static init phase 😢 |
Ok, let's work on this PR and try to solve this use case while we think of another solution for the overall problem. |
...fig-yaml/deployment/src/main/java/io/quarkus/config/yaml/deployment/ConfigYamlProcessor.java
Outdated
Show resolved
Hide resolved
...ts/resteasy-jackson/src/main/java/io/quarkus/it/resteasy/jackson/GreetingDynamicFeature.java
Outdated
Show resolved
Hide resolved
4c88cde
to
51fa71c
Compare
This workflow status is outdated as a new workflow run has been triggered. |
@radcortez remarks addressed, please check again |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better. Thank you. Let's wait for CI now.
@radcortez the CI seems to be happy, is something missing before being merged? |
Yes. This one should go first: #17483 and then this one rebased on. |
@radcortez I merged #17483 . It appears this one still applies cleanly. Should we merge or it requires additional adjustments? |
The used |
No PBR, I will |
51fa71c
to
c21961b
Compare
Thanks! |
Should be done, let's see what the CI says |
CI looks happy :). @radcortez I let you check that everything is OK and merge? Thanks! |
fixes #18237
Motivation
Value of properties defined into a YAML file cannot be used anymore since Quarkus 2.0 in case of JAX-RS
DynamicFeature
sModifications:
ConfigPropertyProvider
of the yaml extension asStaticInitConfigSourceProviderBuildItem