Merge pull request #1268 from charithag/master

Fixed NPE in sending push notifications
revert-70aa11f8
Hasunie 6 years ago committed by GitHub
commit 6fafde1d16
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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