Solution is if (servletConnection != null) URLConnectionUtils.closeQuietly(servletConnection);, guard the call with a test,
or even better, take into account in closeQuietly that the input parameter may be null.