use of com.palantir.logsafe.SafeLoggable in project dialogue by palantir.
the class ApacheHttpClientChannelsTest method close_doesnt_fail_inflight_requests.
@Test
public void close_doesnt_fail_inflight_requests() throws Exception {
ClientConfiguration conf = TestConfigurations.create("http://foo");
Channel channel;
try (ApacheHttpClientChannels.CloseableClient client = ApacheHttpClientChannels.createCloseableHttpClient(conf, "client")) {
channel = ApacheHttpClientChannels.createSingleUri("http://foo", client);
ListenableFuture<Response> response = channel.execute(TestEndpoint.POST, Request.builder().build());
assertThatThrownBy(() -> Futures.getUnchecked(response)).getCause().isInstanceOfSatisfying(UnknownHostException.class, throwable -> assertThat(throwable.getSuppressed()[0]).satisfies(diagnosticThrowable -> assertThat(diagnosticThrowable.getStackTrace()).as("Diagnostic exception should have an empty stack trace").isEmpty()).isInstanceOfSatisfying(SafeLoggable.class, safeLoggable -> {
assertThat(Lists.transform(safeLoggable.getArgs(), Arg::getName)).as("Expected a diagnostic exception").containsExactlyInAnyOrder("durationMillis", "connectTimeout", "socketTimeout", "clientName", "serviceName", "endpointName", "requestTraceId", "requestSpanId", "hostIndex");
}));
}
ListenableFuture<Response> again = channel.execute(TestEndpoint.POST, Request.builder().build());
assertThatThrownBy(() -> Futures.getUnchecked(again)).hasCauseInstanceOf(UnknownHostException.class);
}
Aggregations