Skip to content

Commit 540f7fe

Browse files
committed
Remove unused imports and reuse method
1 parent c6836aa commit 540f7fe

2 files changed

Lines changed: 2 additions & 13 deletions

File tree

http-clients/netty-nio-client/src/main/java/software/amazon/awssdk/http/nio/netty/internal/NettyRequestMetrics.java

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,9 @@ public static void ifMetricsAreEnabled(MetricCollector metrics, Consumer<MetricC
6464
* the stream has been initialized. If the stream is not initialized when this is invoked, an exception will be thrown.
6565
*/
6666
public static void publishHttp2StreamMetrics(MetricCollector metricCollector, Channel channel) {
67-
if (!metricsAreEnabled(metricCollector)) {
68-
return;
69-
}
7067

71-
try {
72-
getHttp2Connection(channel).ifPresent(http2Connection -> {
73-
writeHttp2RequestMetrics(metricCollector, channel, http2Connection);
74-
});
75-
} catch (Exception e) {
76-
logger.warn(null, () -> "Failed to collect metrics", e);
77-
}
68+
ifMetricsAreEnabled(metricCollector, collector -> getHttp2Connection(channel)
69+
.ifPresent(http2Connection -> writeHttp2RequestMetrics(collector, channel, http2Connection)));
7870
}
7971

8072
private static Optional<Http2Connection> getHttp2Connection(Channel channel) {

http-clients/netty-nio-client/src/test/java/software/amazon/awssdk/http/nio/netty/Http2MetricsTest.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,8 @@
3838
import io.netty.util.ReferenceCountUtil;
3939
import java.net.URI;
4040
import org.junit.jupiter.api.AfterAll;
41-
import org.junit.jupiter.api.Assertions;
4241
import org.junit.jupiter.api.BeforeAll;
4342
import org.junit.jupiter.api.Test;
44-
import org.mockito.Mockito;
4543
import software.amazon.awssdk.http.EmptyPublisher;
4644
import software.amazon.awssdk.http.Http2Metric;
4745
import software.amazon.awssdk.http.HttpMetric;
@@ -53,7 +51,6 @@
5351
import software.amazon.awssdk.http.async.SdkAsyncHttpClient;
5452
import software.amazon.awssdk.metrics.MetricCollection;
5553
import software.amazon.awssdk.metrics.MetricCollector;
56-
import software.amazon.awssdk.metrics.SdkMetric;
5754

5855
public class Http2MetricsTest {
5956
private static final int H2_DEFAULT_WINDOW_SIZE = 65535;

0 commit comments

Comments
 (0)