+ return;
+ }
+
+ if (getResponse.getStatusLine().getStatusCode() != HttpServletResponse.SC_OK) {
+ response.sendRedirect("badurl.jspx");
+ return;
+ }
+ if (!isSizeOK(getResponse)) {
+ response.sendRedirect("badimage.jspx");
+ return;
+ }
+
+ log.info("Decoding " + imageURI);
+ HttpEntity entity = getResponse.getEntity();
+ InputStream is = entity.getContent();
+ try {
+ processStream(is, request, response);
+ } finally {
+ entity.consumeContent();
+ is.close();
+ // Hmm, trying harder here to avoid the CLOSE_WAIT problem:
+ connectionManager.closeExpiredConnections();
+ connectionManager.closeIdleConnections(0L, TimeUnit.MILLISECONDS);