Skip to content

Commit 86a922f

Browse files
committed
prevent resolveVariable from returning null
Signed-off-by: Jimmy Tanagra <jcode@tanagra.id.au>
1 parent cd232cb commit 86a922f

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

  • bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/util/preprocessor

bundles/org.openhab.core.model.yaml/src/main/java/org/openhab/core/model/yaml/internal/util/preprocessor/ModelConstructor.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,17 +141,18 @@ public Object construct(@Nullable Node node) {
141141
*
142142
* @param name - variable name in the template
143143
* @param separator - separator in the template, can be :-, -
144-
* @param defaultValue - default value or the error in the template
144+
* @param defaultValue - default value or the error in the template.
145+
* If defaultValue is null, return an empty string.
145146
* @return the value to resolve in the template
146147
*/
147-
private @Nullable String resolveVariable(String name, @Nullable String separator,
148+
private String resolveVariable(String name, @Nullable String separator,
148149
@Nullable String defaultValue) {
149150
String value = variables.get(name);
150151
if (value != null && !value.isEmpty()) {
151152
return value;
152153
}
153154
// variable is either unset or empty
154-
if (separator != null) {
155+
if (separator != null && defaultValue != null) {
155156
if (separator.startsWith(":")) {
156157
if (value == null || value.isEmpty()) {
157158
return defaultValue;

0 commit comments

Comments
 (0)