package io.traintracker.core;

import java.io.IOException;
import java.net.URI;
import java.nio.charset.Charset;

import org.apache.http.HttpEntity;
import org.apache.http.client.config.RequestConfig;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.util.EntityUtils;

import static java.util.Objects.requireNonNull;

abstract class AbstractVoyageFetcher implements VoyageFetcher, AutoCloseable {

	private static final int DEFAULT_TIMEOUT_SECONDS = 30;

	private final CloseableHttpClient httpClient;

	protected AbstractVoyageFetcher(CloseableHttpClient httpClient) {
		this.httpClient = requireNonNull(httpClient);
	}

	protected String loadHtml(URI uri, Charset charset) {
		RequestConfig config = RequestConfig.custom()
				.setConnectionRequestTimeout(DEFAULT_TIMEOUT_SECONDS * 1000)
				.setConnectTimeout(DEFAULT_TIMEOUT_SECONDS * 1000)
				.setSocketTimeout(DEFAULT_TIMEOUT_SECONDS * 1000)
				.build();

		HttpGet request = new HttpGet(uri);
		request.setConfig(config);

		try (CloseableHttpResponse httpResponse = this.httpClient.execute(request)) {
			HttpEntity httpResponseEntity = httpResponse.getEntity();
			return EntityUtils.toString(httpResponseEntity, charset);
		}
		catch (Exception e) {
			throw new RuntimeException(e);
		}
	}

	@Override
	public void close() throws IOException {
		this.httpClient.close();
	}

}

@@ -28,36 +28,8 @@
 e;%0A%0A
-import java.io.IOException;%0A
 impo
@@ -486,23 +486,8 @@
 cher
-, AutoCloseable
  %7B%0A%0A
@@ -1346,90 +1346,6 @@
 %09%7D%0A%0A
-%09@Override%0A%09public void close() throws IOException %7B%0A%09%09this.httpClient.close();%0A%09%7D%0A%0A
 %7D%0A

Remove needless AutoCloseable