-
Notifications
You must be signed in to change notification settings - Fork 20
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
PLAT-3546: Validating Config-files #797
base: master
Are you sure you want to change the base?
Conversation
… default config factory because of the bootstrap binding. Validation of the configs did not work. That is fixed by changing the order of the modules binding in relation to the bootstrap binding.
m.preBind(); | ||
} | ||
|
||
mergedModule = Modules.override(mergedModule) |
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.
checked if the test injector uses this feature to override modules?
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.
TestInjector should indeed override the modules. I made a special case for it.
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.
failing build
@Override | ||
public Integer getPrio() { | ||
// We want this module to override the default binding of ConfigFactory | ||
return 110; |
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.
Is there any way of creating a test to validate that this actually works, and more importantly continues to work in the future as well?
@@ -28,12 +28,12 @@ void shouldBindImplementationsToTheirInterfaces() { | |||
} | |||
|
|||
@Test | |||
void shouldUseBootStrapBindingOverDefault() { |
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.
This seems to be a very conscious choice, did you find any hints on why it was this way? It could help prevent reintroducing bugs that this might have resolved.
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.
No, I don't have any clue why it's done this way. The bootstrap module binds only two things:
bind(String[].class).annotatedWith(Names.named("args")).toInstance(args);
bind(ConfigFactory.class).toInstance(configFactory);
So it's either the default ConfigFactory class or whatever ConfigFactory compatible class defined in the override modules. I could not find hints why the default factory should always override.
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.
Maybe this order of overrides was made just for a single purpose: to promote the TestInjector in DbProxyTest. When this case is fixed, both tests and applications work fine.
… it's a TestInjector.
… the bootstrap override sequence. The latter is needed for TestInjector take effect. There still are some doubt about the initial justification of having ConfigFactory in the main method. There was an explanation about LoggingFactory. Not clear if it's still valid.
Quality Gate passedIssues Measures |
Validation of the config files seems to be broken for a long time.
ValidatingConfigFactory
did not have effect because its binding was always overridden by the default config factory from the bootstrap binding.For some reason bootstrap binding was giving the highest priority, thus overriding the bindings of all the auto-bind modules. I could not find any justification for this behaviour. The only class that is bound in the bootstrap module is
ConfigFactory
, and we want it to be overridden byValidatingConfigFactory
. It looks like it was a bug.The modules precedence is fixed so that the bootstrap is at the lowest place, overridden by the rest of the modules.