Commit 4686b2323a18cce31a05bae0190b7b884734573d

Authored by Volodymyr Babak
1 parent 450026d5

Null pointer fix

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