Checking for null when setting URLConnection