Repository: camel Updated Branches: refs/heads/camel-2.19.x 9c9aa099e -> 1a692127f refs/heads/master b710a0790 -> 431c3198d
CAMEL-11559: Work around a NPE in milo 0.1.3 When the sampling interval is unset in the Camel component, then it is passed to milo as 'null'. Which is acceptable to the milo API, however internally milo automatically unboxes the value from 'Double' to 'double' and may run into a NPE by doing so. This patch assures that, although theoretically acceptable, 'null' is never passed in to the Milo API. Signed-off-by: Jens Reimann <jreim...@redhat.com> Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/1a692127 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/1a692127 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/1a692127 Branch: refs/heads/camel-2.19.x Commit: 1a692127f54990e72dcbf1d56f83b0e3cb9df20e Parents: 9c9aa09 Author: Jens Reimann <jreim...@redhat.com> Authored: Wed Jul 19 10:21:33 2017 +0200 Committer: Jens Reimann <jreim...@redhat.com> Committed: Wed Jul 19 10:31:15 2017 +0200 ---------------------------------------------------------------------- .../component/milo/client/internal/SubscriptionManager.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/1a692127/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java ---------------------------------------------------------------------- diff --git a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java index 7502164..877bf08 100644 --- a/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java +++ b/components/camel-milo/src/main/java/org/apache/camel/component/milo/client/internal/SubscriptionManager.java @@ -174,7 +174,12 @@ public class SubscriptionManager { } else { final NodeId nodeId = s.getPartialNodeId().toNodeId(namespaceIndex); final ReadValueId itemId = new ReadValueId(nodeId, AttributeId.Value.uid(), null, QualifiedName.NULL_VALUE); - final MonitoringParameters parameters = new MonitoringParameters(entry.getKey(), s.getSamplingInterval(), null, null, null); + Double samplingInterval = s.getSamplingInterval(); + if (samplingInterval == null) { + // work around a bug (NPE) in Eclipse Milo 0.1.3 + samplingInterval = 0.0; + } + final MonitoringParameters parameters = new MonitoringParameters(entry.getKey(), samplingInterval, null, null, null); items.add(new MonitoredItemCreateRequest(itemId, MonitoringMode.Reporting, parameters)); } }