Repository: airavata
Updated Branches:
  refs/heads/master e429faafa -> 6fcd3941b


AIRAVATA-2282 notification sort: Prevent int overflow

Instead of returning the difference as a long and casting to an int,
which risks integer overflow, just return 1 or -1 corresponding to the
sign of the difference.


Project: http://git-wip-us.apache.org/repos/asf/airavata/repo
Commit: http://git-wip-us.apache.org/repos/asf/airavata/commit/53b52dcf
Tree: http://git-wip-us.apache.org/repos/asf/airavata/tree/53b52dcf
Diff: http://git-wip-us.apache.org/repos/asf/airavata/diff/53b52dcf

Branch: refs/heads/master
Commit: 53b52dcf1dd1049280c6155ae16ddbccb41e04d2
Parents: e429faa
Author: Marcus Christie <machr...@iu.edu>
Authored: Fri Dec 16 12:29:50 2016 -0500
Committer: Marcus Christie <machr...@iu.edu>
Committed: Fri Dec 16 13:34:30 2016 -0500

----------------------------------------------------------------------
 .../core/experiment/catalog/impl/NotificationRegistry.java         | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/airavata/blob/53b52dcf/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/NotificationRegistry.java
----------------------------------------------------------------------
diff --git 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/NotificationRegistry.java
 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/NotificationRegistry.java
index 3715b7f..9476daf 100644
--- 
a/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/NotificationRegistry.java
+++ 
b/modules/registry/registry-core/src/main/java/org/apache/airavata/registry/core/experiment/catalog/impl/NotificationRegistry.java
@@ -80,7 +80,7 @@ public class NotificationRegistry {
                 
notifications.add(ThriftDataModelConversion.getNotification((NotificationResource)
 e));
             }
         }
-        Collections.sort(notifications, (o1, o2) -> (int) 
(o2.getCreationTime() - o1.getCreationTime()));
+        Collections.sort(notifications, (o1, o2) -> (o2.getCreationTime() - 
o1.getCreationTime()) > 0 ? 1 : -1);
         return notifications;
     }
 

Reply via email to