← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 9146: Made the IdentifiableObjectNameComparator null safe

 

------------------------------------------------------------
revno: 9146
committer: Lars Helge Øverland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2012-11-28 15:20:45 +0100
message:
  Made the IdentifiableObjectNameComparator null safe
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/IdentifiableObjectNameComparator.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/common/comparator/IdentifiableObjectNameComparator.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/IdentifiableObjectNameComparator.java	2012-01-25 19:22:00 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/common/comparator/IdentifiableObjectNameComparator.java	2012-11-28 14:20:45 +0000
@@ -41,6 +41,11 @@
     
     public int compare( IdentifiableObject object0, IdentifiableObject object1 )
     {
-        return object0.getDisplayName().compareToIgnoreCase( object1.getDisplayName() );
+        if ( object0 == null )
+        {
+            return object1 == null ? 0 : -1;
+        }
+        
+        return object1 == null ? 1 : object0.getDisplayName().compareToIgnoreCase( object1.getDisplayName() );
     }
 }