You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@usergrid.apache.org by sf...@apache.org on 2014/09/08 17:50:56 UTC

[1/2] git commit: add null check after test

Repository: incubator-usergrid
Updated Branches:
  refs/heads/two-dot-o 3b73cec8a -> e1ddd47c3


add null check after test


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/1f1b264a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/1f1b264a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/1f1b264a

Branch: refs/heads/two-dot-o
Commit: 1f1b264a795e19bf707745525ecfed575bf649d4
Parents: 3b73cec
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 8 09:12:58 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 8 09:12:58 2014 -0600

----------------------------------------------------------------------
 .../services/notifications/apns/NotificationsServiceIT.java    | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/1f1b264a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
----------------------------------------------------------------------
diff --git a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
index 13cd29f..cfa5dac 100644
--- a/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
+++ b/stack/services/src/test/java/org/apache/usergrid/services/notifications/apns/NotificationsServiceIT.java
@@ -136,8 +136,10 @@ public class NotificationsServiceIT extends AbstractServiceNotificationIT {
 
     @After
     public void after() throws Exception {
-        listener.stop();
-        listener = null;
+        if(listener != null) {
+            listener.stop();
+            listener = null;
+        }
     }
 
     @Test


[2/2] git commit: adding notification expiration message

Posted by sf...@apache.org.
adding notification expiration message


Project: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/commit/e1ddd47c
Tree: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/tree/e1ddd47c
Diff: http://git-wip-us.apache.org/repos/asf/incubator-usergrid/diff/e1ddd47c

Branch: refs/heads/two-dot-o
Commit: e1ddd47c3762cec531f5ba778d44445a06d633e8
Parents: 1f1b264
Author: Shawn Feldman <sf...@apache.org>
Authored: Mon Sep 8 09:34:10 2014 -0600
Committer: Shawn Feldman <sf...@apache.org>
Committed: Mon Sep 8 09:34:10 2014 -0600

----------------------------------------------------------------------
 .../notifications/apns/APNsAdapter.java         | 26 +++++++++++---------
 1 file changed, 15 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-usergrid/blob/e1ddd47c/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
----------------------------------------------------------------------
diff --git a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
index ded9ac7..82cd4b9 100644
--- a/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
+++ b/stack/services/src/main/java/org/apache/usergrid/services/notifications/apns/APNsAdapter.java
@@ -102,10 +102,6 @@ public class APNsAdapter implements ProviderAdapter {
     public void sendNotification(String providerId, Notifier notifier,
             Object payload, Notification notification, TaskTracker tracker)
             throws Exception {
-        if(isMock(notifier)){
-            tracker.completed("Mocked!");
-            return;
-        }
         APNsNotification apnsNotification = APNsNotification.create(providerId, payload.toString(), notification, tracker);
         PushManager<SimpleApnsPushNotification> pushManager = getPushManager(notifier);
         try {
@@ -168,27 +164,35 @@ public class APNsAdapter implements ProviderAdapter {
 
     //cache to retrieve push manager, cached per notifier, so many notifications will get same push manager
     private static LoadingCache<Notifier, PushManager<SimpleApnsPushNotification>> apnsServiceMap = CacheBuilder
-            .newBuilder().expireAfterAccess(10, TimeUnit.MINUTES)
+            .newBuilder()
+            .expireAfterAccess(10, TimeUnit.MINUTES)
             .removalListener(new RemovalListener<Notifier, PushManager<SimpleApnsPushNotification>>() {
                 @Override
                 public void onRemoval(
                         RemovalNotification<Notifier, PushManager<SimpleApnsPushNotification>> notification) {
                     try {
                         PushManager<SimpleApnsPushNotification> manager = notification.getValue();
-                        if(!manager.isShutDown()){
-                            notification.getValue().shutdown();
+                        if (!manager.isShutDown()) {
+                            List<SimpleApnsPushNotification> notifications = manager.shutdown(3000);
+                            for (SimpleApnsPushNotification notification1 : notifications) {
+                                try {
+                                    ((APNsNotification) notification1).messageSendFailed(new Exception("Cache Expired: Shutting down sender"));
+                                }catch (Exception e){
+                                    logger.error("Failed to mark notification",e);
+                                }
+                            }
                         }
                     } catch (Exception ie) {
-                        logger.error("Failed to shutdown from cache",ie);
+                        logger.error("Failed to shutdown from cache", ie);
                     }
                 }
             }).build(new CacheLoader<Notifier, PushManager<SimpleApnsPushNotification>>() {
                 @Override
                 public PushManager<SimpleApnsPushNotification> load(Notifier notifier) {
-                    try{
+                    try {
                         return createApnsService(notifier);
-                    }catch (KeyStoreException ke){
-                        logger.error("Could not instantiate pushmanager",ke);
+                    } catch (KeyStoreException ke) {
+                        logger.error("Could not instantiate pushmanager", ke);
                         return null;
                     }
                 }