diff options
author | Anton Tananaev <anton@traccar.org> | 2024-07-05 08:49:09 -0700 |
---|---|---|
committer | Anton Tananaev <anton@traccar.org> | 2024-07-05 08:49:09 -0700 |
commit | 99b1436fbfb8c367808a9260d18e845c997b68fc (patch) | |
tree | 304974bcf1ccc031c8fb6aabc5bc1c554cdaab9d /src/main/java/org/traccar/handler | |
parent | 17d6db44d6a7f6beacb1a73594d96430063e3d33 (diff) | |
download | trackermap-server-99b1436fbfb8c367808a9260d18e845c997b68fc.tar.gz trackermap-server-99b1436fbfb8c367808a9260d18e845c997b68fc.tar.bz2 trackermap-server-99b1436fbfb8c367808a9260d18e845c997b68fc.zip |
Clear attribute on null result
Diffstat (limited to 'src/main/java/org/traccar/handler')
-rw-r--r-- | src/main/java/org/traccar/handler/ComputedAttributesHandler.java | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java index d286866a5..b7d7a5ed5 100644 --- a/src/main/java/org/traccar/handler/ComputedAttributesHandler.java +++ b/src/main/java/org/traccar/handler/ComputedAttributesHandler.java @@ -146,14 +146,9 @@ public class ComputedAttributesHandler extends BasePositionHandler { .collect(Collectors.toUnmodifiableList()); for (Attribute attribute : attributes) { if (attribute.getAttribute() != null) { - Object result = null; try { - result = computeAttribute(attribute, position); - } catch (JexlException error) { - LOGGER.warn("Attribute computation error", error); - } - if (result != null) { - try { + Object result = computeAttribute(attribute, position); + if (result != null) { switch (attribute.getAttribute()) { case "valid": position.setValid((Boolean) result); @@ -194,9 +189,13 @@ public class ComputedAttributesHandler extends BasePositionHandler { } break; } - } catch (ClassCastException error) { - LOGGER.warn("Attribute cast error", error); + } else { + position.getAttributes().remove(attribute.getAttribute()); } + } catch (JexlException error) { + LOGGER.warn("Attribute computation error", error); + } catch (ClassCastException error) { + LOGGER.warn("Attribute cast error", error); } } } |