Fixing NullPointerException when there is no proxy host