Source:
<code>public void poll() { try { if (!started) { return; } ConcurrentHashMap<String, DruidDataSource> newDataSources = new ConcurrentHashMap<String, DruidDataSource>(); log.debug("Starting polling of segment table"); List<DataSegment> segments = dbi.withHandle( new HandleCallback<List<DataSegment>>() { @Override public List<DataSegment> withHandle(Handle handle) throws Exception { return handle.createQuery( String.format("SELECT payload FROM %s WHERE used=true", getSegmentsTable()) ) .map( new ResultSetMapper<DataSegment>() { @Override public DataSegment map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { return jsonMapper.readValue(r.getBytes("payload"), DataSegment.class); } catch (IOException e) { log.makeAlert(e, "Failed to read segment from db."); return null; } } } ) .list(); } } ); if (segments == null || segments.isEmpty()) { log.warn("No segments found in the database!"); return; } segments = new ArrayList<>( Collections2.filter( <START> segments, new Predicate<DataSegment>() <END> { @Override public boolean apply(DataSegment input) { return input != null; } } ) ); log.info("Polled and found %,d segments in the database", segments.size()); for (final DataSegment segment : segments) { String datasourceName = segment.getDataSource(); DruidDataSource dataSource = newDataSources.get(datasourceName); if (dataSource == null) { dataSource = new DruidDataSource( datasourceName, ImmutableMap.of("created", new DateTime().toString()) ); Object shouldBeNull = newDataSources.put( datasourceName, dataSource ); if (shouldBeNull != null) { log.warn( "Just put key[%s] into dataSources and what was there wasn't null!? It was[%s]", datasourceName, shouldBeNull ); } } if (!dataSource.getSegments().contains(segment)) { dataSource.addSegment(segment.getIdentifier(), segment); } } synchronized (lock) { if (started) { dataSources.set(newDataSources); } } } catch (Exception e) { log.makeAlert(e, "Problem polling DB.").emit(); } }</code><technical_language>simply Predicates.notNull()</technical_language>

Target:
public void poll() { try { if (!started) { return; } ConcurrentHashMap<String, DruidDataSource> newDataSources = new ConcurrentHashMap<String, DruidDataSource>(); log.debug("Starting polling of segment table"); final List<DataSegment> segments = dbi.withHandle( new HandleCallback<List<DataSegment>>() { @Override public List<DataSegment> withHandle(Handle handle) throws Exception { return handle.createQuery( String.format("SELECT payload FROM %s WHERE used=true", getSegmentsTable()) ) .map( new ResultSetMapper<DataSegment>() { @Override public DataSegment map(int index, ResultSet r, StatementContext ctx) throws SQLException { try { return jsonMapper.readValue(r.getBytes("payload"), DataSegment.class); } catch (IOException e) { log.makeAlert(e, "Failed to read segment from db."); return null; } } } ) .list(); } } ); if (segments == null || segments.isEmpty()) { log.warn("No segments found in the database!"); return; } final Collection<DataSegment> segmentsFinal = Collections2.filter( segments, Predicates.notNull() ); log.info("Polled and found %,d segments in the database", segments.size()); for (final DataSegment segment : segmentsFinal) { String datasourceName = segment.getDataSource(); DruidDataSource dataSource = newDataSources.get(datasourceName); if (dataSource == null) { dataSource = new DruidDataSource( datasourceName, ImmutableMap.of("created", new DateTime().toString()) ); Object shouldBeNull = newDataSources.put( datasourceName, dataSource ); if (shouldBeNull != null) { log.warn( "Just put key[%s] into dataSources and what was there wasn't null!? It was[%s]", datasourceName, shouldBeNull ); } } if (!dataSource.getSegments().contains(segment)) { dataSource.addSegment(segment.getIdentifier(), segment); } } synchronized (lock) { if (started) { dataSources.set(newDataSources); } } } catch (Exception e) { log.makeAlert(e, "Problem polling DB.").emit(); } }