-
Notifications
You must be signed in to change notification settings - Fork 122
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
unwrap config instead of just cast #871
Conversation
cdi/src/main/java/io/smallrye/config/inject/ConfigPropertiesInjectionBean.java
Outdated
Show resolved
Hide resolved
78b6d19
to
6733e61
Compare
6733e61
to
69ae0d0
Compare
Hi, @craig-day Thanks for the PR. We have other places in the code where we are casting to |
@radcortez I've updated all the casts I could find that were not test. Do you think we should unwrap in test too? |
Yes, please, go ahead. Thank you! |
unwrap to SmallRyeConfig in other places too unwrap over cast to SmallRyeConfig in test
62a3cea
to
31d5fe8
Compare
@radcortez I replaced all the casts with |
Can you run the build locally to fix the formatting issues and push again? :) Thanks! |
@radcortez updated and pushed :D |
Great! Thank you! |
My app uses MicroProfile Config generically, and also uses the SmallRye implementation. My config provider returns a class called
SmallRyeAppSettings
whichimplements Config
. I think this is valid according to the MP spec. However, when I try to inject config, I end up with a class cast exception.I traced the error to this specific cast.
Following the docs from both MP and SmallRye, I think we should use
unwrap
when handling results fromConfigProvider.getConfig()
rather than casting. I added an instanceof shortcut check here to maintain the previous code path. Probably not necessary.Alternatively, should this be using the small rye provider directly? Maybe this?
I'm not sure if this will create a circular dependency so I went with the more generic unwrap route first.
I tried to write a test, but to register an override for a
ConfigProvider
, you need to create somethingServiceLoader
can pick up. I couldn't find a nice way to do something for just a single test class that didn't impact all the other test classes.