Skip to content
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

Reflection check on startup to validate injected configurations #289

Open
costimuraru opened this issue Apr 6, 2016 · 0 comments
Open

Comments

@costimuraru
Copy link

We're considering using governator in our projects and after giving it a try, I must say I'm impressed. Keep up the great work!

The one thing that's bugging me is the inability to check injected configurations at startup time. Let me give a simple example.

Sample class that uses a configuration mapping:

public class AppConfig {
    @Configuration("baaar") String bar;
}

Example of reference.conf:

bar = 111

I'm using ArchaiusConfigurationProvider to read these configs.

As you can see the configuration mapping (baaar) is spelled wrong in our case, as it does not match any entry in the config file. In this case the appConfig.bar is going to be assigned null.
This simple typo can cause big problems down the road (null pointer exceptions & co). It would be awesome if we could choose to fail with a runtime exception when a configuration maps to an inexistent config. How would one achieve this?

For instance, a much smaller library (https://github.com/racc/typesafeconfig-guice) has this kind of support. It uses reflection to check all the injected fields to see if it maps to existing configs. Though it lacks the support for dynamic config on runtime, which is a pity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant