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

Configuration file related changes #1459

Merged
merged 3 commits into from
Jan 26, 2021
Merged

Configuration file related changes #1459

merged 3 commits into from
Jan 26, 2021

Conversation

kryalama
Copy link
Contributor

Enhancements:
Improve discoverability of configuration file syntax error
Fail on invalid config attributes instead of silently ignoring

Copy link
Member

@trask trask left a comment

Choose a reason for hiding this comment

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

does the user see a friendly message on invalid json attribute?

Comment on lines 140 to 142
} catch (URISyntaxException e) {
e.printStackTrace();
} finally {
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
} catch (URISyntaxException e) {
e.printStackTrace();
} finally {
} catch (Throwable e) {
e.printStackTrace();

Comment on lines 143 to 150
// If the startupLogger still have some issues being initialized, just print the error stack trace
if(startupLogger == null) {
if (isFriendlyException) {
System.err.println(message);
} else {
t.printStackTrace();
}
}
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// If the startupLogger still have some issues being initialized, just print the error stack trace
if(startupLogger == null) {
if (isFriendlyException) {
System.err.println(message);
} else {
t.printStackTrace();
}
}
if (isFriendlyException) {
System.err.println(message);
} else {
t.printStackTrace();
}

@@ -288,7 +288,7 @@ public static Configuration loadJsonConfigFile(Path configPath) throws IOExcepti
long lastModifiedTime = attributes.lastModifiedTime().toMillis();
try (InputStream in = Files.newInputStream(configPath)) {
Moshi moshi = MoshiBuilderFactory.createBuilderWithAdaptor();
JsonAdapter<Configuration> jsonAdapter = moshi.adapter(Configuration.class);
JsonAdapter<Configuration> jsonAdapter = moshi.adapter(Configuration.class).failOnUnknown();
Copy link
Member

Choose a reason for hiding this comment

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

nice

@kryalama
Copy link
Contributor Author

does the user see a friendly message on invalid json attribute?

I was thinking to handle this in a new PR. I will create a work item for this.

@kryalama kryalama requested a review from trask January 25, 2021 22:28
],
"selfDiagnostics": {
"level": "debug"
}
]
Copy link
Member

Choose a reason for hiding this comment

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

😄 👍

@kryalama kryalama merged commit 93ee092 into master Jan 26, 2021
@trask trask deleted the kryalama/configex branch February 14, 2021 18:52
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.

2 participants