Commit e1109a32107fbf0a9e2fb6320e2819e6826a2083

Authored by Andrew Shvayka
1 parent f45ba17f

Check for NPE

1 1 /**
2 2 * Copyright © 2016-2018 The Thingsboard Authors
3   - *
  3 + * <p>
4 4 * Licensed under the Apache License, Version 2.0 (the "License");
5 5 * you may not use this file except in compliance with the License.
6 6 * You may obtain a copy of the License at
7   - *
8   - * http://www.apache.org/licenses/LICENSE-2.0
9   - *
  7 + * <p>
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + * <p>
10 10 * Unless required by applicable law or agreed to in writing, software
11 11 * distributed under the License is distributed on an "AS IS" BASIS,
12 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
... ... @@ -166,7 +166,7 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio
166 166
167 167 private SubscriptionState getUpdatedSubscriptionState(EntityId entityId, SubscriptionState sub, EntityView entityView) {
168 168 Map<String, Long> keyStates;
169   - if(sub.isAllKeys()) {
  169 + if (sub.isAllKeys()) {
170 170 keyStates = entityView.getKeys().getTimeseries().stream().collect(Collectors.toMap(k -> k, k -> 0L));
171 171 } else {
172 172 keyStates = sub.getKeyStates().entrySet()
... ... @@ -618,7 +618,9 @@ public class DefaultTelemetrySubscriptionService implements TelemetrySubscriptio
618 618 builder.setEntityId(sub.getEntityId().getId().toString());
619 619 builder.setType(sub.getType().name());
620 620 builder.setAllKeys(sub.isAllKeys());
621   - builder.setScope(sub.getScope());
  621 + if (sub.getScope() != null) {
  622 + builder.setScope(sub.getScope());
  623 + }
622 624 sub.getKeyStates().entrySet().forEach(e -> builder.addKeyStates(
623 625 ClusterAPIProtos.SubscriptionKetStateProto.newBuilder().setKey(e.getKey()).setTs(e.getValue()).build()));
624 626 rpcService.tell(address, ClusterAPIProtos.MessageType.CLUSTER_TELEMETRY_SUBSCRIPTION_CREATE_MESSAGE, builder.build().toByteArray());
... ...