-
Notifications
You must be signed in to change notification settings - Fork 381
Unset config properties: System.getProperty should return default value or null
#10013
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -47,6 +47,7 @@ | |
| import java.util.Collection; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| import java.util.Objects; | ||
| import java.util.Set; | ||
|
|
||
| /** | ||
|
|
@@ -76,7 +77,14 @@ public void endVisit(JPermutationDependentValue x, Context ctx) { | |
| private JExpression propertyValueExpression(JPermutationDependentValue x) { | ||
| List<String> propertyValues = props.getConfigurationProperties().getStrings(x.getRequestedValue()); | ||
|
|
||
| String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").join(propertyValues); | ||
| if (!propertyValues.isEmpty() && propertyValues.stream().allMatch(Objects::isNull)) { | ||
| if (x.getDefaultValueExpression() != null) { | ||
| return x.getDefaultValueExpression(); | ||
| } | ||
| throw new InternalCompilerException("No default set for configuration property '" | ||
|
||
| + x.getRequestedValue() + "'"); | ||
| } | ||
| String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").skipNulls().join(propertyValues); | ||
|
||
|
|
||
| if (propertyValue != null) { | ||
| // It is a configuration property. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I struggle with this distinction every time I try to get back into this code and clean it up - could you add a comment here explaining why we sometimes get
[]and sometimes[null]? I think it is signalling (badly, incompletely) that this config property is only permitted to have a single value, but there is no distinction here between "multi-valued with one value" and "single valued and set", so I'm not sure why it matters... Also there is no distinction between "multivalued and unset" and "undefined key", which seems even more egregious.At least if we keep that confusing behavior, a comment would help to clarify as to why we even do it this way.