Why not:

    if (conf.getOption("spark.hostPort").isEmpty) {

No that you've added `getOption`. There are a handful of other cases in SparkEnv that do this which could also get patched.