Skip to content

Commit

Permalink
Clean up compile warnings (#1728)
Browse files Browse the repository at this point in the history
  • Loading branch information
izeye authored and shakuzen committed Dec 3, 2019
1 parent 10c37d8 commit c6a99f1
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 6 deletions.
Expand Up @@ -121,7 +121,9 @@ public void onSuccess(PutMetricDataRequest request, PutMetricDataResult result)
}
});
try {
latch.await(config.readTimeout().toMillis(), TimeUnit.MILLISECONDS);
@SuppressWarnings("deprecation")
long readTimeoutMillis = config.readTimeout().toMillis();
latch.await(readTimeoutMillis, TimeUnit.MILLISECONDS);
} catch (InterruptedException e) {
logger.warn("metrics push to cloudwatch took longer than expected");
throw e;
Expand Down
Expand Up @@ -145,6 +145,7 @@ void writeMeterWithGaugeShouldDropNanValue() {
assertThat(meterRegistry.writeMeter(gauge)).isEmpty();
}

@SuppressWarnings("unchecked")
@Test
void writeMeterWithGaugeWhenChangingFiniteToNaNShouldWork() {
AtomicBoolean first = new AtomicBoolean(true);
Expand Down
Expand Up @@ -17,7 +17,6 @@

import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.MockClock;
import io.micrometer.core.instrument.util.HierarchicalNameMapper;
import io.micrometer.core.lang.Nullable;
import io.micrometer.core.tck.MeterRegistryCompatibilityKit;

Expand All @@ -26,7 +25,7 @@
class GangliaMeterRegistryCompatibilityTest extends MeterRegistryCompatibilityKit {
@Override
public MeterRegistry registry() {
return new GangliaMeterRegistry(new GangliaConfig() {
return GangliaMeterRegistry.builder(new GangliaConfig() {
@Override
public boolean enabled() {
return false;
Expand All @@ -37,7 +36,7 @@ public boolean enabled() {
public String get(String key) {
return null;
}
}, new MockClock(), HierarchicalNameMapper.DEFAULT);
}).clock(new MockClock()).build();
}

@Override
Expand Down
Expand Up @@ -36,6 +36,7 @@ void compressShouldAddContentEncodingHeader() throws IOException, NoSuchFieldExc
HttpSender.Request.Builder builder = HttpSender.Request.build("https://micrometer.io/", mock(HttpSender.class)).compress();
Field requestHeadersField = HttpSender.Request.Builder.class.getDeclaredField("requestHeaders");
requestHeadersField.setAccessible(true);
@SuppressWarnings("unchecked")
Map<String, String> requestHeaders = (Map<String, String>) requestHeadersField.get(builder);
assertThat(requestHeaders).containsEntry("Content-Encoding", "gzip");
}
Expand Down
Expand Up @@ -53,11 +53,13 @@ public boolean enabled() {
return get(T::isEnabled, StepRegistryConfig.super::enabled);
}

@SuppressWarnings("deprecation")
@Override
public Duration connectTimeout() {
return get(T::getConnectTimeout, StepRegistryConfig.super::connectTimeout);
}

@SuppressWarnings("deprecation")
@Override
public Duration readTimeout() {
return get(T::getReadTimeout, StepRegistryConfig.super::readTimeout);
Expand Down
Expand Up @@ -27,6 +27,7 @@
*/
public abstract class StepRegistryPropertiesTest {

@SuppressWarnings("deprecation")
protected void assertStepRegistryDefaultValues(StepRegistryProperties properties,
StepRegistryConfig config) {
assertThat(properties.getStep()).isEqualTo(config.step());
Expand Down
Expand Up @@ -79,15 +79,15 @@ public void outcomeTagIsServerErrorWhenResponseIs5xx() {
@Test
public void outcomeTagIsUnknownWhenResponseThrowsIOException() throws Exception {
ClientHttpResponse response = mock(ClientHttpResponse.class);
given(response.getRawStatusCode()).willThrow(IOException.class);
given(response.getRawStatusCode()).willThrow(new IOException());
Tag tag = RestTemplateExchangeTags.outcome(response);
assertThat(tag.getValue()).isEqualTo("UNKNOWN");
}

@Test
public void outcomeTagIsUnknownForCustomResponseStatus() throws Exception {
ClientHttpResponse response = mock(ClientHttpResponse.class);
given(response.getRawStatusCode()).willThrow(IllegalArgumentException.class);
given(response.getRawStatusCode()).willThrow(new IllegalArgumentException());
Tag tag = RestTemplateExchangeTags.outcome(response);
assertThat(tag.getValue()).isEqualTo("UNKNOWN");
}
Expand Down

0 comments on commit c6a99f1

Please sign in to comment.