Commit 4686b2323a18cce31a05bae0190b7b884734573d

Authored by Volodymyr Babak
1 parent 450026d5

Null pointer fix

... ... @@ -280,7 +280,8 @@ public class DefaultEdgeNotificationService implements EdgeNotificationService {
280 280 private void processEntity(TenantId tenantId, TransportProtos.EdgeNotificationMsgProto edgeNotificationMsg) {
281 281 ActionType edgeEventActionType = ActionType.valueOf(edgeNotificationMsg.getEdgeEventAction());
282 282 EdgeEventType edgeEventType = EdgeEventType.valueOf(edgeNotificationMsg.getEdgeEventType());
283   - EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(edgeEventType, new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()));
  283 + EntityId entityId = EntityIdFactory.getByEdgeEventTypeAndUuid(edgeEventType,
  284 + new UUID(edgeNotificationMsg.getEntityIdMSB(), edgeNotificationMsg.getEntityIdLSB()));
284 285 ListenableFuture<List<EdgeId>> edgeIdsFuture;
285 286 switch (edgeEventActionType) {
286 287 case ADDED: // used only for USER entity
... ...
... ... @@ -432,7 +432,8 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
432 432 ListenableFuture<List<EntityRelation>> originatorEdgeRelationsFuture =
433 433 relationService.findByToAndTypeAsync(tenantId, entityId, EntityRelation.CONTAINS_TYPE, RelationTypeGroup.EDGE);
434 434 return Futures.transform(originatorEdgeRelationsFuture, originatorEdgeRelations -> {
435   - if (originatorEdgeRelations != null && originatorEdgeRelations.size() > 0) {
  435 + if (originatorEdgeRelations != null && originatorEdgeRelations.size() > 0 &&
  436 + originatorEdgeRelations.get(0).getFrom() != null) {
436 437 return Collections.singletonList(new EdgeId(originatorEdgeRelations.get(0).getFrom().getId()));
437 438 } else {
438 439 return Collections.emptyList();
... ... @@ -444,6 +445,9 @@ public class EdgeServiceImpl extends AbstractEntityService implements EdgeServic
444 445 return convertToEdgeIds(findEdgesByTenantIdAndRuleChainId(tenantId, new RuleChainId(entityId.getId())));
445 446 case USER:
446 447 User userById = userService.findUserById(tenantId, new UserId(entityId.getId()));
  448 + if (userById == null) {
  449 + return Futures.immediateFuture(Collections.emptyList());
  450 + }
447 451 TextPageData<Edge> edges;
448 452 if (userById.getCustomerId() == null || userById.getCustomerId().isNullUid()) {
449 453 edges = findEdgesByTenantId(tenantId, new TextPageLink(Integer.MAX_VALUE));
... ...