If `hostPorts` can be null, annotate it as `@Nullable`, otherwise add a null check.