fix sql compatible null handling config work with runtime.properties#8876
Merged
clintropolis merged 12 commits intoapache:masterfrom Nov 20, 2019
Merged
fix sql compatible null handling config work with runtime.properties#8876clintropolis merged 12 commits intoapache:masterfrom
clintropolis merged 12 commits intoapache:masterfrom
Conversation
2 tasks
Contributor
|
@clintropolis The Travis failure looks legit, e.g., [ERROR] org.apache.druid.server.lookup.jdbc.JdbcDataFetcherTest$FetchTest.testFetch(org.apache.druid.server.lookup.jdbc.JdbcDataFetcherTest$FetchTest)
[ERROR] Run 1: JdbcDataFetcherTest$FetchTest.testFetch:111->assertMapLookup:176 » NullPointer
[ERROR] Run 2: JdbcDataFetcherTest$FetchTest.testFetch:111->assertMapLookup:176 » NullPointer
[ERROR] Run 3: JdbcDataFetcherTest$FetchTest.testFetch:111->assertMapLookup:176 » NullPointer
[ERROR] Run 4: JdbcDataFetcherTest$FetchTest.testFetch:111->assertMapLookup:176 » NullPointer |
gianm
reviewed
Nov 19, 2019
| { | ||
| this.useDefaultValuesForNull = useDefaultValuesForNull == null | ||
| ? true | ||
| ? Boolean.valueOf(System.getProperty(NULL_HANDLING_CONFIG_STRING, "true")) |
Contributor
There was a problem hiding this comment.
I don't think this System.getProperty is necessary. The normal Druid injectorator stuff (what is being activated by the JsonConfigProvider.bind line in NullHandlingModule) handles reading from system properties too.
| private static NullValueHandlingConfig INSTANCE = new NullValueHandlingConfig( | ||
| Boolean.valueOf(System.getProperty(NULL_HANDLING_CONFIG_STRING, "true")) | ||
| ); | ||
| private static NullValueHandlingConfig INSTANCE; |
Contributor
There was a problem hiding this comment.
I suggest making a private getInstance() method, using that everywhere, and having that method throw a nice exception that asks you to either call NullHandling.initializeForTests() or include NullHandlingModule. That way, future benchmark and test writers don't get confused by null pointer exceptions.
5 tasks
Member
Author
|
closing in favor of #8908 |
Member
Author
jon-wei
pushed a commit
to jon-wei/druid
that referenced
this pull request
Nov 26, 2019
…pache#8876) * fix sql compatible null handling config work with runtime.properties * fix npe * fix tests * add friendly error * comment, and friendlier still * fix compile * fix from merges
1 task
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This terrible PR modifies
NullHandlingto no longer have a default value since it appears in practice to overwrite the instance injected byNullHandlingModulethroughrequestStaticInjection, causing thedruid.generic.useDefaultValueForNullconfig to not function when it is in aruntime.propertiesor similar file, and only works when specified as an argument. The injected instance was in fact being created, it was just being overwritten immediately by the default value that was being set for it inNullHandling.Since there is no longer a default value, I have added a method that is just awful,
NullHandling.initializeForTests(), which any tests or benchmarks or anything that does not wire up injection must use to avoid null pointer exceptions. This is bad, but seemed better than any alternative I could come up with, becauseNullHandling.replaceWithDefaultis called in a lot of 'hot' places, so introducing anifstatement or method call overhead from using aSupplieror something like that didn't seem worth risking the overhead for the sake of easier to write tests.This PR has:
Key changed/added classes in this PR
NullHandlingNullValueHandlingConfig