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

Revert "Unset config properties: System.getProperty should return default value or null" #10094

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -141,17 +141,6 @@ public List<String> getStrings(String key) {
return properties.get(key);
}

/**
* Returns all the values of a multi-valued configuration property, or null
* if not found.
*
* <p>A single-valued and unset configuration property will be returned as a list
* containing one null.
*/
public List<String> getStringsOrNull(String key) {
return properties.get(key);
}

/**
* Reads a configuration property as a comma-separated list of strings.
* It may be a single-valued or multi-valued property. If multi-valued,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;

/**
Expand Down Expand Up @@ -75,28 +74,21 @@ public void endVisit(JPermutationDependentValue x, Context ctx) {
}

private JExpression propertyValueExpression(JPermutationDependentValue x) {
List<String> propertyValues = props.getConfigurationProperties()
.getStringsOrNull(x.getRequestedValue());
if (propertyValues != null) {
List<String> propertyValues = props.getConfigurationProperties().getStrings(x.getRequestedValue());

String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").join(propertyValues);

if (propertyValue != null) {
// It is a configuration property.
// If no values are set, propertyValues is either empty (multivalued properties)
// or contains a single null (other properties).
if (propertyValues.stream().anyMatch(Objects::nonNull)) {
return program.getLiteral(x.getSourceInfo(),
Joiner.on(",").skipNulls().join(propertyValues));
}
if (x.getDefaultValueExpression() != null) {
return x.getDefaultValueExpression();
}
return program.getLiteralNull();
return program.getLiteral(x.getSourceInfo(), propertyValue);
}

if (isSoftPermutationProperty(x.getRequestedValue())) {
JMethod method = getOrCreateSoftPropertyMethod(x.getSourceInfo(), x.getRequestedValue());
return new JMethodCall(x.getSourceInfo(), null, method);
}

String propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue());
propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue());

if (propertyValue != null) {
return program.getLiteral(x.getSourceInfo(), propertyValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,4 @@
<set-property name="someOtherDynamicProperty" value="blue">
<when-property-is name="collapsedProperty" value="two"/>
</set-property>
<define-configuration-property name="configPropertyUnset" is-multi-valued="false"/>
<define-configuration-property name="multivaluedConfigPropertyUnset" is-multi-valued="true"/>
</module>
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,5 @@ public void testBindingProperties() {
String expectedResult = "safari".equals(System.getProperty("user.agent")) ?
"InSafari" : "NotInSafari";
assertEquals(expectedResult, System.getProperty("someDynamicProperty"));
assertEquals("foo", System.getProperty("configPropertyUnset", "foo"));
assertNull(System.getProperty("configPropertyUnset"));
assertEquals("foo", System.getProperty("multivaluedConfigPropertyUnset", "foo"));
assertNull(System.getProperty("multivaluedConfigPropertyUnset"));
}
}