Skip to content

Conversation

@tylerbenson
Copy link
Contributor

@tylerbenson tylerbenson commented Aug 28, 2020

This changes some semantics of config a bit... for example the order of precedence between aliases and other sources.

The big benefit this has is removing the additional config constructor which was generally not used.

I think we could improve consistency between when we load config with the dd. prefix and when we don't. I tried to maintain existing semantics when possible.

This changes some semantics of config a bit... for example the order of precedence between aliases and other sources.

Additional tests are needed for various providers, but ConfigTest should cover most cases.
@tylerbenson tylerbenson requested a review from a team as a code owner August 28, 2020 22:26
import lombok.extern.slf4j.Slf4j;

@Slf4j
final class ConfigConverter {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wonder if type specific converters would be better than many static methods, but this is fine.

try {
return PUBLIC_LOOKUP.findStatic(type, "valueOf", MethodType.methodType(type, String.class));
} catch (final NoSuchMethodException | IllegalAccessException e) {
log.debug("Can't invoke or access 'valueOf': ", e);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should by error. I also think this should fail immediately with an Exception or Error in tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can add an assert in ConfigProvider where the exception is being caught and ignored.

}
}

public static ConfigProvider withPropertiesOverride(Properties properties) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ConfigProvider was a Composite of its own type rather than Sources, then this code would have less duplication.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand what you mean here.

Copy link
Contributor

@dougqh dougqh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are few small things that could be improved further, but I think this is solid clean-up to Config. I'm mostly happy with this as is, but I still think it would be good to run these changes by the entire team.

Add assert for conversion exception.

log.debug("New instance: {}", this);
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So much red... 🤩

@tylerbenson tylerbenson changed the title Refactor Config using ConfigProvider Config changes that may impact precedence order for overlapping config defined in multiple places. Sep 1, 2020
@tylerbenson tylerbenson merged commit 4c40b18 into master Sep 1, 2020
@tylerbenson tylerbenson deleted the tyler/config-source branch September 1, 2020 15:04
@github-actions github-actions bot added this to the 0.62.0 milestone Sep 1, 2020
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

Successfully merging this pull request may close these issues.

5 participants