Source:
<code>protected BufferedImage loadImage(final MfClientHttpRequestFactory requestFactory, final MapfishMapContext transformer) throws Throwable { final Closer closer = Closer.create(); final String baseMetricName = WmsLayer.class.getName() + ".read." + this.imageRequest.getURI().getHost(); try { final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); LOGGER.info("Query the WMS image {}.", this.imageRequest.getURI()); final ClientHttpResponse response = closer.register(this.imageRequest.execute()); Assert.isTrue(response != null, "No response, see error above"); Assert.equals(HttpStatus.OK, response.getStatusCode(), String.format("Http status code for %s " + "was not OK. It was: %s. The response message was: '%s'", this.imageRequest.getURI(), response.getStatusCode(), response.getStatusText())); final List<String> contentType = response.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The WMS image don't return a valid content type header.", this.imageRequest.getURI()); } else if (!contentType.get(0).startsWith("image/")) { byte[] data = new byte[response.getBody().available()]; response.getBody().read(data); <START> LOGGER.debug("We wet a wrong WMS image for {}, content type: {}\nresult:\n{}", <END> this.imageRequest.getURI(), contentType.get(0), new String(data, "UTF-8")); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(response.getBody()); if (image == null) { LOGGER.warn("The WMS image is an image format that can be decoded", this.imageRequest.getURI()); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } else { timerDownload.stop(); } return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } finally { closer.close(); } }</code><technical_language>s/We wet/We get/</technical_language>

Target:
protected BufferedImage loadImage(final MfClientHttpRequestFactory requestFactory, final MapfishMapContext transformer) throws Throwable { final Closer closer = Closer.create(); final String baseMetricName = WmsLayer.class.getName() + ".read." + this.imageRequest.getURI().getHost(); try { final Timer.Context timerDownload = this.registry.timer(baseMetricName).time(); LOGGER.info("Query the WMS image {}.", this.imageRequest.getURI()); final ClientHttpResponse response = closer.register(this.imageRequest.execute()); Assert.isTrue(response != null, "No response, see error above"); Assert.equals(HttpStatus.OK, response.getStatusCode(), String.format("Http status code for %s " + "was not OK. It was: %s. The response message was: '%s'", this.imageRequest.getURI(), response.getStatusCode(), response.getStatusText())); final List<String> contentType = response.getHeaders().get("Content-Type"); if (contentType == null || contentType.size() != 1) { LOGGER.debug("The WMS image don't return a valid content type header.", this.imageRequest.getURI()); } else if (!contentType.get(0).startsWith("image/")) { byte[] data = new byte[response.getBody().available()]; response.getBody().read(data); LOGGER.debug("We get a wrong WMS image for {}, content type: {}\nresult:\n{}", this.imageRequest.getURI(), contentType.get(0), new String(data, "UTF-8")); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } final BufferedImage image = ImageIO.read(response.getBody()); if (image == null) { LOGGER.warn("The WMS image is an image format that can be decoded", this.imageRequest.getURI()); this.registry.counter(baseMetricName + ".error").inc(); return createErrorImage(transformer.getPaintArea()); } else { timerDownload.stop(); } return image; } catch (Throwable e) { this.registry.counter(baseMetricName + ".error").inc(); throw e; } finally { closer.close(); } }