mirror of https://github.com/apache/druid.git
Making StatusResponseHandler singleton and fixing all its instantiation invocations (#7969)
* Making StatusResponseHandler singleton and fixing all its instantiation invocations * Using StatusResponseHandler.getInstance() where applicable
This commit is contained in:
parent
0aabeb4b1a
commit
6701dc08fe
|
@ -22,17 +22,22 @@ package org.apache.druid.java.util.http.client.response;
|
|||
import org.jboss.netty.handler.codec.http.HttpChunk;
|
||||
import org.jboss.netty.handler.codec.http.HttpResponse;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class StatusResponseHandler implements HttpResponseHandler<StatusResponseHolder, StatusResponseHolder>
|
||||
{
|
||||
private final Charset charset;
|
||||
|
||||
public StatusResponseHandler(Charset charset)
|
||||
private static final StatusResponseHandler INSTANCE = new StatusResponseHandler();
|
||||
|
||||
private StatusResponseHandler()
|
||||
{
|
||||
this.charset = charset;
|
||||
}
|
||||
|
||||
public static StatusResponseHandler getInstance()
|
||||
{
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +46,7 @@ public class StatusResponseHandler implements HttpResponseHandler<StatusResponse
|
|||
return ClientResponse.unfinished(
|
||||
new StatusResponseHolder(
|
||||
response.getStatus(),
|
||||
new StringBuilder(response.getContent().toString(charset))
|
||||
new StringBuilder(response.getContent().toString(StandardCharsets.UTF_8))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -59,7 +64,7 @@ public class StatusResponseHandler implements HttpResponseHandler<StatusResponse
|
|||
return ClientResponse.finished(null);
|
||||
}
|
||||
|
||||
builder.append(chunk.getContent().toString(charset));
|
||||
builder.append(chunk.getContent().toString(StandardCharsets.UTF_8));
|
||||
return response;
|
||||
}
|
||||
|
||||
|
|
|
@ -97,7 +97,7 @@ public class FriendlyServersTest
|
|||
final StatusResponseHolder response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
Assert.assertEquals(200, response.getStatus().getCode());
|
||||
|
@ -156,7 +156,7 @@ public class FriendlyServersTest
|
|||
final StatusResponseHolder response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", serverSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
Assert.assertEquals(200, response.getStatus().getCode());
|
||||
|
@ -213,7 +213,7 @@ public class FriendlyServersTest
|
|||
HttpMethod.GET,
|
||||
new URL(StringUtils.format("https://localhost:%d/", sslConnector.getLocalPort()))
|
||||
),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get().getStatus();
|
||||
Assert.assertEquals(404, status.getCode());
|
||||
}
|
||||
|
@ -226,7 +226,7 @@ public class FriendlyServersTest
|
|||
HttpMethod.GET,
|
||||
new URL(StringUtils.format("https://127.0.0.1:%d/", sslConnector.getLocalPort()))
|
||||
),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
Throwable ea = null;
|
||||
|
@ -249,7 +249,7 @@ public class FriendlyServersTest
|
|||
HttpMethod.GET,
|
||||
new URL(StringUtils.format("https://localhost:%d/", sslConnector.getLocalPort()))
|
||||
),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
Throwable eb = null;
|
||||
|
@ -285,7 +285,7 @@ public class FriendlyServersTest
|
|||
final HttpResponseStatus status = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL("https://httpbin.org/get")),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get().getStatus();
|
||||
|
||||
Assert.assertEquals(200, status.getCode());
|
||||
|
@ -296,7 +296,7 @@ public class FriendlyServersTest
|
|||
.go(
|
||||
new Request(HttpMethod.POST, new URL("https://httpbin.org/post"))
|
||||
.setContent(new byte[]{'a', 'b', 'c', 1, 2, 3}),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get().getStatus();
|
||||
|
||||
Assert.assertEquals(200, status.getCode());
|
||||
|
|
|
@ -42,7 +42,6 @@ import java.io.OutputStream;
|
|||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
@ -158,7 +157,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> future = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
Throwable e = null;
|
||||
|
@ -186,7 +185,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> future = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", silentServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8),
|
||||
StatusResponseHandler.getInstance(),
|
||||
new Duration(100L)
|
||||
);
|
||||
|
||||
|
@ -219,7 +218,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", silentServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
Throwable e = null;
|
||||
|
@ -247,7 +246,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", closingServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
Throwable e = null;
|
||||
try {
|
||||
|
@ -276,7 +275,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", closingServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
Throwable e = null;
|
||||
|
@ -311,7 +310,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("http://localhost:%d/", echoServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
expectedException.expect(ExecutionException.class);
|
||||
|
@ -335,7 +334,7 @@ public class JankyServersTest
|
|||
final ListenableFuture<StatusResponseHolder> response = client
|
||||
.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("https://localhost:%d/", echoServerSocket.getLocalPort()))),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
|
||||
expectedException.expect(ExecutionException.class);
|
||||
|
|
|
@ -92,7 +92,6 @@ import javax.annotation.Nullable;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
|
@ -129,7 +128,6 @@ import java.util.concurrent.TimeUnit;
|
|||
public class RemoteTaskRunner implements WorkerTaskRunner, TaskLogStreamer
|
||||
{
|
||||
private static final EmittingLogger log = new EmittingLogger(RemoteTaskRunner.class);
|
||||
private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
private static final Joiner JOINER = Joiner.on("/");
|
||||
|
||||
private final ObjectMapper jsonMapper;
|
||||
|
@ -564,7 +562,7 @@ public class RemoteTaskRunner implements WorkerTaskRunner, TaskLogStreamer
|
|||
url = TaskRunnerUtils.makeWorkerURL(zkWorker.getWorker(), "/druid/worker/v1/task/%s/shutdown", taskId);
|
||||
final StatusResponseHolder response = httpClient.go(
|
||||
new Request(HttpMethod.POST, url),
|
||||
RESPONSE_HANDLER,
|
||||
StatusResponseHandler.getInstance(),
|
||||
shutdownTimeout
|
||||
).get();
|
||||
|
||||
|
|
|
@ -36,7 +36,6 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
|||
|
||||
import javax.inject.Inject;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
public class WorkerTaskRunnerQueryAdapter
|
||||
|
@ -95,7 +94,7 @@ public class WorkerTaskRunnerQueryAdapter
|
|||
try {
|
||||
final StatusResponseHolder response = httpClient.go(
|
||||
new Request(HttpMethod.POST, workerUrl),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8)
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
log.info(
|
||||
|
|
|
@ -45,7 +45,6 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
|
|||
import org.joda.time.DateTime;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
@ -71,7 +70,6 @@ public class WorkerHolder
|
|||
{
|
||||
};
|
||||
|
||||
private static final StatusResponseHandler RESPONSE_HANDLER = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
|
||||
private final Worker worker;
|
||||
private Worker disabledWorker;
|
||||
|
@ -231,7 +229,7 @@ public class WorkerHolder
|
|||
new Request(HttpMethod.POST, url)
|
||||
.addHeader(HttpHeaders.Names.CONTENT_TYPE, SmileMediaTypes.APPLICATION_JACKSON_SMILE)
|
||||
.setContent(smileMapper.writeValueAsBytes(task)),
|
||||
RESPONSE_HANDLER,
|
||||
StatusResponseHandler.getInstance(),
|
||||
config.getAssignRequestHttpTimeout().toStandardDuration()
|
||||
).get();
|
||||
|
||||
|
@ -276,7 +274,7 @@ public class WorkerHolder
|
|||
try {
|
||||
final StatusResponseHolder response = httpClient.go(
|
||||
new Request(HttpMethod.POST, url),
|
||||
RESPONSE_HANDLER,
|
||||
StatusResponseHandler.getInstance(),
|
||||
config.getShutdownRequestHttpTimeout().toStandardDuration()
|
||||
).get();
|
||||
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
|
|||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -54,7 +53,7 @@ public abstract class AbstractQueryResourceTestClient<QueryType>
|
|||
this.jsonMapper = jsonMapper;
|
||||
this.httpClient = httpClient;
|
||||
this.routerUrl = config.getRouterUrl();
|
||||
this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
this.responseHandler = StatusResponseHandler.getInstance();
|
||||
}
|
||||
|
||||
public abstract String getBrokerURL();
|
||||
|
|
|
@ -34,7 +34,6 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
|
|||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
public class ClientInfoResourceTestClient
|
||||
|
@ -54,7 +53,7 @@ public class ClientInfoResourceTestClient
|
|||
this.jsonMapper = jsonMapper;
|
||||
this.httpClient = httpClient;
|
||||
this.brokerUrl = config.getBrokerUrl();
|
||||
this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
this.responseHandler = StatusResponseHandler.getInstance();
|
||||
}
|
||||
|
||||
private String getBrokerURL()
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
|||
import org.joda.time.Interval;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -65,7 +64,7 @@ public class CoordinatorResourceTestClient
|
|||
this.jsonMapper = jsonMapper;
|
||||
this.httpClient = httpClient;
|
||||
this.coordinator = config.getCoordinatorUrl();
|
||||
this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
this.responseHandler = StatusResponseHandler.getInstance();
|
||||
}
|
||||
|
||||
private String getCoordinatorURL()
|
||||
|
|
|
@ -45,7 +45,6 @@ import java.util.Map;
|
|||
public class EventReceiverFirehoseTestClient
|
||||
{
|
||||
private final String host;
|
||||
private final StatusResponseHandler responseHandler;
|
||||
private final ObjectMapper jsonMapper;
|
||||
private final HttpClient httpClient;
|
||||
private final String chatID;
|
||||
|
@ -61,7 +60,6 @@ public class EventReceiverFirehoseTestClient
|
|||
{
|
||||
this.host = host;
|
||||
this.jsonMapper = jsonMapper;
|
||||
this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
this.httpClient = httpClient;
|
||||
this.chatID = chatID;
|
||||
this.smileMapper = smileMapper;
|
||||
|
@ -89,7 +87,7 @@ public class EventReceiverFirehoseTestClient
|
|||
StatusResponseHolder response = httpClient.go(
|
||||
new Request(HttpMethod.POST, new URL(getURL()))
|
||||
.setContent(mediaType, objectMapper.writeValueAsBytes(events)),
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
|
|
|
@ -41,7 +41,6 @@ import org.jboss.netty.handler.codec.http.HttpMethod;
|
|||
import org.jboss.netty.handler.codec.http.HttpResponseStatus;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -52,7 +51,6 @@ public class OverlordResourceTestClient
|
|||
private final ObjectMapper jsonMapper;
|
||||
private final HttpClient httpClient;
|
||||
private final String indexer;
|
||||
private final StatusResponseHandler responseHandler;
|
||||
|
||||
@Inject
|
||||
OverlordResourceTestClient(
|
||||
|
@ -64,7 +62,6 @@ public class OverlordResourceTestClient
|
|||
this.jsonMapper = jsonMapper;
|
||||
this.httpClient = httpClient;
|
||||
this.indexer = config.getIndexerUrl();
|
||||
this.responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
}
|
||||
|
||||
private String getIndexerURL()
|
||||
|
@ -86,7 +83,7 @@ public class OverlordResourceTestClient
|
|||
"application/json",
|
||||
StringUtils.toUtf8(task)
|
||||
),
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
throw new ISE(
|
||||
|
@ -212,7 +209,7 @@ public class OverlordResourceTestClient
|
|||
"application/json",
|
||||
StringUtils.toUtf8(spec)
|
||||
),
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
throw new ISE(
|
||||
|
@ -245,7 +242,7 @@ public class OverlordResourceTestClient
|
|||
StringUtils.urlEncode(id)
|
||||
))
|
||||
),
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
throw new ISE(
|
||||
|
@ -265,7 +262,7 @@ public class OverlordResourceTestClient
|
|||
{
|
||||
try {
|
||||
StatusResponseHolder response = this.httpClient
|
||||
.go(new Request(method, new URL(url)), responseHandler).get();
|
||||
.go(new Request(method, new URL(url)), StatusResponseHandler.getInstance()).get();
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
throw new ISE("Error while making request to indexer [%s %s]", response.getStatus(), response.getContent());
|
||||
}
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.testng.internal.annotations.IAnnotationFinder;
|
|||
import org.testng.xml.XmlTest;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -119,13 +118,12 @@ public class DruidTestRunnerFactory implements ITestRunnerFactory
|
|||
|
||||
public void waitUntilInstanceReady(final HttpClient client, final String host)
|
||||
{
|
||||
final StatusResponseHandler handler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
RetryUtil.retryUntilTrue(
|
||||
() -> {
|
||||
try {
|
||||
StatusResponseHolder response = client.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("%s/status/health", host))),
|
||||
handler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
LOG.info("%s %s", response.getStatus(), response.getContent());
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.testng.annotations.Test;
|
|||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
@ -210,13 +209,12 @@ public class ITUnionQueryTest extends AbstractIndexerTest
|
|||
LOG.info("Event Receiver Found at host [%s]", host);
|
||||
|
||||
LOG.info("Checking worker /status/health for [%s]", host);
|
||||
final StatusResponseHandler handler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
RetryUtil.retryUntilTrue(
|
||||
() -> {
|
||||
try {
|
||||
StatusResponseHolder response = httpClient.go(
|
||||
new Request(HttpMethod.GET, new URL(StringUtils.format("https://%s/status/health", host))),
|
||||
handler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
return response.getStatus().equals(HttpResponseStatus.OK);
|
||||
}
|
||||
|
|
|
@ -56,7 +56,6 @@ import org.testng.annotations.Test;
|
|||
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.sql.Connection;
|
||||
import java.sql.DriverManager;
|
||||
import java.sql.ResultSet;
|
||||
|
@ -114,7 +113,6 @@ public class ITBasicAuthConfigurationTest
|
|||
@Client
|
||||
HttpClient httpClient;
|
||||
|
||||
StatusResponseHandler responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
|
||||
@Inject
|
||||
private CoordinatorResourceTestClient coordinatorClient;
|
||||
|
@ -620,7 +618,7 @@ public class ITBasicAuthConfigurationTest
|
|||
while (true) {
|
||||
response = httpClient.go(
|
||||
request,
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
if (!response.getStatus().equals(expectedStatus)) {
|
||||
|
|
|
@ -54,7 +54,6 @@ import javax.net.ssl.SSLException;
|
|||
import javax.ws.rs.core.MediaType;
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
@Guice(moduleFactory = DruidTestModuleFactory.class)
|
||||
public class ITTLSTest
|
||||
|
@ -85,7 +84,6 @@ public class ITTLSTest
|
|||
@Inject
|
||||
TLSCertificateChecker certificateChecker;
|
||||
|
||||
StatusResponseHandler responseHandler = new StatusResponseHandler(StandardCharsets.UTF_8);
|
||||
|
||||
@Test
|
||||
public void testPlaintextAccess()
|
||||
|
@ -504,7 +502,7 @@ public class ITTLSTest
|
|||
while (true) {
|
||||
response = httpClient.go(
|
||||
request,
|
||||
responseHandler
|
||||
StatusResponseHandler.getInstance()
|
||||
).get();
|
||||
|
||||
if (!response.getStatus().equals(HttpResponseStatus.OK)) {
|
||||
|
|
|
@ -64,7 +64,6 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
import java.io.SequenceInputStream;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
|
@ -486,7 +485,7 @@ public class DirectDruidClient<T> implements QueryRunner<T>
|
|||
? SmileMediaTypes.APPLICATION_JACKSON_SMILE
|
||||
: MediaType.APPLICATION_JSON
|
||||
),
|
||||
new StatusResponseHandler(StandardCharsets.UTF_8),
|
||||
StatusResponseHandler.getInstance(),
|
||||
Duration.standardSeconds(1)
|
||||
).get(1, TimeUnit.SECONDS);
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ import org.junit.Assert;
|
|||
import org.junit.Test;
|
||||
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
@ -131,7 +130,7 @@ public class JettyQosTest extends BaseJettyTest
|
|||
ListenableFuture<StatusResponseHolder> go =
|
||||
slowClient.go(
|
||||
new Request(HttpMethod.GET, new URL("http://localhost:" + port + "/slow/hello")),
|
||||
new StatusResponseHandler(Charset.defaultCharset())
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
go.get();
|
||||
slowCount.incrementAndGet();
|
||||
|
@ -166,7 +165,7 @@ public class JettyQosTest extends BaseJettyTest
|
|||
ListenableFuture<StatusResponseHolder> go =
|
||||
fastClient.go(
|
||||
new Request(HttpMethod.GET, new URL("http://localhost:" + port + "/default")),
|
||||
new StatusResponseHandler(Charset.defaultCharset())
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
go.get();
|
||||
fastCount.incrementAndGet();
|
||||
|
|
|
@ -172,7 +172,7 @@ public class JettyTest extends BaseJettyTest
|
|||
ListenableFuture<StatusResponseHolder> go =
|
||||
client.go(
|
||||
new Request(HttpMethod.GET, new URL("http://localhost:" + port + "/slow/hello")),
|
||||
new StatusResponseHandler(Charset.defaultCharset())
|
||||
StatusResponseHandler.getInstance()
|
||||
);
|
||||
startTime2 = System.currentTimeMillis();
|
||||
go.get();
|
||||
|
|
Loading…
Reference in New Issue