Fixed NPE in sending push notifications

4.x.x
Charitha Goonetilleke 6 years ago
parent 8eaa7c6698
commit 128b5f64aa

@ -86,11 +86,18 @@ public class PushNotificationSchedulerTask implements Runnable {
NotificationStrategy notificationStrategy = provider.getNotificationStrategyByDeviceType NotificationStrategy notificationStrategy = provider.getNotificationStrategyByDeviceType
(operationMapping.getDeviceIdentifier().getType()); (operationMapping.getDeviceIdentifier().getType());
// Send the push notification on given strategy // Send the push notification on given strategy
notificationStrategy.execute(new NotificationContext(operationMapping.getDeviceIdentifier(), if (notificationStrategy != null) {
provider.getOperation(operationMapping.getDeviceIdentifier().getType(), operationMapping notificationStrategy.execute(new NotificationContext(operationMapping.getDeviceIdentifier(),
.getOperationId()))); provider.getOperation(operationMapping.getDeviceIdentifier().getType(), operationMapping
operationMapping.setPushNotificationStatus(Operation.PushNotificationStatus.COMPLETED); .getOperationId())));
operationsCompletedList.add(operationMapping); operationMapping.setPushNotificationStatus(Operation.PushNotificationStatus.COMPLETED);
operationsCompletedList.add(operationMapping);
} else {
if (log.isDebugEnabled()) {
log.debug("Tenant '" + PrivilegedCarbonContext.getThreadLocalCarbonContext()
.getTenantDomain() + "' does not have push notification strategy.");
}
}
} catch (DeviceManagementException e) { } catch (DeviceManagementException e) {
log.error("Error occurred while getting notification strategy for operation mapping " + log.error("Error occurred while getting notification strategy for operation mapping " +
operationMapping.getDeviceIdentifier().getType(), e); operationMapping.getDeviceIdentifier().getType(), e);
@ -121,7 +128,7 @@ public class PushNotificationSchedulerTask implements Runnable {
log.debug("Push notification job running completed."); log.debug("Push notification job running completed.");
} }
} catch (Throwable cause) { } catch (Throwable cause) {
log.error("PushNotificationSchedulerTask failed due to " + cause); log.error("PushNotificationSchedulerTask failed due to " + cause.getMessage(), cause);
} }
} }
} }

Loading…
Cancel
Save