From 3119f6278b67910b9f874cb6cbb02ca287f41af4 Mon Sep 17 00:00:00 2001 From: Christian Menard Date: Thu, 9 Mar 2023 12:16:03 +0100 Subject: [PATCH] Fix validation of target properties This includes two fixes: - Use `equals()` to check equality of strings - Fix a hidden nullpointer exception in `validateRos2TargetProperties` --- org.lflang/src/org/lflang/validation/LFValidator.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/org.lflang/src/org/lflang/validation/LFValidator.java b/org.lflang/src/org/lflang/validation/LFValidator.java index f53987e2b5..b2c60bd07f 100644 --- a/org.lflang/src/org/lflang/validation/LFValidator.java +++ b/org.lflang/src/org/lflang/validation/LFValidator.java @@ -1034,7 +1034,7 @@ public void checkTargetProperties(KeyValuePairs targetProperties) { private KeyValuePair getKeyValuePair(KeyValuePairs targetProperties, TargetProperty property) { List properties = targetProperties.getPairs().stream() - .filter(pair -> pair.getName() == property.description) + .filter(pair -> pair.getName().equals(property.description)) .toList(); assert (properties.size() <= 1); return properties.size() > 0 ? properties.get(0) : null; @@ -1128,7 +1128,7 @@ private void validateSchedulerTargetProperties(KeyValuePairs targetProperties) { private void validateRos2TargetProperties(KeyValuePairs targetProperties) { KeyValuePair ros2 = getKeyValuePair(targetProperties, TargetProperty.ROS2); KeyValuePair ros2Dependencies = getKeyValuePair(targetProperties, TargetProperty.ROS2_DEPENDENCIES); - if (!ASTUtils.toBoolean(ros2.getValue()) && ros2Dependencies != null) { + if (ros2Dependencies != null && (ros2 == null || !ASTUtils.toBoolean(ros2.getValue()))) { warning( "Ignoring ros2-dependencies as ros2 compilation is disabled", ros2Dependencies,