← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 20006: minor NPE check in FormUtils

 

------------------------------------------------------------
revno: 20006
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-09-07 09:24:53 +0700
message:
  minor NPE check in FormUtils
modified:
  dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.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-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2015-08-31 08:23:12 +0000
+++ dhis-2/dhis-web/dhis-web-api/src/main/java/org/hisp/dhis/webapi/utils/FormUtils.java	2015-09-07 02:24:53 +0000
@@ -202,11 +202,9 @@
     private static List<Field> inputFromProgramStageDataElements( List<ProgramStageDataElement> programStageDataElements )
     {
         List<DataElement> dataElements = new ArrayList<>();
-
-        for ( ProgramStageDataElement programStageDataElement : programStageDataElements )
-        {
-            dataElements.add( programStageDataElement.getDataElement() );
-        }
+        programStageDataElements.stream()
+            .filter( programStageDataElement -> programStageDataElement != null && programStageDataElement.getDataElement() != null )
+            .forEach( programStageDataElement -> dataElements.add( programStageDataElement.getDataElement() ) );
 
         return inputFromDataElements( dataElements, new ArrayList<>() );
     }