public static int getHttpStatusCode(String url) throws Exception { URLConnection connection = connectToUrl(url); long startTime = System.currentTimeMillis(); int status = ((HttpURLConnection) connection).getResponseCode(); // read fully if possible, then close everything, trying to prevent cached threads at server consumeAndCloseQuietly((HttpURLConnection) connection); if (LOG.isDebugEnabled()) LOG.debug("connection to {} ({}ms) gives {}", new Object[] { url, (System.currentTimeMillis()-startTime), status }); return status; }