Prevent possible NPEs by filtering null in getAffectedObjects.

Change-Id: I29317f48642cb7d3f4b82080e7aa58dfbe478540