Skip to content

Adjust how fieldAsText method in Config handles optional values#75

Merged
John-Paul-R merged 1 commit intoJohn-Paul-R:masterfrom
SonarBeserk:fix-config-display
Oct 28, 2021
Merged

Adjust how fieldAsText method in Config handles optional values#75
John-Paul-R merged 1 commit intoJohn-Paul-R:masterfrom
SonarBeserk:fix-config-display

Conversation

@SonarBeserk
Copy link
Copy Markdown
Contributor

@SonarBeserk SonarBeserk commented Oct 28, 2021

When attempting to display the config currently you seen an exception related to the use of field.get() in this method. This change instead casts the field as an optional value and gets the string value of the optional.

Due to

((Option<?>) field.get(this)).loadAndSave(props);
only Optionals are supported in the config at this point. If that ever changes it may make sense to type check the fields like mentioned at https://stackoverflow.com/a/2262639

@John-Paul-R John-Paul-R merged commit fb59e6a into John-Paul-R:master Oct 28, 2021
@John-Paul-R
Copy link
Copy Markdown
Owner

Seems this slipped through the cracks when I introduced the Option class. Good catch, and thanks for the fix!

I appreciate the link to the relevant stackoverflow as well 👍

@SonarBeserk SonarBeserk deleted the fix-config-display branch January 26, 2022 06:46
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