From 4a64e9d8853de64531e93cfe28a8395dadf3254f Mon Sep 17 00:00:00 2001 From: Zbynek Konecny Date: Fri, 18 Oct 2024 22:31:49 +0200 Subject: [PATCH] Unset config properties: use default value or fail with meaningful exception --- .../jjs/impl/ResolvePermutationDependentValues.java | 10 +++++++++- .../google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml | 1 + .../google/gwt/dev/jjs/test/SystemGetPropertyTest.java | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java index 515e9d5df46..ea3a9ef3434 100644 --- a/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java +++ b/dev/core/src/com/google/gwt/dev/jjs/impl/ResolvePermutationDependentValues.java @@ -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 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. diff --git a/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml b/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml index f307fdb4644..1502cb1789f 100644 --- a/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml +++ b/user/test/com/google/gwt/dev/jjs/SystemGetPropertyTest.gwt.xml @@ -33,4 +33,5 @@ + \ No newline at end of file diff --git a/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java b/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java index 696978a3388..042a3f43008 100644 --- a/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java +++ b/user/test/com/google/gwt/dev/jjs/test/SystemGetPropertyTest.java @@ -36,5 +36,6 @@ public void testBindingProperties() { String expectedResult = "safari".equals(System.getProperty("user.agent")) ? "InSafari" : "NotInSafari"; assertEquals(expectedResult, System.getProperty("someDynamicProperty")); + assertEquals("foo", System.getProperty("configPropertyUnset", "foo")); } }