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

Fix exception when plugin settings are empty #1525

Merged

Conversation

dlvenable
Copy link
Member

Description

When creating a plugin configuration with an empty plug-in settings, make that configuration non-null. This fixes a bug where the call to validate() was provided a null pointer. Additionally, plugins should expect that their configurations are non-null.

Issues Resolved

N/A

Check List

  • New functionality includes testing.
  • New functionality has been documented.
    • New functionality has javadoc added
  • Commits are signed with a real name per the DCO

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

…ting to validate that setting. Always return a non-null plugin configuration.

Signed-off-by: David Venable <[email protected]>
@dlvenable dlvenable requested a review from a team as a code owner June 17, 2022 20:52
@codecov-commenter
Copy link

Codecov Report

Merging #1525 (a4b06a9) into main (fe138f5) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@            Coverage Diff            @@
##               main    #1525   +/-   ##
=========================================
  Coverage     94.17%   94.18%           
- Complexity     1179     1181    +2     
=========================================
  Files           165      165           
  Lines          3382     3386    +4     
  Branches        276      277    +1     
=========================================
+ Hits           3185     3189    +4     
  Misses          141      141           
  Partials         56       56           
Impacted Files Coverage Δ
...taprepper/plugin/PluginConfigurationConverter.java 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update fe138f5...a4b06a9. Read the comment docs.

@dlvenable dlvenable merged commit 7d26f16 into opensearch-project:main Jun 17, 2022
private Object convertSettings(final Class<?> pluginConfigurationType, final PluginSetting pluginSetting) {
Map<String, Object> settingsMap = pluginSetting.getSettings();
if (settingsMap == null)
settingsMap = Collections.emptyMap();
Copy link
Contributor

Choose a reason for hiding this comment

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

The PluginSettings class define the default value for an empty plugin settings over the PluginConfigurationConverter

Copy link
Member Author

Choose a reason for hiding this comment

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

Yea, I thought about that as well. But, I didn't want to interrupt any use of getSettings that was already using null.

From what I can tell, plugins that use the new pluginConfigurationType are all assuming non-null configurations. So I wanted to at least cover that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I'd like to fully remove PluginSettings someday. :)

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for clarifying!

@dlvenable dlvenable deleted the plugin-null-validation-fix branch June 23, 2022 14:08
finnroblin pushed a commit to finnroblin/data-prepper that referenced this pull request Jul 11, 2022
…ting to validate that setting. Always return a non-null plugin configuration. (opensearch-project#1525)

Signed-off-by: David Venable <[email protected]>
Signed-off-by: Finn Roblin <[email protected]>
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