Merge pull request #19306 from javanna/fix/default_sniffer_scheme

Rest Client: HostsSniffer to set http as default scheme
This commit is contained in:
Luca Cavanna 2016-07-08 10:57:59 +02:00 committed by GitHub
commit 64880ca4ed
2 changed files with 6 additions and 2 deletions

View File

@ -156,7 +156,7 @@ public class HostsSniffer {
private final RestClient restClient;
private long sniffRequestTimeoutMillis = DEFAULT_SNIFF_REQUEST_TIMEOUT;
private Scheme scheme;
private Scheme scheme = Scheme.HTTP;
private Builder(RestClient restClient) {
Objects.requireNonNull(restClient, "restClient cannot be null");

View File

@ -89,7 +89,11 @@ public class HostsSnifferTests extends RestClientTestCase {
public void testSniffNodes() throws IOException, URISyntaxException {
HttpHost httpHost = new HttpHost(httpServer.getAddress().getHostString(), httpServer.getAddress().getPort());
try (RestClient restClient = RestClient.builder(httpHost).build()) {
HostsSniffer sniffer = new HostsSniffer(restClient, sniffRequestTimeout, scheme);
HostsSniffer.Builder builder = HostsSniffer.builder(restClient).setSniffRequestTimeoutMillis(sniffRequestTimeout);
if (scheme != HostsSniffer.Scheme.HTTP || randomBoolean()) {
builder.setScheme(scheme);
}
HostsSniffer sniffer = builder.build();
try {
List<HttpHost> sniffedHosts = sniffer.sniffHosts();
if (sniffResponse.isFailure) {