← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 22207: I18nService. Filtering out null objects before translating collections. Null items might come fro...

 

------------------------------------------------------------
revno: 22207
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2016-03-09 12:35:42 +0100
message:
  I18nService. Filtering out null objects before translating collections. Null items might come from missing sort_order entries in link tables. Guava classes fails early on nulls so this caused the system to crash in certain situations.
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.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-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java	2016-01-04 02:27:49 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/i18n/DefaultI18nService.java	2016-03-09 11:35:42 +0000
@@ -46,6 +46,7 @@
 import java.util.List;
 import java.util.Locale;
 import java.util.Map;
+import java.util.stream.Collectors;
 
 import static org.hisp.dhis.system.util.ReflectionUtils.*;
 
@@ -136,6 +137,8 @@
             return;
         }
 
+        objects = objects.stream().filter( o -> o != null ).collect( Collectors.toList() );
+        
         Map<String, List<Object>> classNameObjectMap = Multimaps.asMap( Multimaps.index( objects, o -> getClassName( o ) ) );
         
         for ( String className : classNameObjectMap.keySet() )