Skip to content

Commit a0cd441

Browse files
authored
Revert "Unset config properties: System.getProperty should return default value or null" (#10094)
Tests are currently failing, need to be re-checked. Reverts #10013
1 parent 8e04c91 commit a0cd441

File tree

4 files changed

+7
-32
lines changed

4 files changed

+7
-32
lines changed

dev/core/src/com/google/gwt/dev/cfg/ConfigurationProperties.java

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,6 @@ public List<String> getStrings(String key) {
141141
return properties.get(key);
142142
}
143143

144-
/**
145-
* Returns all the values of a multi-valued configuration property, or null
146-
* if not found.
147-
*
148-
* <p>A single-valued and unset configuration property will be returned as a list
149-
* containing one null.
150-
*/
151-
public List<String> getStringsOrNull(String key) {
152-
return properties.get(key);
153-
}
154-
155144
/**
156145
* Reads a configuration property as a comma-separated list of strings.
157146
* It may be a single-valued or multi-valued property. If multi-valued,

dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
import java.util.Collection;
4848
import java.util.List;
4949
import java.util.Map;
50-
import java.util.Objects;
5150
import java.util.Set;
5251

5352
/**
@@ -75,28 +74,21 @@ public void endVisit(JPermutationDependentValue x, Context ctx) {
7574
}
7675

7776
private JExpression propertyValueExpression(JPermutationDependentValue x) {
78-
List<String> propertyValues = props.getConfigurationProperties()
79-
.getStringsOrNull(x.getRequestedValue());
80-
if (propertyValues != null) {
77+
List<String> propertyValues = props.getConfigurationProperties().getStrings(x.getRequestedValue());
78+
79+
String propertyValue = propertyValues.isEmpty() ? null : Joiner.on(",").join(propertyValues);
80+
81+
if (propertyValue != null) {
8182
// It is a configuration property.
82-
// If no values are set, propertyValues is either empty (multivalued properties)
83-
// or contains a single null (other properties).
84-
if (propertyValues.stream().anyMatch(Objects::nonNull)) {
85-
return program.getLiteral(x.getSourceInfo(),
86-
Joiner.on(",").skipNulls().join(propertyValues));
87-
}
88-
if (x.getDefaultValueExpression() != null) {
89-
return x.getDefaultValueExpression();
90-
}
91-
return program.getLiteralNull();
83+
return program.getLiteral(x.getSourceInfo(), propertyValue);
9284
}
9385

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

99-
String propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue());
91+
propertyValue = commonPropertyAndBindingInfo.getPropertyValue(x.getRequestedValue());
10092

10193
if (propertyValue != null) {
10294
return program.getLiteral(x.getSourceInfo(), propertyValue);

user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,4 @@
3333
<set-property name="someOtherDynamicProperty" value="blue">
3434
<when-property-is name="collapsedProperty" value="two"/>
3535
</set-property>
36-
<define-configuration-property name="configPropertyUnset" is-multi-valued="false"/>
37-
<define-configuration-property name="multivaluedConfigPropertyUnset" is-multi-valued="true"/>
3836
</module>

user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,5 @@ public void testBindingProperties() {
3636
String expectedResult = "safari".equals(System.getProperty("user.agent")) ?
3737
"InSafari" : "NotInSafari";
3838
assertEquals(expectedResult, System.getProperty("someDynamicProperty"));
39-
assertEquals("foo", System.getProperty("configPropertyUnset", "foo"));
40-
assertNull(System.getProperty("configPropertyUnset"));
41-
assertEquals("foo", System.getProperty("multivaluedConfigPropertyUnset", "foo"));
42-
assertNull(System.getProperty("multivaluedConfigPropertyUnset"));
4339
}
4440
}

0 commit comments

Comments
 (0)