It's very important to ensure that the Configuration the CliFrontend loads ends up in the *ContexteEnvironment and that its settings are reflected there. Currently, there are no tests for this behaviour and it is hard to convince yourself that the code is actually doing the right thing. We should simplify the flow of the Configuration from loading to the environment and add tests that verify this behaviour.
Currently, the flow is roughly this:
- the main() method loads the Configuration (from flink-conf.yaml)
- the Configuration is passed to the CustomCommandLines in loadCustomCommandLines()
- main() passes both the Configuration and the CustomCommandLines to the constructor of CliFrontend
- when we need a Configuration for execution getEffectiveConfiguration() is called. This doesn't take the Configuration of the CliFrontend as a basis but instead calls CustomCommandLine.applyCommandLineOptionsToConfiguration
It's up to the CustomCommandLine.applyCommandLineOptionsToConfiguration() implemenation to either forward the Configuration that was given to it by the CliFrontend.main() method or return some other Configuration. Only if the correct Configuration is returned can we ensure that user settings make it all the way though.
I'm proposing to change CustomCommandLine.applyCommandLineOptionsToConfiguration() to instead apply it's settings to a Configuration that is passed in a parameter, then getEffectiveConfiguration() can pass in the Configuration it got from the main() method as a basis and the flow is easy to verify because.