← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13888: NPE checks in AttributeValueSortOrderComparator

 

------------------------------------------------------------
revno: 13888
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-01-29 10:35:59 +0700
message:
  NPE checks in AttributeValueSortOrderComparator
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/comparator/AttributeValueSortOrderComparator.java


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/comparator/AttributeValueSortOrderComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/comparator/AttributeValueSortOrderComparator.java	2014-01-23 09:32:35 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/attribute/comparator/AttributeValueSortOrderComparator.java	2014-01-29 03:35:59 +0000
@@ -43,6 +43,11 @@
     @Override
     public int compare( AttributeValue o1, AttributeValue o2 )
     {
+        if ( o1 == null || o2 == null || o1.getAttribute() == null || o2.getAttribute() == null )
+        {
+            return 0;
+        }
+
         if ( o1.getAttribute().getSortOrder() == null || o2.getAttribute().getSortOrder() == 0 )
         {
             return o1.getAttribute().getName().compareTo( o2.getAttribute().getName() );