import com.google.common.collect.ImmutableList;
import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
import java.util.stream.Collectors;
import javax.annotation.concurrent.GuardedBy;
import javax.annotation.concurrent.ThreadSafe;
@Override
public List<BGPRIBState> getRibStats() {
synchronized (this.bgpRibStates) {
- return ImmutableList.copyOf(this.bgpRibStates.stream().map(BGPRIBStateConsumer::getRIBState)
- .collect(Collectors.toList()));
+ return ImmutableList.copyOf(this.bgpRibStates
+ .stream()
+ .map(BGPRIBStateConsumer::getRIBState)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList()));
}
}
@Override
public List<BGPPeerState> getPeerStats() {
synchronized (this.bgpPeerStates) {
- return ImmutableList.copyOf(this.bgpPeerStates.stream().map(BGPPeerStateConsumer::getPeerState)
- .collect(Collectors.toList()));
+ return ImmutableList.copyOf(this.bgpPeerStates
+ .stream()
+ .map(BGPPeerStateConsumer::getPeerState)
+ .filter(Objects::nonNull)
+ .collect(Collectors.toList()));
}
}