From 82943a49e5a9aa141c43ab57119928a730f63b65 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 13 Dec 2023 10:44:35 +0100 Subject: [PATCH] run metrics --- .../metrics-v4.2.19-expected-changes.patch | 6660 +++++++++++++++++ .../metrics-v4.2.19-expected-warnings.txt | 133 +- integration-tests/metrics-v4.2.19-init.patch | 2 +- integration-tests/metrics-v4.2.19.sh | 4 +- 4 files changed, 6793 insertions(+), 6 deletions(-) diff --git a/integration-tests/metrics-v4.2.19-expected-changes.patch b/integration-tests/metrics-v4.2.19-expected-changes.patch index e69de29bb2d..5d6d51f6b84 100644 --- a/integration-tests/metrics-v4.2.19-expected-changes.patch +++ b/integration-tests/metrics-v4.2.19-expected-changes.patch @@ -0,0 +1,6660 @@ +--- a/metrics-benchmarks/src/main/java/com/codahale/metrics/benchmarks/SlidingTimeWindowReservoirsBenchmark.java ++++ b/metrics-benchmarks/src/main/java/com/codahale/metrics/benchmarks/SlidingTimeWindowReservoirsBenchmark.java +@@ -2,7 +2,6 @@ package com.codahale.metrics.benchmarks; + + import com.codahale.metrics.SlidingTimeWindowArrayReservoir; + import com.codahale.metrics.SlidingTimeWindowReservoir; +-import com.codahale.metrics.Snapshot; + import java.util.concurrent.TimeUnit; + import org.openjdk.jmh.annotations.Benchmark; + import org.openjdk.jmh.annotations.Group; +@@ -42,8 +41,7 @@ public class SlidingTimeWindowReservoirsBenchmark { + @Group("slidingTime") + @GroupThreads(1) + public Object slidingTimeRead() { +- Snapshot snapshot = slidingTime.getSnapshot(); +- return snapshot; ++ return slidingTime.getSnapshot(); + } + + @Benchmark +@@ -58,8 +56,7 @@ public class SlidingTimeWindowReservoirsBenchmark { + @Group("arrTime") + @GroupThreads(1) + public Object arrTimeRead() { +- Snapshot snapshot = arrTime.getSnapshot(); +- return snapshot; ++ return arrTime.getSnapshot(); + } + + public static void main(String[] args) throws RunnerException { +--- a/metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java ++++ b/metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java +@@ -4,10 +4,8 @@ import static com.codahale.metrics.MetricAttribute.COUNT; + import static com.codahale.metrics.MetricAttribute.M15_RATE; + import static com.codahale.metrics.MetricAttribute.M1_RATE; + import static com.codahale.metrics.MetricAttribute.M5_RATE; +-import static com.codahale.metrics.MetricAttribute.MAX; + import static com.codahale.metrics.MetricAttribute.MEAN; + import static com.codahale.metrics.MetricAttribute.MEAN_RATE; +-import static com.codahale.metrics.MetricAttribute.MIN; + import static com.codahale.metrics.MetricAttribute.P50; + import static com.codahale.metrics.MetricAttribute.P75; + import static com.codahale.metrics.MetricAttribute.P95; +@@ -15,6 +13,7 @@ import static com.codahale.metrics.MetricAttribute.P98; + import static com.codahale.metrics.MetricAttribute.P99; + import static com.codahale.metrics.MetricAttribute.P999; + import static com.codahale.metrics.MetricAttribute.STDDEV; ++import static java.util.Collections.emptySet; + + import com.codahale.metrics.Clock; + import com.codahale.metrics.Counter; +@@ -29,7 +28,6 @@ import com.codahale.metrics.Snapshot; + import com.codahale.metrics.Timer; + import java.io.IOException; + import java.net.InetAddress; +-import java.util.Collections; + import java.util.Map; + import java.util.Set; + import java.util.SortedMap; +@@ -80,7 +78,7 @@ public class CollectdReporter extends ScheduledReporter { + private SecurityLevel securityLevel = SecurityLevel.NONE; + private String username = ""; + private String password = ""; +- private Set disabledMetricAttributes = Collections.emptySet(); ++ private Set disabledMetricAttributes = emptySet(); + private int maxLength = Sanitize.DEFAULT_MAX_LENGTH; + + private Builder(MetricRegistry registry) { +@@ -302,7 +300,7 @@ public class CollectdReporter extends ScheduledReporter { + try { + writer.write(metaData, value); + } catch (RuntimeException e) { +- LOG.warn("Failed to process metric '" + metaData.getPlugin() + "': " + e.getMessage()); ++ LOG.warn("Failed to process metric '{}': {}", metaData.getPlugin(), e.getMessage()); + } catch (IOException e) { + LOG.error("Failed to send metric to collectd", e); + } +@@ -337,9 +335,9 @@ public class CollectdReporter extends ScheduledReporter { + private void serializeHistogram(MetaData.Builder metaData, Histogram metric) { + final Snapshot snapshot = metric.getSnapshot(); + writeValue(metaData, COUNT, (double) metric.getCount()); +- writeValue(metaData, MAX, (double) snapshot.getMax()); ++ writeValue(metaData, MetricAttribute.MAX, (double) snapshot.getMax()); + writeValue(metaData, MEAN, snapshot.getMean()); +- writeValue(metaData, MIN, (double) snapshot.getMin()); ++ writeValue(metaData, MetricAttribute.MIN, (double) snapshot.getMin()); + writeValue(metaData, STDDEV, snapshot.getStdDev()); + writeValue(metaData, P50, snapshot.getMedian()); + writeValue(metaData, P75, snapshot.get75thPercentile()); +@@ -352,9 +350,9 @@ public class CollectdReporter extends ScheduledReporter { + private void serializeTimer(MetaData.Builder metaData, Timer metric) { + final Snapshot snapshot = metric.getSnapshot(); + writeValue(metaData, COUNT, (double) metric.getCount()); +- writeDuration(metaData, MAX, (double) snapshot.getMax()); ++ writeDuration(metaData, MetricAttribute.MAX, (double) snapshot.getMax()); + writeDuration(metaData, MEAN, snapshot.getMean()); +- writeDuration(metaData, MIN, (double) snapshot.getMin()); ++ writeDuration(metaData, MetricAttribute.MIN, (double) snapshot.getMin()); + writeDuration(metaData, STDDEV, snapshot.getStdDev()); + writeDuration(metaData, P50, snapshot.getMedian()); + writeDuration(metaData, P75, snapshot.get75thPercentile()); +--- a/metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java ++++ b/metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java +@@ -1,10 +1,12 @@ + package com.codahale.metrics.collectd; + ++import static java.nio.charset.StandardCharsets.US_ASCII; ++import static java.nio.charset.StandardCharsets.UTF_8; ++ + import java.io.IOException; + import java.nio.BufferOverflowException; + import java.nio.ByteBuffer; + import java.nio.ByteOrder; +-import java.nio.charset.StandardCharsets; + import java.security.InvalidKeyException; + import java.security.MessageDigest; + import java.security.NoSuchAlgorithmException; +@@ -64,8 +66,8 @@ class PacketWriter { + PacketWriter(Sender sender, String username, String password, SecurityLevel securityLevel) { + this.sender = sender; + this.securityLevel = securityLevel; +- this.username = username != null ? username.getBytes(StandardCharsets.UTF_8) : null; +- this.password = password != null ? password.getBytes(StandardCharsets.UTF_8) : null; ++ this.username = username != null ? username.getBytes(UTF_8) : null; ++ this.password = password != null ? password.getBytes(UTF_8) : null; + } + + void write(MetaData metaData, Number... values) throws BufferOverflowException, IOException { +@@ -119,12 +121,12 @@ class PacketWriter { + } + + private void writeString(ByteBuffer buffer, int type, String val) { +- if (val == null || val.length() == 0) { ++ if (val == null || val.isEmpty()) { + return; + } + int len = HEADER_LEN + val.length() + 1; + writeHeader(buffer, type, len); +- buffer.put(val.getBytes(StandardCharsets.US_ASCII)).put(NULL); ++ buffer.put(val.getBytes(US_ASCII)).put(NULL); + } + + private void writeNumber(ByteBuffer buffer, int type, long val) { +--- a/metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterSecurityTest.java ++++ b/metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterSecurityTest.java +@@ -1,6 +1,6 @@ + package com.codahale.metrics.collectd; + +-import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException; ++import static org.assertj.core.api.Assertions.assertThatThrownBy; + + import com.codahale.metrics.MetricRegistry; + import org.junit.Test; +@@ -11,27 +11,27 @@ public class CollectdReporterSecurityTest { + + @Test + public void testUnableSetSecurityLevelToSignWithoutUsername() { +- assertThatIllegalArgumentException() +- .isThrownBy( ++ assertThatThrownBy( + () -> + CollectdReporter.forRegistry(registry) + .withHostName("eddie") + .withSecurityLevel(SecurityLevel.SIGN) + .withPassword("t1_g3r") + .build(new Sender("localhost", 25826))) +- .withMessage("username is required for securityLevel: SIGN"); ++ .isInstanceOf(IllegalArgumentException.class) ++ .hasMessage("username is required for securityLevel: SIGN"); + } + + @Test + public void testUnableSetSecurityLevelToSignWithoutPassword() { +- assertThatIllegalArgumentException() +- .isThrownBy( ++ assertThatThrownBy( + () -> + CollectdReporter.forRegistry(registry) + .withHostName("eddie") + .withSecurityLevel(SecurityLevel.SIGN) + .withUsername("scott") + .build(new Sender("localhost", 25826))) +- .withMessage("password is required for securityLevel: SIGN"); ++ .isInstanceOf(IllegalArgumentException.class) ++ .hasMessage("password is required for securityLevel: SIGN"); + } + } +--- a/metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterTest.java ++++ b/metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterTest.java +@@ -1,5 +1,8 @@ + package com.codahale.metrics.collectd; + ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptySortedMap; ++import static java.util.Collections.singletonMap; + import static java.util.concurrent.TimeUnit.MILLISECONDS; + import static org.assertj.core.api.Assertions.assertThat; + import static org.mockito.Mockito.mock; +@@ -12,7 +15,6 @@ import com.codahale.metrics.MetricAttribute; + import com.codahale.metrics.MetricRegistry; + import com.codahale.metrics.Snapshot; + import com.codahale.metrics.Timer; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -94,7 +96,7 @@ public class CollectdReporterTest { + + @Test + public void reportsCounters() throws Exception { +- Counter counter = mock(Counter.class); ++ Counter counter = mock(); + when(counter.getCount()).thenReturn(42L); + + reporter.report(map(), map("api.rest.requests.count", counter), map(), map(), map()); +@@ -104,7 +106,7 @@ public class CollectdReporterTest { + + @Test + public void reportsMeters() throws Exception { +- Meter meter = mock(Meter.class); ++ Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getOneMinuteRate()).thenReturn(2.0); + when(meter.getFiveMinuteRate()).thenReturn(3.0); +@@ -122,8 +124,8 @@ public class CollectdReporterTest { + + @Test + public void reportsHistograms() throws Exception { +- Histogram histogram = mock(Histogram.class); +- Snapshot snapshot = mock(Snapshot.class); ++ Histogram histogram = mock(); ++ Snapshot snapshot = mock(); + when(histogram.getCount()).thenReturn(1L); + when(histogram.getSnapshot()).thenReturn(snapshot); + when(snapshot.getMax()).thenReturn(2L); +@@ -146,8 +148,8 @@ public class CollectdReporterTest { + + @Test + public void reportsTimers() throws Exception { +- Timer timer = mock(Timer.class); +- Snapshot snapshot = mock(Snapshot.class); ++ Timer timer = mock(); ++ Snapshot snapshot = mock(); + when(timer.getSnapshot()).thenReturn(snapshot); + when(timer.getCount()).thenReturn(1L); + when(timer.getSnapshot()).thenReturn(snapshot); +@@ -187,14 +189,14 @@ public class CollectdReporterTest { + + @Test + public void doesNotReportDisabledMetricAttributes() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getOneMinuteRate()).thenReturn(2.0); + when(meter.getFiveMinuteRate()).thenReturn(3.0); + when(meter.getFifteenMinuteRate()).thenReturn(4.0); + when(meter.getMeanRate()).thenReturn(5.0); + +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(11L); + + CollectdReporter reporter = +@@ -240,16 +242,16 @@ public class CollectdReporterTest { + } + + private SortedMap map() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + private SortedMap map(String name, T metric) { +- final Map map = Collections.singletonMap(name, metric); ++ final Map map = singletonMap(name, metric); + return new TreeMap<>(map); + } + + private List nextValues(Receiver receiver) throws Exception { + final ValueList valueList = receiver.next(); +- return valueList == null ? Collections.emptyList() : valueList.getValues(); ++ return valueList == null ? emptyList() : valueList.getValues(); + } + } +--- a/metrics-collectd/src/test/java/com/codahale/metrics/collectd/PacketWriterTest.java ++++ b/metrics-collectd/src/test/java/com/codahale/metrics/collectd/PacketWriterTest.java +@@ -190,6 +190,6 @@ public class PacketWriterTest { + assertThat(amountOfValues).isEqualTo((short) 1); + byte dataType = packet.get(); + assertThat(dataType).isEqualTo((byte) 1); +- assertThat(packet.order(ByteOrder.LITTLE_ENDIAN).getDouble()).isEqualTo(42.0, offset(0.01)); ++ assertThat(packet.order(ByteOrder.LITTLE_ENDIAN).getDouble()).isCloseTo(42.0, offset(0.01)); + } + } +--- a/metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java +@@ -1,8 +1,9 @@ + package com.codahale.metrics; + ++import static java.util.Collections.emptySet; ++ + import java.io.PrintStream; + import java.text.DateFormat; +-import java.util.Collections; + import java.util.Date; + import java.util.Locale; + import java.util.Map; +@@ -53,7 +54,7 @@ public class ConsoleReporter extends ScheduledReporter { + this.filter = MetricFilter.ALL; + this.executor = null; + this.shutdownExecutorOnStop = true; +- disabledMetricAttributes = Collections.emptySet(); ++ disabledMetricAttributes = emptySet(); + } + + /** +--- a/metrics-core/src/main/java/com/codahale/metrics/LockFreeExponentiallyDecayingReservoir.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/LockFreeExponentiallyDecayingReservoir.java +@@ -1,8 +1,9 @@ + package com.codahale.metrics; + ++import static java.util.Objects.requireNonNull; ++ + import com.codahale.metrics.WeightedSnapshot.WeightedSample; + import java.time.Duration; +-import java.util.Objects; + import java.util.concurrent.ConcurrentSkipListMap; + import java.util.concurrent.ThreadLocalRandom; + import java.util.concurrent.atomic.AtomicIntegerFieldUpdater; +@@ -127,7 +128,7 @@ public final class LockFreeExponentiallyDecayingReservoir implements Reservoir { + // It's possible that more values were added while the map was scanned, those with the + // minimum priorities are removed. + while (newCount > size) { +- Objects.requireNonNull(newValues.pollFirstEntry(), "Expected an entry"); ++ requireNonNull(newValues.pollFirstEntry(), "Expected an entry"); + newCount--; + } + return new State(alphaNanos, size, newTick, newCount, newValues); +@@ -255,13 +256,13 @@ public final class LockFreeExponentiallyDecayingReservoir implements Reservoir { + + /** Interval at which this reservoir is rescaled. */ + public Builder rescaleThreshold(Duration value) { +- this.rescaleThreshold = Objects.requireNonNull(value, "rescaleThreshold is required"); ++ this.rescaleThreshold = requireNonNull(value, "rescaleThreshold is required"); + return this; + } + + /** Clock instance used for decay. */ + public Builder clock(Clock value) { +- this.clock = Objects.requireNonNull(value, "clock is required"); ++ this.clock = requireNonNull(value, "clock is required"); + return this; + } + +--- a/metrics-core/src/main/java/com/codahale/metrics/MetricRegistry.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/MetricRegistry.java +@@ -1,6 +1,9 @@ + package com.codahale.metrics; + +-import java.util.Collections; ++import static java.util.Collections.unmodifiableMap; ++import static java.util.Collections.unmodifiableSortedMap; ++import static java.util.Collections.unmodifiableSortedSet; ++ + import java.util.List; + import java.util.Map; + import java.util.SortedMap; +@@ -207,7 +210,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Counter.class.isInstance(metric); ++ return metric instanceof Counter; + } + }); + } +@@ -242,7 +245,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Histogram.class.isInstance(metric); ++ return metric instanceof Histogram; + } + }); + } +@@ -277,7 +280,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Meter.class.isInstance(metric); ++ return metric instanceof Meter; + } + }); + } +@@ -312,7 +315,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Timer.class.isInstance(metric); ++ return metric instanceof Timer; + } + }); + } +@@ -350,7 +353,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Gauge.class.isInstance(metric); ++ return metric instanceof Gauge; + } + }); + } +@@ -414,7 +417,7 @@ public class MetricRegistry implements MetricSet { + * @return the names of all the metrics + */ + public SortedSet getNames() { +- return Collections.unmodifiableSortedSet(new TreeSet<>(metrics.keySet())); ++ return unmodifiableSortedSet(new TreeSet<>(metrics.keySet())); + } + + /** +@@ -541,7 +544,7 @@ public class MetricRegistry implements MetricSet { + timers.put(entry.getKey(), (T) entry.getValue()); + } + } +- return Collections.unmodifiableSortedMap(timers); ++ return unmodifiableSortedMap(timers); + } + + private void onMetricAdded(String name, Metric metric) { +@@ -609,7 +612,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public Map getMetrics() { +- return Collections.unmodifiableMap(metrics); ++ return unmodifiableMap(metrics); + } + + @FunctionalInterface +@@ -628,7 +631,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Counter.class.isInstance(metric); ++ return metric instanceof Counter; + } + }; + +@@ -641,7 +644,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Histogram.class.isInstance(metric); ++ return metric instanceof Histogram; + } + }; + +@@ -654,7 +657,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Meter.class.isInstance(metric); ++ return metric instanceof Meter; + } + }; + +@@ -667,7 +670,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Timer.class.isInstance(metric); ++ return metric instanceof Timer; + } + }; + +@@ -681,7 +684,7 @@ public class MetricRegistry implements MetricSet { + + @Override + public boolean isInstance(Metric metric) { +- return Gauge.class.isInstance(metric); ++ return metric instanceof Gauge; + } + }; + +--- a/metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java +@@ -1,9 +1,13 @@ + package com.codahale.metrics; + ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.emptySet; ++import static java.util.Collections.emptySortedMap; ++import static java.util.Collections.emptySortedSet; ++ + import java.io.OutputStream; + import java.time.Duration; + import java.util.Collection; +-import java.util.Collections; + import java.util.Map; + import java.util.Set; + import java.util.SortedMap; +@@ -137,69 +141,69 @@ public final class NoopMetricRegistry extends MetricRegistry { + /** {@inheritDoc} */ + @Override + public SortedSet getNames() { +- return Collections.emptySortedSet(); ++ return emptySortedSet(); + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("rawtypes") + public SortedMap getGauges() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + @SuppressWarnings("rawtypes") + public SortedMap getGauges(MetricFilter filter) { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getCounters() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getCounters(MetricFilter filter) { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getHistograms() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getHistograms(MetricFilter filter) { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getMeters() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getMeters(MetricFilter filter) { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getTimers() { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ + @Override + public SortedMap getTimers(MetricFilter filter) { +- return Collections.emptySortedMap(); ++ return emptySortedMap(); + } + + /** {@inheritDoc} */ +@@ -211,7 +215,7 @@ public final class NoopMetricRegistry extends MetricRegistry { + /** {@inheritDoc} */ + @Override + public Map getMetrics() { +- return Collections.emptyMap(); ++ return emptyMap(); + } + + static final class NoopGauge implements Gauge { +@@ -601,19 +605,19 @@ public final class NoopMetricRegistry extends MetricRegistry { + /** {@inheritDoc} */ + @Override + public Set keySet() { +- return Collections.emptySet(); ++ return emptySet(); + } + + /** {@inheritDoc} */ + @Override + public Collection values() { +- return Collections.emptySet(); ++ return emptySet(); + } + + /** {@inheritDoc} */ + @Override + public Set> entrySet() { +- return Collections.emptySet(); ++ return emptySet(); + } + } + } +--- a/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java +@@ -1,7 +1,8 @@ + package com.codahale.metrics; + ++import static java.util.Collections.emptySet; ++ + import java.io.Closeable; +-import java.util.Collections; + import java.util.Locale; + import java.util.Set; + import java.util.SortedMap; +@@ -128,7 +129,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter { + durationUnit, + executor, + shutdownExecutorOnStop, +- Collections.emptySet()); ++ emptySet()); + } + + protected ScheduledReporter( +@@ -154,7 +155,7 @@ public abstract class ScheduledReporter implements Closeable, Reporter { + this.durationFactor = durationUnit.toNanos(1); + this.durationUnit = durationUnit.toString().toLowerCase(Locale.US); + this.disabledMetricAttributes = +- disabledMetricAttributes != null ? disabledMetricAttributes : Collections.emptySet(); ++ disabledMetricAttributes != null ? disabledMetricAttributes : emptySet(); + } + + /** +@@ -185,8 +186,8 @@ public abstract class ScheduledReporter implements Closeable, Reporter { + * @deprecated Use {@link #getScheduledFuture(long, long, TimeUnit, Runnable, + * ScheduledExecutorService)} instead. + */ +- @SuppressWarnings("DeprecatedIsStillUsed") + @Deprecated ++ @SuppressWarnings("DeprecatedIsStillUsed") + protected ScheduledFuture getScheduledFuture( + long initialDelay, long period, TimeUnit unit, Runnable runnable) { + return getScheduledFuture(initialDelay, period, unit, runnable, this.executor); +--- a/metrics-core/src/main/java/com/codahale/metrics/Slf4jReporter.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/Slf4jReporter.java +@@ -4,10 +4,8 @@ import static com.codahale.metrics.MetricAttribute.COUNT; + import static com.codahale.metrics.MetricAttribute.M15_RATE; + import static com.codahale.metrics.MetricAttribute.M1_RATE; + import static com.codahale.metrics.MetricAttribute.M5_RATE; +-import static com.codahale.metrics.MetricAttribute.MAX; + import static com.codahale.metrics.MetricAttribute.MEAN; + import static com.codahale.metrics.MetricAttribute.MEAN_RATE; +-import static com.codahale.metrics.MetricAttribute.MIN; + import static com.codahale.metrics.MetricAttribute.P50; + import static com.codahale.metrics.MetricAttribute.P75; + import static com.codahale.metrics.MetricAttribute.P95; +@@ -15,8 +13,8 @@ import static com.codahale.metrics.MetricAttribute.P98; + import static com.codahale.metrics.MetricAttribute.P99; + import static com.codahale.metrics.MetricAttribute.P999; + import static com.codahale.metrics.MetricAttribute.STDDEV; ++import static java.util.Collections.emptySet; + +-import java.util.Collections; + import java.util.Map.Entry; + import java.util.Set; + import java.util.SortedMap; +@@ -81,7 +79,7 @@ public class Slf4jReporter extends ScheduledReporter { + this.loggingLevel = LoggingLevel.INFO; + this.executor = null; + this.shutdownExecutorOnStop = true; +- this.disabledMetricAttributes = Collections.emptySet(); ++ this.disabledMetricAttributes = emptySet(); + } + + /** +@@ -306,8 +304,8 @@ public class Slf4jReporter extends ScheduledReporter { + b.append("type=TIMER"); + append(b, "name", prefix(name)); + appendCountIfEnabled(b, timer); +- appendLongDurationIfEnabled(b, MIN, snapshot::getMin); +- appendLongDurationIfEnabled(b, MAX, snapshot::getMax); ++ appendLongDurationIfEnabled(b, MetricAttribute.MIN, snapshot::getMin); ++ appendLongDurationIfEnabled(b, MetricAttribute.MAX, snapshot::getMax); + appendDoubleDurationIfEnabled(b, MEAN, snapshot::getMean); + appendDoubleDurationIfEnabled(b, STDDEV, snapshot::getStdDev); + appendDoubleDurationIfEnabled(b, P50, snapshot::getMedian); +@@ -338,8 +336,8 @@ public class Slf4jReporter extends ScheduledReporter { + b.append("type=HISTOGRAM"); + append(b, "name", prefix(name)); + appendCountIfEnabled(b, histogram); +- appendLongIfEnabled(b, MIN, snapshot::getMin); +- appendLongIfEnabled(b, MAX, snapshot::getMax); ++ appendLongIfEnabled(b, MetricAttribute.MIN, snapshot::getMin); ++ appendLongIfEnabled(b, MetricAttribute.MAX, snapshot::getMax); + appendDoubleIfEnabled(b, MEAN, snapshot::getMean); + appendDoubleIfEnabled(b, STDDEV, snapshot::getStdDev); + appendDoubleIfEnabled(b, P50, snapshot::getMedian); +--- a/metrics-core/src/main/java/com/codahale/metrics/SlidingTimeWindowMovingAverages.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/SlidingTimeWindowMovingAverages.java +@@ -184,7 +184,6 @@ public class SlidingTimeWindowMovingAverages implements MovingAverages { + buckets.stream().limit(toIndex).mapToLong(LongAdder::longValue).forEach(adder::add); + buckets.stream().skip(fromIndex).mapToLong(LongAdder::longValue).forEach(adder::add); + } +- long retval = adder.longValue(); +- return retval; ++ return adder.longValue(); + } + } +--- a/metrics-core/src/main/java/com/codahale/metrics/WeightedSnapshot.java ++++ b/metrics-core/src/main/java/com/codahale/metrics/WeightedSnapshot.java +@@ -1,13 +1,13 @@ + package com.codahale.metrics; + + import static java.nio.charset.StandardCharsets.UTF_8; ++import static java.util.Comparator.comparingLong; + + import java.io.OutputStream; + import java.io.OutputStreamWriter; + import java.io.PrintWriter; + import java.util.Arrays; + import java.util.Collection; +-import java.util.Comparator; + + /** A statistical snapshot of a {@link WeightedSnapshot}. */ + public class WeightedSnapshot extends Snapshot { +@@ -35,7 +35,7 @@ public class WeightedSnapshot extends Snapshot { + public WeightedSnapshot(Collection values) { + final WeightedSample[] copy = values.toArray(new WeightedSample[] {}); + +- Arrays.sort(copy, Comparator.comparingLong(w -> w.value)); ++ Arrays.sort(copy, comparingLong(w -> w.value)); + + this.values = new long[copy.length]; + this.normWeights = new double[copy.length]; +--- a/metrics-core/src/test/java/com/codahale/metrics/ClockTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/ClockTest.java +@@ -11,9 +11,9 @@ public class ClockTest { + public void userTimeClock() { + final Clock.UserTimeClock clock = new Clock.UserTimeClock(); + +- assertThat((double) clock.getTime()).isEqualTo(System.currentTimeMillis(), offset(100.0)); ++ assertThat((double) clock.getTime()).isCloseTo(System.currentTimeMillis(), offset(100.0)); + +- assertThat((double) clock.getTick()).isEqualTo(System.nanoTime(), offset(1000000.0)); ++ assertThat((double) clock.getTick()).isCloseTo(System.nanoTime(), offset(1000000.0)); + } + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/ConsoleReporterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/ConsoleReporterTest.java +@@ -21,8 +21,8 @@ public class ConsoleReporterTest { + private final Locale locale = Locale.US; + private final TimeZone timeZone = TimeZone.getTimeZone("America/Los_Angeles"); + +- private final MetricRegistry registry = mock(MetricRegistry.class); +- private final Clock clock = mock(Clock.class); ++ private final MetricRegistry registry = mock(); ++ private final Clock clock = mock(); + private final ByteArrayOutputStream bytes = new ByteArrayOutputStream(); + private final PrintStream output = new PrintStream(bytes); + private final ConsoleReporter reporter = +@@ -68,7 +68,7 @@ public class ConsoleReporterTest { + + @Test + public void reportsCounterValues() throws Exception { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + + reporter.report(map(), map("test.counter", counter), map(), map(), map()); +@@ -87,10 +87,10 @@ public class ConsoleReporterTest { + + @Test + public void reportsHistogramValues() throws Exception { +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +@@ -130,7 +130,7 @@ public class ConsoleReporterTest { + + @Test + public void reportsMeterValues() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getMeanRate()).thenReturn(2.0); + when(meter.getOneMinuteRate()).thenReturn(3.0); +@@ -157,14 +157,14 @@ public class ConsoleReporterTest { + + @Test + public void reportsTimerValues() throws Exception { +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + when(timer.getMeanRate()).thenReturn(2.0); + when(timer.getOneMinuteRate()).thenReturn(3.0); + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -223,7 +223,7 @@ public class ConsoleReporterTest { + .disabledMetricAttributes(disabledMetricAttributes) + .build(); + +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getMeanRate()).thenReturn(2.0); + when(meter.getOneMinuteRate()).thenReturn(3.0); +@@ -266,14 +266,14 @@ public class ConsoleReporterTest { + .disabledMetricAttributes(disabledMetricAttributes) + .build(); + +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + when(timer.getMeanRate()).thenReturn(2.0); + when(timer.getOneMinuteRate()).thenReturn(3.0); + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -329,10 +329,10 @@ public class ConsoleReporterTest { + .disabledMetricAttributes(disabledMetricAttributes) + .build(); + +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +--- a/metrics-core/src/test/java/com/codahale/metrics/CounterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/CounterTest.java +@@ -9,7 +9,7 @@ public class CounterTest { + + @Test + public void startsAtZero() { +- assertThat(counter.getCount()).isZero(); ++ assertThat(counter.getCount()).isEqualTo(0); + } + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/CsvReporterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/CsvReporterTest.java +@@ -7,7 +7,6 @@ import static org.mockito.Mockito.when; + + import java.io.File; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import java.nio.file.Files; + import java.util.Locale; + import java.util.SortedMap; +@@ -21,8 +20,8 @@ import org.junit.rules.TemporaryFolder; + public class CsvReporterTest { + @Rule public final TemporaryFolder folder = new TemporaryFolder(); + +- private final MetricRegistry registry = mock(MetricRegistry.class); +- private final Clock clock = mock(Clock.class); ++ private final MetricRegistry registry = mock(); ++ private final Clock clock = mock(); + + private File dataDirectory; + private CsvReporter reporter; +@@ -54,7 +53,7 @@ public class CsvReporterTest { + + @Test + public void reportsCounterValues() throws Exception { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + + reporter.report(map(), map("test.counter", counter), map(), map(), map()); +@@ -64,10 +63,10 @@ public class CsvReporterTest { + + @Test + public void reportsHistogramValues() throws Exception { +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +@@ -105,14 +104,14 @@ public class CsvReporterTest { + + @Test + public void reportsTimerValues() throws Exception { +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + when(timer.getMeanRate()).thenReturn(2.0); + when(timer.getOneMinuteRate()).thenReturn(3.0); + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -137,7 +136,7 @@ public class CsvReporterTest { + + @Test + public void testCsvFileProviderIsUsed() { +- CsvFileProvider fileProvider = mock(CsvFileProvider.class); ++ CsvFileProvider fileProvider = mock(); + when(fileProvider.getFile(dataDirectory, "gauge")) + .thenReturn(new File(dataDirectory, "guage.csv")); + +@@ -175,7 +174,7 @@ public class CsvReporterTest { + } + + private Meter mockMeter() { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getMeanRate()).thenReturn(2.0); + when(meter.getOneMinuteRate()).thenReturn(3.0); +@@ -194,8 +193,7 @@ public class CsvReporterTest { + } + + private String fileContents(String filename) throws IOException { +- return new String( +- Files.readAllBytes(new File(dataDirectory, filename).toPath()), StandardCharsets.UTF_8); ++ return Files.readString(new File(dataDirectory, filename).toPath()); + } + + private SortedMap map() { +--- a/metrics-core/src/test/java/com/codahale/metrics/EWMATest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/EWMATest.java +@@ -13,67 +13,67 @@ public class EWMATest { + ewma.update(3); + ewma.tick(); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.6, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.6, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.22072766, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.22072766, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.08120117, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.08120117, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.02987224, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.02987224, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.01098938, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.01098938, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00404277, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00404277, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00148725, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00148725, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00054713, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00054713, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00020128, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00020128, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00007405, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00007405, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00002724, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00002724, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00001002, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00001002, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00000369, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00000369, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00000136, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00000136, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00000050, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00000050, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.00000018, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.00000018, offset(0.000001)); + } + + @Test +@@ -82,67 +82,67 @@ public class EWMATest { + ewma.update(3); + ewma.tick(); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.6, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.6, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.49123845, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.49123845, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.40219203, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.40219203, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.32928698, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.32928698, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.26959738, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.26959738, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.22072766, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.22072766, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.18071653, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.18071653, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.14795818, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.14795818, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.12113791, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.12113791, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.09917933, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.09917933, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.08120117, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.08120117, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.06648190, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.06648190, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.05443077, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.05443077, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.04456415, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.04456415, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.03648604, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.03648604, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.02987224, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.02987224, offset(0.000001)); + } + + @Test +@@ -151,67 +151,67 @@ public class EWMATest { + ewma.update(3); + ewma.tick(); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.6, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.6, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.56130419, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.56130419, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.52510399, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.52510399, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.49123845, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.49123845, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.45955700, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.45955700, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.42991879, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.42991879, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.40219203, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.40219203, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.37625345, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.37625345, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.35198773, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.35198773, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.32928698, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.32928698, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.30805027, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.30805027, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.28818318, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.28818318, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.26959738, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.26959738, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.25221023, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.25221023, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.23594443, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.23594443, offset(0.000001)); + + elapseMinute(ewma); + +- assertThat(ewma.getRate(TimeUnit.SECONDS)).isEqualTo(0.22072766, offset(0.000001)); ++ assertThat(ewma.getRate(TimeUnit.SECONDS)).isCloseTo(0.22072766, offset(0.000001)); + } + + private void elapseMinute(EWMA ewma) { +--- a/metrics-core/src/test/java/com/codahale/metrics/ExponentiallyDecayingReservoirTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/ExponentiallyDecayingReservoirTest.java +@@ -1,5 +1,6 @@ + package com.codahale.metrics; + ++import static java.util.stream.Collectors.toList; + import static org.assertj.core.api.Assertions.assertThat; + + import com.codahale.metrics.Timer.Context; +@@ -8,7 +9,6 @@ import java.util.Collection; + import java.util.concurrent.TimeUnit; + import java.util.concurrent.atomic.AtomicBoolean; + import java.util.concurrent.atomic.AtomicInteger; +-import java.util.stream.Collectors; + import org.junit.Test; + import org.junit.runner.RunWith; + import org.junit.runners.Parameterized; +@@ -46,7 +46,7 @@ public class ExponentiallyDecayingReservoirTest { + public static Collection reservoirs() { + return Arrays.stream(ReservoirFactory.values()) + .map(value -> new Object[] {value}) +- .collect(Collectors.toList()); ++ .collect(toList()); + } + + private final ReservoirFactory reservoirFactory; +--- a/metrics-core/src/test/java/com/codahale/metrics/HistogramTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/HistogramTest.java +@@ -8,12 +8,12 @@ import static org.mockito.Mockito.when; + import org.junit.Test; + + public class HistogramTest { +- private final Reservoir reservoir = mock(Reservoir.class); ++ private final Reservoir reservoir = mock(); + private final Histogram histogram = new Histogram(reservoir); + + @Test + public void updatesTheCountOnUpdates() { +- assertThat(histogram.getCount()).isZero(); ++ assertThat(histogram.getCount()).isEqualTo(0); + + histogram.update(1); + +@@ -22,7 +22,7 @@ public class HistogramTest { + + @Test + public void returnsTheSnapshotFromTheReservoir() { +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(reservoir.getSnapshot()).thenReturn(snapshot); + + assertThat(histogram.getSnapshot()).isEqualTo(snapshot); +--- a/metrics-core/src/test/java/com/codahale/metrics/InstrumentedExecutorServiceTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/InstrumentedExecutorServiceTest.java +@@ -112,8 +112,8 @@ public class InstrumentedExecutorServiceTest { + assertThat(idle.getSnapshot().size()).isEqualTo(1); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void reportsTasksInformationForThreadPoolExecutor() throws Exception { + executor = + new ThreadPoolExecutor(4, 16, 0L, TimeUnit.MILLISECONDS, new LinkedBlockingQueue<>(32)); +@@ -170,8 +170,8 @@ public class InstrumentedExecutorServiceTest { + assertThat(poolSize.getValue()).isEqualTo(1); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void reportsTasksInformationForForkJoinPool() throws Exception { + executor = Executors.newWorkStealingPool(4); + instrumentedExecutorService = new InstrumentedExecutorService(executor, registry, "fjp"); +--- a/metrics-core/src/test/java/com/codahale/metrics/InstrumentedScheduledExecutorServiceTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/InstrumentedScheduledExecutorServiceTest.java +@@ -36,16 +36,16 @@ public class InstrumentedScheduledExecutorServiceTest { + + @Test + public void testSubmitRunnable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + Future theFuture = + instrumentedScheduledExecutor.submit( +@@ -53,87 +53,87 @@ public class InstrumentedScheduledExecutorServiceTest { + assertThat(submitted.getCount()).isEqualTo(1); + + assertThat(running.getCount()).isEqualTo(1); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + }); + + theFuture.get(); + + assertThat(submitted.getCount()).isEqualTo(1); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isEqualTo(1); + assertThat(duration.getCount()).isEqualTo(1); + assertThat(duration.getSnapshot().size()).isEqualTo(1); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + } + + @Test + public void testScheduleRunnable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + ScheduledFuture theFuture = + instrumentedScheduledExecutor.schedule( + () -> { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + + assertThat(running.getCount()).isEqualTo(1); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + + assertThat(scheduledOnce.getCount()).isEqualTo(1); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + }, + 10L, + TimeUnit.MILLISECONDS); + + theFuture.get(); + +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isEqualTo(1); + assertThat(duration.getCount()).isEqualTo(1); + assertThat(duration.getSnapshot().size()).isEqualTo(1); + + assertThat(scheduledOnce.getCount()).isEqualTo(1); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + } + + @Test + public void testSubmitCallable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + final Object obj = new Object(); + +@@ -143,13 +143,13 @@ public class InstrumentedScheduledExecutorServiceTest { + assertThat(submitted.getCount()).isEqualTo(1); + + assertThat(running.getCount()).isEqualTo(1); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + return obj; + }); +@@ -158,45 +158,45 @@ public class InstrumentedScheduledExecutorServiceTest { + + assertThat(submitted.getCount()).isEqualTo(1); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isEqualTo(1); + assertThat(duration.getCount()).isEqualTo(1); + assertThat(duration.getSnapshot().size()).isEqualTo(1); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + } + + @Test + public void testScheduleCallable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + final Object obj = new Object(); + + ScheduledFuture theFuture = + instrumentedScheduledExecutor.schedule( + () -> { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + + assertThat(running.getCount()).isEqualTo(1); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + + assertThat(scheduledOnce.getCount()).isEqualTo(1); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + return obj; + }, +@@ -205,37 +205,37 @@ public class InstrumentedScheduledExecutorServiceTest { + + assertThat(theFuture.get()).isEqualTo(obj); + +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isEqualTo(1); + assertThat(duration.getCount()).isEqualTo(1); + assertThat(duration.getSnapshot().size()).isEqualTo(1); + + assertThat(scheduledOnce.getCount()).isEqualTo(1); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + } + + @Test + public void testScheduleFixedRateCallable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + CountDownLatch countDownLatch = new CountDownLatch(1); + ScheduledFuture theFuture = + instrumentedScheduledExecutor.scheduleAtFixedRate( + () -> { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + + assertThat(running.getCount()).isEqualTo(1); + +@@ -257,14 +257,14 @@ public class InstrumentedScheduledExecutorServiceTest { + theFuture.cancel(true); + TimeUnit.MILLISECONDS.sleep(200); // Wait while the task is cancelled + +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isNotEqualTo(0); + assertThat(duration.getCount()).isNotEqualTo(0); + assertThat(duration.getSnapshot().size()).isNotEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); + assertThat(scheduledRepetitively.getCount()).isEqualTo(1); + assertThat(scheduledOverrun.getCount()).isNotEqualTo(0); + assertThat(percentOfPeriod.getCount()).isNotEqualTo(0); +@@ -272,22 +272,22 @@ public class InstrumentedScheduledExecutorServiceTest { + + @Test + public void testScheduleFixedDelayCallable() throws Exception { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); +- assertThat(completed.getCount()).isZero(); +- assertThat(duration.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); ++ assertThat(completed.getCount()).isEqualTo(0); ++ assertThat(duration.getCount()).isEqualTo(0); + +- assertThat(scheduledOnce.getCount()).isZero(); +- assertThat(scheduledRepetitively.getCount()).isZero(); +- assertThat(scheduledOverrun.getCount()).isZero(); +- assertThat(percentOfPeriod.getCount()).isZero(); ++ assertThat(scheduledOnce.getCount()).isEqualTo(0); ++ assertThat(scheduledRepetitively.getCount()).isEqualTo(0); ++ assertThat(scheduledOverrun.getCount()).isEqualTo(0); ++ assertThat(percentOfPeriod.getCount()).isEqualTo(0); + + CountDownLatch countDownLatch = new CountDownLatch(1); + ScheduledFuture theFuture = + instrumentedScheduledExecutor.scheduleWithFixedDelay( + () -> { +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + + assertThat(running.getCount()).isEqualTo(1); + +@@ -310,9 +310,9 @@ public class InstrumentedScheduledExecutorServiceTest { + theFuture.cancel(true); + TimeUnit.MILLISECONDS.sleep(200); + +- assertThat(submitted.getCount()).isZero(); ++ assertThat(submitted.getCount()).isEqualTo(0); + +- assertThat(running.getCount()).isZero(); ++ assertThat(running.getCount()).isEqualTo(0); + assertThat(completed.getCount()).isNotEqualTo(0); + assertThat(duration.getCount()).isNotEqualTo(0); + assertThat(duration.getSnapshot().size()).isNotEqualTo(0); +--- a/metrics-core/src/test/java/com/codahale/metrics/MeterApproximationTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/MeterApproximationTest.java +@@ -11,7 +11,7 @@ import org.junit.runner.RunWith; + import org.junit.runners.Parameterized; + import org.junit.runners.Parameterized.Parameters; + +-@RunWith(value = Parameterized.class) ++@RunWith(Parameterized.class) + public class MeterApproximationTest { + + @Parameters +@@ -34,7 +34,7 @@ public class MeterApproximationTest { + 3, TimeUnit.MINUTES); + + assertThat(meter.getOneMinuteRate() * 60.0) +- .isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute)); ++ .isCloseTo(ratePerMinute, offset(0.1 * ratePerMinute)); + } + + @Test +@@ -45,7 +45,7 @@ public class MeterApproximationTest { + 13, TimeUnit.MINUTES); + + assertThat(meter.getFiveMinuteRate() * 60.0) +- .isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute)); ++ .isCloseTo(ratePerMinute, offset(0.1 * ratePerMinute)); + } + + @Test +@@ -56,7 +56,7 @@ public class MeterApproximationTest { + 38, TimeUnit.MINUTES); + + assertThat(meter.getFifteenMinuteRate() * 60.0) +- .isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute)); ++ .isCloseTo(ratePerMinute, offset(0.1 * ratePerMinute)); + } + + private Meter simulateMetronome( +--- a/metrics-core/src/test/java/com/codahale/metrics/MeterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/MeterTest.java +@@ -10,7 +10,7 @@ import org.junit.Before; + import org.junit.Test; + + public class MeterTest { +- private final Clock clock = mock(Clock.class); ++ private final Clock clock = mock(); + private final Meter meter = new Meter(clock); + + @Before +@@ -20,15 +20,15 @@ public class MeterTest { + + @Test + public void startsOutWithNoRatesOrCount() { +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + +- assertThat(meter.getMeanRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(meter.getMeanRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(meter.getOneMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(meter.getOneMinuteRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(meter.getFiveMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(meter.getFiveMinuteRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(meter.getFifteenMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(meter.getFifteenMinuteRate()).isCloseTo(0.0, offset(0.001)); + } + + @Test +@@ -36,12 +36,12 @@ public class MeterTest { + meter.mark(); + meter.mark(2); + +- assertThat(meter.getMeanRate()).isEqualTo(0.3, offset(0.001)); ++ assertThat(meter.getMeanRate()).isCloseTo(0.3, offset(0.001)); + +- assertThat(meter.getOneMinuteRate()).isEqualTo(0.1840, offset(0.001)); ++ assertThat(meter.getOneMinuteRate()).isCloseTo(0.1840, offset(0.001)); + +- assertThat(meter.getFiveMinuteRate()).isEqualTo(0.1966, offset(0.001)); ++ assertThat(meter.getFiveMinuteRate()).isCloseTo(0.1966, offset(0.001)); + +- assertThat(meter.getFifteenMinuteRate()).isEqualTo(0.1988, offset(0.001)); ++ assertThat(meter.getFifteenMinuteRate()).isCloseTo(0.1988, offset(0.001)); + } + } +--- a/metrics-core/src/test/java/com/codahale/metrics/MetricRegistryListenerTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/MetricRegistryListenerTest.java +@@ -6,10 +6,10 @@ import static org.mockito.Mockito.verifyNoInteractions; + import org.junit.Test; + + public class MetricRegistryListenerTest { +- private final Counter counter = mock(Counter.class); +- private final Histogram histogram = mock(Histogram.class); +- private final Meter meter = mock(Meter.class); +- private final Timer timer = mock(Timer.class); ++ private final Counter counter = mock(); ++ private final Histogram histogram = mock(); ++ private final Meter meter = mock(); ++ private final Timer timer = mock(); + private final MetricRegistryListener listener = new MetricRegistryListener.Base() {}; + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/MetricRegistryTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/MetricRegistryTest.java +@@ -1,6 +1,7 @@ + package com.codahale.metrics; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.stream.Collectors.toSet; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.entry; + import static org.mockito.Mockito.mock; +@@ -10,20 +11,19 @@ import static org.mockito.Mockito.verify; + import java.util.HashMap; + import java.util.Map; + import java.util.Set; +-import java.util.stream.Collectors; + import org.junit.Assert; + import org.junit.Before; + import org.junit.Test; + + public class MetricRegistryTest { +- private final MetricRegistryListener listener = mock(MetricRegistryListener.class); ++ private final MetricRegistryListener listener = mock(); + private final MetricRegistry registry = new MetricRegistry(); + private final Gauge gauge = () -> ""; + private final SettableGauge settableGauge = new DefaultSettableGauge<>(""); +- private final Counter counter = mock(Counter.class); +- private final Histogram histogram = mock(Histogram.class); +- private final Meter meter = mock(Meter.class); +- private final Timer timer = mock(Timer.class); ++ private final Counter counter = mock(); ++ private final Histogram histogram = mock(); ++ private final Meter meter = mock(); ++ private final Timer timer = mock(); + + @Before + public void setUp() { +@@ -230,8 +230,8 @@ public class MetricRegistryTest { + verify(listener).onGaugeAdded("thing", gauge1); + } + +- @Test + @SuppressWarnings("rawtypes") ++ @Test + public void accessingACustomGaugeRegistersAndReusesIt() { + final MetricRegistry.MetricSupplier supplier = () -> gauge; + final Gauge gauge1 = registry.gauge("thing", supplier); +@@ -261,7 +261,7 @@ public class MetricRegistryTest { + registry.register("meter", meter); + registry.register("timer", timer); + +- final MetricRegistryListener other = mock(MetricRegistryListener.class); ++ final MetricRegistryListener other = mock(); + registry.addListener(other); + + verify(other).onGaugeAdded("gauge", gauge); +@@ -383,7 +383,7 @@ public class MetricRegistryTest { + MetricRegistry other = new MetricRegistry(); + other.register("gauge", gauge); + registry.register("nested", other); +- assertThat(registry.getNames()).containsOnly("nested.gauge"); ++ assertThat(registry.getNames()).containsExactly("nested.gauge"); + } + + @Test +@@ -391,8 +391,8 @@ public class MetricRegistryTest { + assertThat(name("one", "two", "three")).isEqualTo("one.two.three"); + } + +- @Test + @SuppressWarnings("NullArgumentToVariableArgMethod") ++ @Test + public void elidesNullValuesFromNamesWhenOnlyOneNullPassedIn() { + assertThat(name("one", (String) null)).isEqualTo("one"); + } +@@ -456,7 +456,7 @@ public class MetricRegistryTest { + Set childMetrics = child.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + } + + @Test +@@ -474,7 +474,7 @@ public class MetricRegistryTest { + Set childMetrics = child.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + } + + @Test +@@ -498,14 +498,13 @@ public class MetricRegistryTest { + Set deepChildMetrics = deepChild.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + + assertThat(childMetrics) +- .containsAll( +- deepChildMetrics.stream().map(m -> "deep-child." + m).collect(Collectors.toSet())); ++ .containsAll(deepChildMetrics.stream().map(m -> "deep-child." + m).collect(toSet())); + +- assertThat(deepChildMetrics.size()).isEqualTo(3); +- assertThat(childMetrics.size()).isEqualTo(5); ++ assertThat(deepChildMetrics).hasSize(3); ++ assertThat(childMetrics).hasSize(5); + } + + @Test +@@ -523,7 +522,7 @@ public class MetricRegistryTest { + Set childMetrics = child.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + + assertThat(childMetrics).doesNotContain("test-1"); + } +@@ -546,7 +545,7 @@ public class MetricRegistryTest { + Set childMetrics = child.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + + assertThat(childMetrics).doesNotContain("test-1", "test-3"); + } +@@ -572,16 +571,15 @@ public class MetricRegistryTest { + Set deepChildMetrics = deepChild.getMetrics().keySet(); + + assertThat(parentMetrics) +- .isEqualTo(childMetrics.stream().map(m -> "child." + m).collect(Collectors.toSet())); ++ .hasSameElementsAs(childMetrics.stream().map(m -> "child." + m).collect(toSet())); + + assertThat(childMetrics) +- .containsAll( +- deepChildMetrics.stream().map(m -> "deep-child." + m).collect(Collectors.toSet())); ++ .containsAll(deepChildMetrics.stream().map(m -> "deep-child." + m).collect(toSet())); + + assertThat(deepChildMetrics).doesNotContain("test-2"); + +- assertThat(deepChildMetrics.size()).isEqualTo(1); +- assertThat(childMetrics.size()).isEqualTo(3); ++ assertThat(deepChildMetrics).hasSize(1); ++ assertThat(childMetrics).hasSize(3); + } + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/NoopMetricRegistryTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/NoopMetricRegistryTest.java +@@ -1,7 +1,7 @@ + package com.codahale.metrics; + + import static org.assertj.core.api.Assertions.assertThat; +-import static org.assertj.core.api.Assertions.assertThatNullPointerException; ++import static org.assertj.core.api.Assertions.assertThatThrownBy; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.never; + import static org.mockito.Mockito.verify; +@@ -13,13 +13,13 @@ import org.junit.Before; + import org.junit.Test; + + public class NoopMetricRegistryTest { +- private final MetricRegistryListener listener = mock(MetricRegistryListener.class); ++ private final MetricRegistryListener listener = mock(); + private final NoopMetricRegistry registry = new NoopMetricRegistry(); + private final Gauge gauge = () -> ""; +- private final Counter counter = mock(Counter.class); +- private final Histogram histogram = mock(Histogram.class); +- private final Meter meter = mock(Meter.class); +- private final Timer timer = mock(Timer.class); ++ private final Counter counter = mock(); ++ private final Histogram histogram = mock(); ++ private final Meter meter = mock(); ++ private final Timer timer = mock(); + + @Before + public void setUp() { +@@ -218,8 +218,8 @@ public class NoopMetricRegistryTest { + verify(listener, never()).onGaugeAdded("thing", gauge1); + } + +- @Test + @SuppressWarnings("rawtypes") ++ @Test + public void accessingACustomGaugeRegistersAndReusesIt() { + final MetricRegistry.MetricSupplier supplier = () -> gauge; + final Gauge gauge1 = registry.gauge("thing", supplier); +@@ -240,7 +240,7 @@ public class NoopMetricRegistryTest { + registry.register("meter", meter); + registry.register("timer", timer); + +- final MetricRegistryListener other = mock(MetricRegistryListener.class); ++ final MetricRegistryListener other = mock(); + registry.addListener(other); + + verify(other, never()).onGaugeAdded("gauge", gauge); +@@ -488,8 +488,8 @@ public class NoopMetricRegistryTest { + @Test + public void registerNullMetric() { + MetricRegistry registry = new NoopMetricRegistry(); +- assertThatNullPointerException() +- .isThrownBy(() -> registry.register("any_name", null)) +- .withMessage("metric == null"); ++ assertThatThrownBy(() -> registry.register("any_name", null)) ++ .isInstanceOf(NullPointerException.class) ++ .hasMessage("metric == null"); + } + } +--- a/metrics-core/src/test/java/com/codahale/metrics/RatioGaugeTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/RatioGaugeTest.java +@@ -9,7 +9,7 @@ public class RatioGaugeTest { + public void ratiosAreHumanReadable() { + final RatioGauge.Ratio ratio = RatioGauge.Ratio.of(100, 200); + +- assertThat(ratio.toString()).isEqualTo("100.0:200.0"); ++ assertThat(ratio).hasToString("100.0:200.0"); + } + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/ScheduledReporterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/ScheduledReporterTest.java +@@ -26,12 +26,12 @@ import org.junit.Test; + + public class ScheduledReporterTest { + private final Gauge gauge = () -> ""; +- private final Counter counter = mock(Counter.class); +- private final Histogram histogram = mock(Histogram.class); +- private final Meter meter = mock(Meter.class); +- private final Timer timer = mock(Timer.class); ++ private final Counter counter = mock(); ++ private final Histogram histogram = mock(); ++ private final Meter meter = mock(); ++ private final Timer timer = mock(); + +- private final ScheduledExecutorService mockExecutor = mock(ScheduledExecutorService.class); ++ private final ScheduledExecutorService mockExecutor = mock(); + private final ScheduledExecutorService customExecutor = + Executors.newSingleThreadScheduledExecutor(); + private final ScheduledExecutorService externalExecutor = +@@ -145,7 +145,7 @@ public class ScheduledReporterTest { + public void shouldUsePeriodAsInitialDelayIfNotSpecifiedOtherwise() throws Exception { + reporterWithCustomMockExecutor.start(200, TimeUnit.MILLISECONDS); + +- verify(mockExecutor, times(1)) ++ verify(mockExecutor) + .scheduleWithFixedDelay(any(Runnable.class), eq(200L), eq(200L), eq(TimeUnit.MILLISECONDS)); + } + +@@ -295,7 +295,7 @@ public class ScheduledReporterTest { + + Thread.sleep(1_000); + +- verify(reporter, times(1)) ++ verify(reporter) + .report( + map("gauge", gauge), + map("counter", counter), +--- a/metrics-core/src/test/java/com/codahale/metrics/SharedMetricRegistriesTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/SharedMetricRegistriesTest.java +@@ -29,7 +29,7 @@ public class SharedMetricRegistriesTest { + public void hasASetOfNames() { + SharedMetricRegistries.getOrCreate("one"); + +- assertThat(SharedMetricRegistries.names()).containsOnly("one"); ++ assertThat(SharedMetricRegistries.names()).containsExactly("one"); + } + + @Test +--- a/metrics-core/src/test/java/com/codahale/metrics/Slf4jReporterTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/Slf4jReporterTest.java +@@ -3,7 +3,6 @@ package com.codahale.metrics; + import static com.codahale.metrics.MetricAttribute.COUNT; + import static com.codahale.metrics.MetricAttribute.M1_RATE; + import static com.codahale.metrics.MetricAttribute.MEAN_RATE; +-import static com.codahale.metrics.MetricAttribute.MIN; + import static com.codahale.metrics.MetricAttribute.P50; + import static com.codahale.metrics.MetricAttribute.P999; + import static com.codahale.metrics.MetricAttribute.STDDEV; +@@ -22,9 +21,9 @@ import org.slf4j.Marker; + + public class Slf4jReporterTest { + +- private final Logger logger = mock(Logger.class); +- private final Marker marker = mock(Marker.class); +- private final MetricRegistry registry = mock(MetricRegistry.class); ++ private final Logger logger = mock(); ++ private final Marker marker = mock(); ++ private final MetricRegistry registry = mock(); + + /** + * The set of disabled metric attributes to pass to the Slf4jReporter builder in the default +@@ -79,7 +78,7 @@ public class Slf4jReporterTest { + } + + private Timer timer() { +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + + when(timer.getMeanRate()).thenReturn(2.0); +@@ -87,7 +86,7 @@ public class Slf4jReporterTest { + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -104,10 +103,10 @@ public class Slf4jReporterTest { + } + + private Histogram histogram() { +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +@@ -124,7 +123,7 @@ public class Slf4jReporterTest { + } + + private Meter meter() { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getMeanRate()).thenReturn(2.0); + when(meter.getOneMinuteRate()).thenReturn(3.0); +@@ -134,7 +133,7 @@ public class Slf4jReporterTest { + } + + private Counter counter() { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + return counter; + } +@@ -168,7 +167,7 @@ public class Slf4jReporterTest { + + @Test + public void reportsHistogramValuesAtErrorWithDisabledMetricAttributes() { +- disabledMetricAttributes = EnumSet.of(COUNT, MIN, P50); ++ disabledMetricAttributes = EnumSet.of(COUNT, MetricAttribute.MIN, P50); + reportsHistogramValuesAtError( + "type=HISTOGRAM, name=test.histogram, max=2, mean=3.0, " + + "stddev=5.0, p75=7.0, p95=8.0, p98=9.0, p99=10.0, p999=11.0"); +@@ -192,7 +191,7 @@ public class Slf4jReporterTest { + + @Test + public void reportsMeterValuesAtErrorWithDisabledMetricAttributes() { +- disabledMetricAttributes = EnumSet.of(MIN, P50, M1_RATE); ++ disabledMetricAttributes = EnumSet.of(MetricAttribute.MIN, P50, M1_RATE); + reportsMeterValuesAtError( + "type=METER, name=test.meter, count=1, m5_rate=4.0, m15_rate=5.0, " + + "mean_rate=2.0, rate_unit=events/second"); +@@ -218,7 +217,7 @@ public class Slf4jReporterTest { + + @Test + public void reportsTimerValuesAtErrorWithDisabledMetricAttributes() { +- disabledMetricAttributes = EnumSet.of(MIN, STDDEV, P999, MEAN_RATE); ++ disabledMetricAttributes = EnumSet.of(MetricAttribute.MIN, STDDEV, P999, MEAN_RATE); + reportsTimerValuesAtError( + "type=TIMER, name=test.another.timer, count=1, max=100.0, mean=200.0, " + + "p50=500.0, p75=600.0, p95=700.0, p98=800.0, p99=900.0, m1_rate=3.0, m5_rate=4.0, m15_rate=5.0, " +--- a/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowArrayReservoirTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowArrayReservoirTest.java +@@ -16,7 +16,7 @@ public class SlidingTimeWindowArrayReservoirTest { + + @Test + public void storesMeasurementsWithDuplicateTicks() { +- final Clock clock = mock(Clock.class); ++ final Clock clock = mock(); + final SlidingTimeWindowArrayReservoir reservoir = + new SlidingTimeWindowArrayReservoir(10, NANOSECONDS, clock); + +@@ -30,7 +30,7 @@ public class SlidingTimeWindowArrayReservoirTest { + + @Test + public void boundsMeasurementsToATimeWindow() { +- final Clock clock = mock(Clock.class); ++ final Clock clock = mock(); + final SlidingTimeWindowArrayReservoir reservoir = + new SlidingTimeWindowArrayReservoir(10, NANOSECONDS, clock); + +@@ -99,7 +99,7 @@ public class SlidingTimeWindowArrayReservoirTest { + // Set the clock to overflow in (2*window+1)ns + final ManualClock clock = new ManualClock(); + clock.addNanos(Long.MAX_VALUE / 256 - 2 * window - clock.getTick()); +- assertThat(clock.getTick() * 256).isGreaterThan(0); ++ assertThat(clock.getTick() * 256).isPositive(); + + // Create the reservoir + final SlidingTimeWindowArrayReservoir reservoir = +--- a/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowMovingAveragesTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowMovingAveragesTest.java +@@ -44,7 +44,7 @@ public class SlidingTimeWindowMovingAveragesTest { + + SlidingTimeWindowMovingAverages stwm = new SlidingTimeWindowMovingAverages(clock); + +- assertThat(stwm.calculateIndexOfTick(Instant.ofEpochSecond(0L)), is(0)); ++ assertThat(stwm.calculateIndexOfTick(Instant.EPOCH), is(0)); + assertThat(stwm.calculateIndexOfTick(Instant.ofEpochSecond(1L)), is(1)); + } + +@@ -62,7 +62,7 @@ public class SlidingTimeWindowMovingAveragesTest { + } + + // verify that no cleanup happened yet +- assertThat(movingAverages.oldestBucketTime, is(Instant.ofEpochSecond(0L))); ++ assertThat(movingAverages.oldestBucketTime, is(Instant.EPOCH)); + + assertThat(meter.getOneMinuteRate(), is(60.0)); + assertThat(meter.getFiveMinuteRate(), is(300.0)); +@@ -83,7 +83,7 @@ public class SlidingTimeWindowMovingAveragesTest { + } + + // verify that at least one cleanup happened +- assertThat(movingAverages.oldestBucketTime, not(is(Instant.ofEpochSecond(0L)))); ++ assertThat(movingAverages.oldestBucketTime, not(is(Instant.EPOCH))); + + assertThat(meter.getOneMinuteRate(), is(60.0)); + assertThat(meter.getFiveMinuteRate(), is(300.0)); +--- a/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowReservoirTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/SlidingTimeWindowReservoirTest.java +@@ -12,7 +12,7 @@ import org.junit.Test; + public class SlidingTimeWindowReservoirTest { + @Test + public void storesMeasurementsWithDuplicateTicks() { +- final Clock clock = mock(Clock.class); ++ final Clock clock = mock(); + final SlidingTimeWindowReservoir reservoir = + new SlidingTimeWindowReservoir(10, NANOSECONDS, clock); + +@@ -26,7 +26,7 @@ public class SlidingTimeWindowReservoirTest { + + @Test + public void boundsMeasurementsToATimeWindow() { +- final Clock clock = mock(Clock.class); ++ final Clock clock = mock(); + when(clock.getTick()).thenReturn(0L); + + final SlidingTimeWindowReservoir reservoir = +@@ -72,7 +72,7 @@ public class SlidingTimeWindowReservoirTest { + + // Set the clock to overflow in (2*window+1)ns + clock.addNanos(Long.MAX_VALUE / 256 - 2 * window - clock.getTick()); +- assertThat(clock.getTick() * 256).isGreaterThan(0); ++ assertThat(clock.getTick() * 256).isPositive(); + + int updatesAfterThreshold = 0; + while (true) { +--- a/metrics-core/src/test/java/com/codahale/metrics/TimerTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/TimerTest.java +@@ -13,7 +13,7 @@ import java.util.concurrent.atomic.AtomicBoolean; + import org.junit.Test; + + public class TimerTest { +- private final Reservoir reservoir = mock(Reservoir.class); ++ private final Reservoir reservoir = mock(); + private final Clock clock = + new Clock() { + // a mock clock that increments its ticker by 50msec per call +@@ -28,20 +28,20 @@ public class TimerTest { + + @Test + public void hasRates() { +- assertThat(timer.getCount()).isZero(); ++ assertThat(timer.getCount()).isEqualTo(0); + +- assertThat(timer.getMeanRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(timer.getMeanRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(timer.getOneMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(timer.getOneMinuteRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(timer.getFiveMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(timer.getFiveMinuteRate()).isCloseTo(0.0, offset(0.001)); + +- assertThat(timer.getFifteenMinuteRate()).isEqualTo(0.0, offset(0.001)); ++ assertThat(timer.getFifteenMinuteRate()).isCloseTo(0.0, offset(0.001)); + } + + @Test + public void updatesTheCountOnUpdates() { +- assertThat(timer.getCount()).isZero(); ++ assertThat(timer.getCount()).isEqualTo(0); + + timer.update(1, TimeUnit.SECONDS); + +@@ -93,7 +93,7 @@ public class TimerTest { + + @Test + public void returnsTheSnapshotFromTheReservoir() { +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(reservoir.getSnapshot()).thenReturn(snapshot); + + assertThat(timer.getSnapshot()).isEqualTo(snapshot); +@@ -103,7 +103,7 @@ public class TimerTest { + public void ignoresNegativeValues() { + timer.update(-1, TimeUnit.SECONDS); + +- assertThat(timer.getCount()).isZero(); ++ assertThat(timer.getCount()).isEqualTo(0); + + verifyNoInteractions(reservoir); + } +@@ -121,14 +121,14 @@ public class TimerTest { + public void java8NegativeDuration() { + timer.update(Duration.ofMillis(-5678)); + +- assertThat(timer.getCount()).isZero(); ++ assertThat(timer.getCount()).isEqualTo(0); + + verifyNoInteractions(reservoir); + } + + @Test + public void tryWithResourcesWork() { +- assertThat(timer.getCount()).isZero(); ++ assertThat(timer.getCount()).isEqualTo(0); + + int dummy = 0; + try (Timer.Context context = timer.time()) { +--- a/metrics-core/src/test/java/com/codahale/metrics/UniformReservoirTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/UniformReservoirTest.java +@@ -5,8 +5,8 @@ import static org.assertj.core.api.Assertions.assertThat; + import org.junit.Test; + + public class UniformReservoirTest { +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void aReservoirOf100OutOf1000Elements() { + final UniformReservoir reservoir = new UniformReservoir(100); + for (int i = 0; i < 1000; i++) { +@@ -20,7 +20,7 @@ public class UniformReservoirTest { + assertThat(snapshot.size()).isEqualTo(100); + + for (double i : snapshot.getValues()) { +- assertThat(i).isLessThan(1000).isGreaterThanOrEqualTo(0); ++ assertThat(i).isLessThan(1000).isNotNegative(); + } + } + } +--- a/metrics-core/src/test/java/com/codahale/metrics/UniformSnapshotTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/UniformSnapshotTest.java +@@ -16,12 +16,12 @@ public class UniformSnapshotTest { + + @Test + public void smallQuantilesAreTheFirstValue() { +- assertThat(snapshot.getValue(0.0)).isEqualTo(1, offset(0.1)); ++ assertThat(snapshot.getValue(0.0)).isCloseTo(1, offset(0.1)); + } + + @Test + public void bigQuantilesAreTheLastValue() { +- assertThat(snapshot.getValue(1.0)).isEqualTo(5, offset(0.1)); ++ assertThat(snapshot.getValue(1.0)).isCloseTo(5, offset(0.1)); + } + + @Test(expected = IllegalArgumentException.class) +@@ -41,32 +41,32 @@ public class UniformSnapshotTest { + + @Test + public void hasAMedian() { +- assertThat(snapshot.getMedian()).isEqualTo(3, offset(0.1)); ++ assertThat(snapshot.getMedian()).isCloseTo(3, offset(0.1)); + } + + @Test + public void hasAp75() { +- assertThat(snapshot.get75thPercentile()).isEqualTo(4.5, offset(0.1)); ++ assertThat(snapshot.get75thPercentile()).isCloseTo(4.5, offset(0.1)); + } + + @Test + public void hasAp95() { +- assertThat(snapshot.get95thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get95thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp98() { +- assertThat(snapshot.get98thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get98thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp99() { +- assertThat(snapshot.get99thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get99thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp999() { +- assertThat(snapshot.get999thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get999thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test +@@ -125,7 +125,7 @@ public class UniformSnapshotTest { + + snapshot.dump(output); + +- assertThat(output.toString()).isEqualTo(String.format("1%n2%n3%n4%n5%n")); ++ assertThat(output).hasToString(String.format("1%n2%n3%n4%n5%n")); + } + + @Test +@@ -145,41 +145,41 @@ public class UniformSnapshotTest { + + @Test + public void calculatesTheStdDev() { +- assertThat(snapshot.getStdDev()).isEqualTo(1.5811, offset(0.0001)); ++ assertThat(snapshot.getStdDev()).isCloseTo(1.5811, offset(0.0001)); + } + + @Test + public void calculatesAMinOfZeroForAnEmptySnapshot() { + final Snapshot emptySnapshot = new UniformSnapshot(new long[] {}); + +- assertThat(emptySnapshot.getMin()).isZero(); ++ assertThat(emptySnapshot.getMin()).isEqualTo(0); + } + + @Test + public void calculatesAMaxOfZeroForAnEmptySnapshot() { + final Snapshot emptySnapshot = new UniformSnapshot(new long[] {}); + +- assertThat(emptySnapshot.getMax()).isZero(); ++ assertThat(emptySnapshot.getMax()).isEqualTo(0); + } + + @Test + public void calculatesAMeanOfZeroForAnEmptySnapshot() { + final Snapshot emptySnapshot = new UniformSnapshot(new long[] {}); + +- assertThat(emptySnapshot.getMean()).isZero(); ++ assertThat(emptySnapshot.getMean()).isEqualTo(0); + } + + @Test + public void calculatesAStdDevOfZeroForAnEmptySnapshot() { + final Snapshot emptySnapshot = new UniformSnapshot(new long[] {}); + +- assertThat(emptySnapshot.getStdDev()).isZero(); ++ assertThat(emptySnapshot.getStdDev()).isEqualTo(0); + } + + @Test + public void calculatesAStdDevOfZeroForASingletonSnapshot() { + final Snapshot singleItemSnapshot = new UniformSnapshot(new long[] {1}); + +- assertThat(singleItemSnapshot.getStdDev()).isZero(); ++ assertThat(singleItemSnapshot.getStdDev()).isEqualTo(0); + } + } +--- a/metrics-core/src/test/java/com/codahale/metrics/WeightedSnapshotTest.java ++++ b/metrics-core/src/test/java/com/codahale/metrics/WeightedSnapshotTest.java +@@ -2,6 +2,7 @@ package com.codahale.metrics; + + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.offset; ++import static org.mockito.ArgumentMatchers.any; + import static org.mockito.Mockito.doReturn; + import static org.mockito.Mockito.spy; + import static org.mockito.Mockito.when; +@@ -11,7 +12,6 @@ import java.io.ByteArrayOutputStream; + import java.util.ArrayList; + import java.util.List; + import org.junit.Test; +-import org.mockito.ArgumentMatchers; + + public class WeightedSnapshotTest { + +@@ -34,12 +34,12 @@ public class WeightedSnapshotTest { + + @Test + public void smallQuantilesAreTheFirstValue() { +- assertThat(snapshot.getValue(0.0)).isEqualTo(1.0, offset(0.1)); ++ assertThat(snapshot.getValue(0.0)).isCloseTo(1.0, offset(0.1)); + } + + @Test + public void bigQuantilesAreTheLastValue() { +- assertThat(snapshot.getValue(1.0)).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.getValue(1.0)).isCloseTo(5.0, offset(0.1)); + } + + @Test(expected = IllegalArgumentException.class) +@@ -59,32 +59,32 @@ public class WeightedSnapshotTest { + + @Test + public void hasAMedian() { +- assertThat(snapshot.getMedian()).isEqualTo(3.0, offset(0.1)); ++ assertThat(snapshot.getMedian()).isCloseTo(3.0, offset(0.1)); + } + + @Test + public void hasAp75() { +- assertThat(snapshot.get75thPercentile()).isEqualTo(4.0, offset(0.1)); ++ assertThat(snapshot.get75thPercentile()).isCloseTo(4.0, offset(0.1)); + } + + @Test + public void hasAp95() { +- assertThat(snapshot.get95thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get95thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp98() { +- assertThat(snapshot.get98thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get98thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp99() { +- assertThat(snapshot.get99thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get99thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test + public void hasAp999() { +- assertThat(snapshot.get999thPercentile()).isEqualTo(5.0, offset(0.1)); ++ assertThat(snapshot.get999thPercentile()).isCloseTo(5.0, offset(0.1)); + } + + @Test +@@ -104,7 +104,7 @@ public class WeightedSnapshotTest { + final List spyItems = spy(originalItems); + doReturn(originalItems.toArray(new WeightedSample[] {})) + .when(spyItems) +- .toArray(ArgumentMatchers.any(WeightedSample[].class)); ++ .toArray(any(WeightedSample[].class)); + when(spyItems.size()).thenReturn(4, 5); + + final Snapshot other = new WeightedSnapshot(spyItems); +@@ -119,7 +119,7 @@ public class WeightedSnapshotTest { + final List spyItems = spy(originalItems); + doReturn(originalItems.toArray(new WeightedSample[] {})) + .when(spyItems) +- .toArray(ArgumentMatchers.any(WeightedSample[].class)); ++ .toArray(any(WeightedSample[].class)); + when(spyItems.size()).thenReturn(6, 5); + + final Snapshot other = new WeightedSnapshot(spyItems); +@@ -133,7 +133,7 @@ public class WeightedSnapshotTest { + + snapshot.dump(output); + +- assertThat(output.toString()).isEqualTo(String.format("1%n2%n3%n4%n5%n")); ++ assertThat(output).hasToString(String.format("1%n2%n3%n4%n5%n")); + } + + @Test +@@ -153,7 +153,7 @@ public class WeightedSnapshotTest { + + @Test + public void calculatesTheStdDev() { +- assertThat(snapshot.getStdDev()).isEqualTo(1.2688, offset(0.0001)); ++ assertThat(snapshot.getStdDev()).isCloseTo(1.2688, offset(0.0001)); + } + + @Test +@@ -161,7 +161,7 @@ public class WeightedSnapshotTest { + final Snapshot emptySnapshot = + new WeightedSnapshot(weightedArray(new long[] {}, new double[] {})); + +- assertThat(emptySnapshot.getMin()).isZero(); ++ assertThat(emptySnapshot.getMin()).isEqualTo(0); + } + + @Test +@@ -169,7 +169,7 @@ public class WeightedSnapshotTest { + final Snapshot emptySnapshot = + new WeightedSnapshot(weightedArray(new long[] {}, new double[] {})); + +- assertThat(emptySnapshot.getMax()).isZero(); ++ assertThat(emptySnapshot.getMax()).isEqualTo(0); + } + + @Test +@@ -177,7 +177,7 @@ public class WeightedSnapshotTest { + final Snapshot emptySnapshot = + new WeightedSnapshot(weightedArray(new long[] {}, new double[] {})); + +- assertThat(emptySnapshot.getMean()).isZero(); ++ assertThat(emptySnapshot.getMean()).isEqualTo(0); + } + + @Test +@@ -185,7 +185,7 @@ public class WeightedSnapshotTest { + final Snapshot emptySnapshot = + new WeightedSnapshot(weightedArray(new long[] {}, new double[] {})); + +- assertThat(emptySnapshot.getStdDev()).isZero(); ++ assertThat(emptySnapshot.getStdDev()).isEqualTo(0); + } + + @Test +@@ -193,7 +193,7 @@ public class WeightedSnapshotTest { + final Snapshot singleItemSnapshot = + new WeightedSnapshot(weightedArray(new long[] {1}, new double[] {1.0})); + +- assertThat(singleItemSnapshot.getStdDev()).isZero(); ++ assertThat(singleItemSnapshot.getStdDev()).isEqualTo(0); + } + + @Test +--- a/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteRabbitMQ.java ++++ b/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteRabbitMQ.java +@@ -132,8 +132,7 @@ public class GraphiteRabbitMQ implements GraphiteSender { + final String sanitizedName = sanitize(name); + final String sanitizedValue = sanitize(value); + +- final String message = +- sanitizedName + ' ' + sanitizedValue + ' ' + Long.toString(timestamp) + '\n'; ++ final String message = sanitizedName + ' ' + sanitizedValue + ' ' + timestamp + '\n'; + channel.basicPublish(exchange, sanitizedName, null, message.getBytes(UTF_8)); + } catch (IOException e) { + failures++; +--- a/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java ++++ b/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java +@@ -4,10 +4,8 @@ import static com.codahale.metrics.MetricAttribute.COUNT; + import static com.codahale.metrics.MetricAttribute.M15_RATE; + import static com.codahale.metrics.MetricAttribute.M1_RATE; + import static com.codahale.metrics.MetricAttribute.M5_RATE; +-import static com.codahale.metrics.MetricAttribute.MAX; + import static com.codahale.metrics.MetricAttribute.MEAN; + import static com.codahale.metrics.MetricAttribute.MEAN_RATE; +-import static com.codahale.metrics.MetricAttribute.MIN; + import static com.codahale.metrics.MetricAttribute.P50; + import static com.codahale.metrics.MetricAttribute.P75; + import static com.codahale.metrics.MetricAttribute.P95; +@@ -15,6 +13,7 @@ import static com.codahale.metrics.MetricAttribute.P98; + import static com.codahale.metrics.MetricAttribute.P99; + import static com.codahale.metrics.MetricAttribute.P999; + import static com.codahale.metrics.MetricAttribute.STDDEV; ++import static java.util.Collections.emptySet; + + import com.codahale.metrics.Clock; + import com.codahale.metrics.Counter; +@@ -29,7 +28,6 @@ import com.codahale.metrics.ScheduledReporter; + import com.codahale.metrics.Snapshot; + import com.codahale.metrics.Timer; + import java.io.IOException; +-import java.util.Collections; + import java.util.Locale; + import java.util.Map; + import java.util.Set; +@@ -83,7 +81,7 @@ public class GraphiteReporter extends ScheduledReporter { + this.filter = MetricFilter.ALL; + this.executor = null; + this.shutdownExecutorOnStop = true; +- this.disabledMetricAttributes = Collections.emptySet(); ++ this.disabledMetricAttributes = emptySet(); + this.addMetricAttributesAsTags = false; + this.floatingPointFormatter = DEFAULT_FP_FORMATTER; + } +@@ -453,9 +451,9 @@ public class GraphiteReporter extends ScheduledReporter { + + private void reportTimer(String name, Timer timer, long timestamp) throws IOException { + final Snapshot snapshot = timer.getSnapshot(); +- sendIfEnabled(MAX, name, convertDuration(snapshot.getMax()), timestamp); ++ sendIfEnabled(MetricAttribute.MAX, name, convertDuration(snapshot.getMax()), timestamp); + sendIfEnabled(MEAN, name, convertDuration(snapshot.getMean()), timestamp); +- sendIfEnabled(MIN, name, convertDuration(snapshot.getMin()), timestamp); ++ sendIfEnabled(MetricAttribute.MIN, name, convertDuration(snapshot.getMin()), timestamp); + sendIfEnabled(STDDEV, name, convertDuration(snapshot.getStdDev()), timestamp); + sendIfEnabled(P50, name, convertDuration(snapshot.getMedian()), timestamp); + sendIfEnabled(P75, name, convertDuration(snapshot.get75thPercentile()), timestamp); +@@ -478,9 +476,9 @@ public class GraphiteReporter extends ScheduledReporter { + throws IOException { + final Snapshot snapshot = histogram.getSnapshot(); + sendIfEnabled(COUNT, name, histogram.getCount(), timestamp); +- sendIfEnabled(MAX, name, snapshot.getMax(), timestamp); ++ sendIfEnabled(MetricAttribute.MAX, name, snapshot.getMax(), timestamp); + sendIfEnabled(MEAN, name, snapshot.getMean(), timestamp); +- sendIfEnabled(MIN, name, snapshot.getMin(), timestamp); ++ sendIfEnabled(MetricAttribute.MIN, name, snapshot.getMin(), timestamp); + sendIfEnabled(STDDEV, name, snapshot.getStdDev(), timestamp); + sendIfEnabled(P50, name, snapshot.getMedian(), timestamp); + sendIfEnabled(P75, name, snapshot.get75thPercentile(), timestamp); +--- a/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteUDP.java ++++ b/metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteUDP.java +@@ -63,7 +63,7 @@ public class GraphiteUDP implements GraphiteSender { + @Override + public void send(String name, String value, long timestamp) throws IOException { + try { +- String str = sanitize(name) + ' ' + sanitize(value) + ' ' + Long.toString(timestamp) + '\n'; ++ String str = sanitize(name) + ' ' + sanitize(value) + ' ' + timestamp + '\n'; + ByteBuffer byteBuffer = ByteBuffer.wrap(str.getBytes(UTF_8)); + datagramChannel.send(byteBuffer, address); + this.failures = 0; +--- a/metrics-graphite/src/main/java/com/codahale/metrics/graphite/PickledGraphite.java ++++ b/metrics-graphite/src/main/java/com/codahale/metrics/graphite/PickledGraphite.java +@@ -249,7 +249,7 @@ public class PickledGraphite implements GraphiteSender { + * message to graphite 3. Clear out the list of metrics + */ + private void writeMetrics() throws IOException { +- if (metrics.size() > 0) { ++ if (!metrics.isEmpty()) { + try { + byte[] payload = pickleMetrics(metrics); + byte[] header = ByteBuffer.allocate(4).putInt(payload.length).array(); +--- a/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteRabbitMQTest.java ++++ b/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteRabbitMQTest.java +@@ -8,7 +8,6 @@ import static org.mockito.Mockito.anyString; + import static org.mockito.Mockito.atMost; + import static org.mockito.Mockito.doThrow; + import static org.mockito.Mockito.mock; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -21,13 +20,13 @@ import org.junit.Before; + import org.junit.Test; + + public class GraphiteRabbitMQTest { +- private final ConnectionFactory connectionFactory = mock(ConnectionFactory.class); +- private final Connection connection = mock(Connection.class); +- private final Channel channel = mock(Channel.class); ++ private final ConnectionFactory connectionFactory = mock(); ++ private final Connection connection = mock(); ++ private final Channel channel = mock(); + +- private final ConnectionFactory bogusConnectionFactory = mock(ConnectionFactory.class); +- private final Connection bogusConnection = mock(Connection.class); +- private final Channel bogusChannel = mock(Channel.class); ++ private final ConnectionFactory bogusConnectionFactory = mock(); ++ private final Connection bogusConnection = mock(); ++ private final Channel bogusChannel = mock(); + + private final GraphiteRabbitMQ graphite = new GraphiteRabbitMQ(connectionFactory, "graphite"); + +@@ -92,10 +91,9 @@ public class GraphiteRabbitMQTest { + + String expectedMessage = "name value 100\n"; + +- verify(channel, times(1)) +- .basicPublish("graphite", "name", null, expectedMessage.getBytes(UTF_8)); ++ verify(channel).basicPublish("graphite", "name", null, expectedMessage.getBytes(UTF_8)); + +- assertThat(graphite.getFailures()).isZero(); ++ assertThat(graphite.getFailures()).isEqualTo(0); + } + + @Test +@@ -105,10 +103,10 @@ public class GraphiteRabbitMQTest { + + String expectedMessage = "name-to-sanitize value-to-sanitize 100\n"; + +- verify(channel, times(1)) ++ verify(channel) + .basicPublish("graphite", "name-to-sanitize", null, expectedMessage.getBytes(UTF_8)); + +- assertThat(graphite.getFailures()).isZero(); ++ assertThat(graphite.getFailures()).isEqualTo(0); + } + + @Test +--- a/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java ++++ b/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java +@@ -1,5 +1,6 @@ + package com.codahale.metrics.graphite; + ++import static java.util.Collections.emptySet; + import static org.mockito.Mockito.doThrow; + import static org.mockito.Mockito.inOrder; + import static org.mockito.Mockito.mock; +@@ -21,7 +22,6 @@ import com.codahale.metrics.Timer; + import java.net.UnknownHostException; + import java.text.DecimalFormat; + import java.text.DecimalFormatSymbols; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.Locale; + import java.util.Set; +@@ -34,9 +34,9 @@ import org.mockito.InOrder; + + public class GraphiteReporterTest { + private final long timestamp = 1000198; +- private final Clock clock = mock(Clock.class); +- private final Graphite graphite = mock(Graphite.class); +- private final MetricRegistry registry = mock(MetricRegistry.class); ++ private final Clock clock = mock(); ++ private final Graphite graphite = mock(); ++ private final MetricRegistry registry = mock(); + private final GraphiteReporter reporter = + GraphiteReporter.forRegistry(registry) + .withClock(clock) +@@ -44,7 +44,7 @@ public class GraphiteReporterTest { + .convertRatesTo(TimeUnit.SECONDS) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .filter(MetricFilter.ALL) +- .disabledMetricAttributes(Collections.emptySet()) ++ .disabledMetricAttributes(emptySet()) + .build(graphite); + + private final GraphiteReporter minuteRateReporter = +@@ -54,7 +54,7 @@ public class GraphiteReporterTest { + .convertRatesTo(TimeUnit.MINUTES) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .filter(MetricFilter.ALL) +- .disabledMetricAttributes(Collections.emptySet()) ++ .disabledMetricAttributes(emptySet()) + .build(graphite); + + @Before +@@ -174,7 +174,7 @@ public class GraphiteReporterTest { + .convertRatesTo(TimeUnit.SECONDS) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .filter(MetricFilter.ALL) +- .disabledMetricAttributes(Collections.emptySet()) ++ .disabledMetricAttributes(emptySet()) + .withFloatingPointFormatter(formatter::format) + .build(graphite)) { + reportGaugeValue(graphiteReporter, 0.000045322); +@@ -216,7 +216,7 @@ public class GraphiteReporterTest { + + @Test + public void reportsCounters() throws Exception { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + + reporter.report(map(), map("counter", counter), map(), map(), map()); +@@ -232,10 +232,10 @@ public class GraphiteReporterTest { + + @Test + public void reportsHistograms() throws Exception { +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +@@ -272,7 +272,7 @@ public class GraphiteReporterTest { + + @Test + public void reportsMeters() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getOneMinuteRate()).thenReturn(2.0); + when(meter.getFiveMinuteRate()).thenReturn(3.0); +@@ -296,7 +296,7 @@ public class GraphiteReporterTest { + + @Test + public void reportsMetersInMinutes() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getOneMinuteRate()).thenReturn(2.0); + when(meter.getFiveMinuteRate()).thenReturn(3.0); +@@ -321,14 +321,14 @@ public class GraphiteReporterTest { + + @Test + public void reportsTimers() throws Exception { +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + when(timer.getMeanRate()).thenReturn(2.0); + when(timer.getOneMinuteRate()).thenReturn(3.0); + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -395,14 +395,14 @@ public class GraphiteReporterTest { + + @Test + public void disabledMetricsAttribute() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getOneMinuteRate()).thenReturn(2.0); + when(meter.getFiveMinuteRate()).thenReturn(3.0); + when(meter.getFifteenMinuteRate()).thenReturn(4.0); + when(meter.getMeanRate()).thenReturn(5.0); + +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(11L); + + Set disabledMetricAttributes = +@@ -433,7 +433,7 @@ public class GraphiteReporterTest { + + @Test + public void sendsMetricAttributesAsTagsIfEnabled() throws Exception { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + + getReporterThatSendsMetricAttributesAsTags() +@@ -459,7 +459,7 @@ public class GraphiteReporterTest { + MetricFilter.ALL, + null, + false, +- Collections.emptySet(), ++ emptySet(), + false) { + @Override + protected String format(double v) { +@@ -475,7 +475,7 @@ public class GraphiteReporterTest { + .convertRatesTo(TimeUnit.SECONDS) + .convertDurationsTo(TimeUnit.MILLISECONDS) + .filter(MetricFilter.ALL) +- .disabledMetricAttributes(Collections.emptySet()) ++ .disabledMetricAttributes(emptySet()) + .addMetricAttributesAsTags(true) + .build(graphite); + } +--- a/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteTest.java ++++ b/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteTest.java +@@ -26,11 +26,11 @@ import org.junit.Test; + public class GraphiteTest { + private final String host = "example.com"; + private final int port = 1234; +- private final SocketFactory socketFactory = mock(SocketFactory.class); ++ private final SocketFactory socketFactory = mock(); + private final InetSocketAddress address = new InetSocketAddress(host, port); + +- private final Socket socket = mock(Socket.class); +- private final ByteArrayOutputStream output = spy(ByteArrayOutputStream.class); ++ private final Socket socket = mock(); ++ private final ByteArrayOutputStream output = spy(); + + @Before + public void setUp() throws Exception { +@@ -84,7 +84,7 @@ public class GraphiteTest { + @Test + public void measuresFailures() throws IOException { + try (Graphite graphite = new Graphite(address, socketFactory)) { +- assertThat(graphite.getFailures()).isZero(); ++ assertThat(graphite.getFailures()).isEqualTo(0); + } + } + +--- a/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java ++++ b/metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java +@@ -1,13 +1,13 @@ + package com.codahale.metrics.graphite; + + import static org.assertj.core.api.Assertions.assertThat; ++import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.verify; + + import java.net.InetSocketAddress; + import java.nio.ByteBuffer; + import java.nio.channels.DatagramChannel; + import org.junit.Test; +-import org.mockito.Mockito; + + public class GraphiteUDPTest { + +@@ -30,7 +30,7 @@ public class GraphiteUDPTest { + @Test + public void writesValue() throws Exception { + graphiteUDP = new GraphiteUDP(host, port); +- DatagramChannel mockDatagramChannel = Mockito.mock(DatagramChannel.class); ++ DatagramChannel mockDatagramChannel = mock(); + graphiteUDP.setDatagramChannel(mockDatagramChannel); + graphiteUDP.setAddress(new InetSocketAddress(host, port)); + +--- a/metrics-graphite/src/test/java/com/codahale/metrics/graphite/PickledGraphiteTest.java ++++ b/metrics-graphite/src/test/java/com/codahale/metrics/graphite/PickledGraphiteTest.java +@@ -32,12 +32,12 @@ import org.python.core.PyList; + import org.python.core.PyTuple; + + public class PickledGraphiteTest { +- private final SocketFactory socketFactory = mock(SocketFactory.class); ++ private final SocketFactory socketFactory = mock(); + private final InetSocketAddress address = new InetSocketAddress("example.com", 1234); + private final PickledGraphite graphite = new PickledGraphite(address, socketFactory, UTF_8, 2); + +- private final Socket socket = mock(Socket.class); +- private final ByteArrayOutputStream output = spy(ByteArrayOutputStream.class); ++ private final Socket socket = mock(); ++ private final ByteArrayOutputStream output = spy(); + + private CompiledScript unpickleScript; + +--- a/metrics-healthchecks/src/main/java/com/codahale/metrics/health/AsyncHealthCheckDecorator.java ++++ b/metrics-healthchecks/src/main/java/com/codahale/metrics/health/AsyncHealthCheckDecorator.java +@@ -29,10 +29,10 @@ public class AsyncHealthCheckDecorator extends HealthCheck implements Runnable { + this.healthyTtl = + async.unit().toMillis(async.healthyTtl() <= 0 ? 2 * async.period() : async.healthyTtl()); + result = +- Async.InitialState.HEALTHY.equals(async.initialState()) ++ Async.InitialState.HEALTHY == async.initialState() + ? Result.healthy(NO_RESULT_YET_MESSAGE) + : Result.unhealthy(NO_RESULT_YET_MESSAGE); +- if (Async.ScheduleType.FIXED_RATE.equals(async.scheduleType())) { ++ if (Async.ScheduleType.FIXED_RATE == async.scheduleType()) { + future = + executorService.scheduleAtFixedRate( + this, async.initialDelay(), async.period(), async.unit()); +--- a/metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java ++++ b/metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java +@@ -1,11 +1,12 @@ + package com.codahale.metrics.health; + ++import static java.util.Collections.unmodifiableMap; ++ + import com.codahale.metrics.Clock; + import java.time.Instant; + import java.time.ZoneId; + import java.time.ZonedDateTime; + import java.time.format.DateTimeFormatter; +-import java.util.Collections; + import java.util.LinkedHashMap; + import java.util.Map; + import java.util.concurrent.TimeUnit; +@@ -124,7 +125,7 @@ public abstract class HealthCheck { + this.healthy = isHealthy; + this.message = message; + this.error = error; +- this.details = details == null ? null : Collections.unmodifiableMap(details); ++ this.details = details == null ? null : unmodifiableMap(details); + this.time = clock.getTime(); + } + +@@ -163,7 +164,7 @@ public abstract class HealthCheck { + */ + public String getTimestamp() { + Instant currentInstant = Instant.ofEpochMilli(time); +- ZonedDateTime zonedDateTime = ZonedDateTime.ofInstant(currentInstant, ZoneId.systemDefault()); ++ ZonedDateTime zonedDateTime = currentInstant.atZone(ZoneId.systemDefault()); + return DATE_FORMAT_PATTERN.format(zonedDateTime); + } + +@@ -219,8 +220,7 @@ public abstract class HealthCheck { + int result = healthy ? 1 : 0; + result = PRIME * result + (message != null ? message.hashCode() : 0); + result = PRIME * result + (error != null ? error.hashCode() : 0); +- result = PRIME * result + (Long.hashCode(time)); +- return result; ++ return PRIME * result + (Long.hashCode(time)); + } + + @Override +@@ -238,7 +238,7 @@ public abstract class HealthCheck { + if (details != null) { + for (Map.Entry e : details.entrySet()) { + builder.append(", "); +- builder.append(e.getKey()).append("=").append(String.valueOf(e.getValue())); ++ builder.append(e.getKey()).append("=").append(e.getValue()); + } + } + builder.append('}'); +--- a/metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java ++++ b/metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java +@@ -1,9 +1,10 @@ + package com.codahale.metrics.health; + + import static com.codahale.metrics.health.HealthCheck.Result; ++import static java.util.Collections.unmodifiableSortedMap; ++import static java.util.Collections.unmodifiableSortedSet; + + import com.codahale.metrics.health.annotation.Async; +-import java.util.Collections; + import java.util.HashMap; + import java.util.List; + import java.util.Map; +@@ -128,7 +129,7 @@ public class HealthCheckRegistry { + * @return the names of all registered health checks + */ + public SortedSet getNames() { +- return Collections.unmodifiableSortedSet(new TreeSet<>(healthChecks.keySet())); ++ return unmodifiableSortedSet(new TreeSet<>(healthChecks.keySet())); + } + + /** +@@ -180,7 +181,7 @@ public class HealthCheckRegistry { + results.put(entry.getKey(), result); + } + } +- return Collections.unmodifiableSortedMap(results); ++ return unmodifiableSortedMap(results); + } + + /** +@@ -208,7 +209,7 @@ public class HealthCheckRegistry { + final String name = entry.getKey(); + final HealthCheck healthCheck = entry.getValue(); + if (filter.matches(name, healthCheck)) { +- futures.put(name, executor.submit(() -> healthCheck.execute())); ++ futures.put(name, executor.submit(healthCheck::execute)); + } + } + +@@ -222,7 +223,7 @@ public class HealthCheckRegistry { + } + } + +- return Collections.unmodifiableSortedMap(results); ++ return unmodifiableSortedMap(results); + } + + private void onHealthCheckAdded(String name, HealthCheck healthCheck) { +--- a/metrics-healthchecks/src/test/java/com/codahale/metrics/health/AsyncHealthCheckDecoratorTest.java ++++ b/metrics-healthchecks/src/test/java/com/codahale/metrics/health/AsyncHealthCheckDecoratorTest.java +@@ -5,7 +5,6 @@ import static org.mockito.ArgumentCaptor.forClass; + import static org.mockito.ArgumentMatchers.any; + import static org.mockito.ArgumentMatchers.eq; + import static org.mockito.Mockito.mock; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -31,11 +30,11 @@ public class AsyncHealthCheckDecoratorTest { + .withMessage("Result was healthy but it expired 1 milliseconds ago") + .build(); + +- private final HealthCheck mockHealthCheck = mock(HealthCheck.class); +- private final ScheduledExecutorService mockExecutorService = mock(ScheduledExecutorService.class); ++ private final HealthCheck mockHealthCheck = mock(); ++ private final ScheduledExecutorService mockExecutorService = mock(); + + @SuppressWarnings("rawtypes") +- private final ScheduledFuture mockFuture = mock(ScheduledFuture.class); ++ private final ScheduledFuture mockFuture = mock(); + + @Test(expected = IllegalArgumentException.class) + public void nullHealthCheckTriggersInstantiationFailure() { +@@ -74,7 +73,7 @@ public class AsyncHealthCheckDecoratorTest { + AsyncHealthCheckDecorator asyncDecorator = + new AsyncHealthCheckDecorator(asyncHealthCheck, mockExecutorService); + +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate(any(Runnable.class), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); + assertThat(asyncDecorator.getHealthCheck()).isEqualTo(asyncHealthCheck); + assertThat(asyncDecorator.check().isHealthy()).isTrue(); +@@ -87,7 +86,7 @@ public class AsyncHealthCheckDecoratorTest { + AsyncHealthCheckDecorator asyncDecorator = + new AsyncHealthCheckDecorator(asyncHealthCheck, mockExecutorService); + +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleWithFixedDelay(any(Runnable.class), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); + assertThat(asyncDecorator.getHealthCheck()).isEqualTo(asyncHealthCheck); + } +@@ -102,8 +101,8 @@ public class AsyncHealthCheckDecoratorTest { + assertThat(asyncDecorator.check().isHealthy()).isFalse(); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void tearDownTriggersCancellation() throws Exception { + when(mockExecutorService.scheduleAtFixedRate( + any(Runnable.class), eq(0L), eq(1L), eq(TimeUnit.SECONDS))) +@@ -114,13 +113,13 @@ public class AsyncHealthCheckDecoratorTest { + new AsyncHealthCheckDecorator(new DefaultAsyncHealthCheck(), mockExecutorService); + asyncDecorator.tearDown(); + +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate(any(Runnable.class), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); +- verify(mockFuture, times(1)).cancel(eq(true)); ++ verify(mockFuture).cancel(true); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void afterFirstExecutionDecoratedHealthCheckResultIsProvided() throws Exception { + HealthCheck.Result expectedResult = HealthCheck.Result.healthy("AsyncHealthCheckTest"); + when(mockExecutorService.scheduleAtFixedRate( +@@ -133,7 +132,7 @@ public class AsyncHealthCheckDecoratorTest { + HealthCheck.Result initialResult = asyncDecorator.check(); + + ArgumentCaptor runnableCaptor = forClass(Runnable.class); +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate(runnableCaptor.capture(), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); + Runnable capturedRunnable = runnableCaptor.getValue(); + capturedRunnable.run(); +@@ -143,8 +142,8 @@ public class AsyncHealthCheckDecoratorTest { + assertThat(actualResult).isNotEqualTo(initialResult); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void exceptionInDecoratedHealthCheckWontAffectAsyncDecorator() throws Exception { + Exception exception = new Exception("TestException"); + when(mockExecutorService.scheduleAtFixedRate( +@@ -156,7 +155,7 @@ public class AsyncHealthCheckDecoratorTest { + new ConfigurableAsyncHealthCheck(exception), mockExecutorService); + + ArgumentCaptor runnableCaptor = forClass(Runnable.class); +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate(runnableCaptor.capture(), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); + Runnable capturedRunnable = runnableCaptor.getValue(); + capturedRunnable.run(); +@@ -173,7 +172,7 @@ public class AsyncHealthCheckDecoratorTest { + new AsyncHealthCheckDecorator(healthCheck, mockExecutorService, FIXED_CLOCK); + + ArgumentCaptor runnableCaptor = forClass(Runnable.class); +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate( + runnableCaptor.capture(), eq(0L), eq(1000L), eq(TimeUnit.MILLISECONDS)); + Runnable capturedRunnable = runnableCaptor.getValue(); +@@ -192,7 +191,7 @@ public class AsyncHealthCheckDecoratorTest { + new AsyncHealthCheckDecorator(healthCheck, mockExecutorService, FIXED_CLOCK); + + ArgumentCaptor runnableCaptor = forClass(Runnable.class); +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate( + runnableCaptor.capture(), eq(0L), eq(1000L), eq(TimeUnit.MILLISECONDS)); + Runnable capturedRunnable = runnableCaptor.getValue(); +@@ -210,7 +209,7 @@ public class AsyncHealthCheckDecoratorTest { + new AsyncHealthCheckDecorator(healthCheck, mockExecutorService, FIXED_CLOCK); + + ArgumentCaptor runnableCaptor = forClass(Runnable.class); +- verify(mockExecutorService, times(1)) ++ verify(mockExecutorService) + .scheduleAtFixedRate(runnableCaptor.capture(), eq(0L), eq(1L), eq(TimeUnit.SECONDS)); + Runnable capturedRunnable = runnableCaptor.getValue(); + capturedRunnable.run(); +--- a/metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckRegistryTest.java ++++ b/metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckRegistryTest.java +@@ -23,21 +23,21 @@ import org.junit.Test; + import org.mockito.ArgumentCaptor; + + public class HealthCheckRegistryTest { +- private final ScheduledExecutorService executorService = mock(ScheduledExecutorService.class); ++ private final ScheduledExecutorService executorService = mock(); + private final HealthCheckRegistry registry = new HealthCheckRegistry(executorService); +- private final HealthCheckRegistryListener listener = mock(HealthCheckRegistryListener.class); ++ private final HealthCheckRegistryListener listener = mock(); + +- private final HealthCheck hc1 = mock(HealthCheck.class); +- private final HealthCheck hc2 = mock(HealthCheck.class); ++ private final HealthCheck hc1 = mock(); ++ private final HealthCheck hc2 = mock(); + +- private final HealthCheck.Result r1 = mock(HealthCheck.Result.class); +- private final HealthCheck.Result r2 = mock(HealthCheck.Result.class); ++ private final HealthCheck.Result r1 = mock(); ++ private final HealthCheck.Result r2 = mock(); + +- private final HealthCheck.Result ar = mock(HealthCheck.Result.class); ++ private final HealthCheck.Result ar = mock(); + private final HealthCheck ahc = new TestAsyncHealthCheck(ar); + + @SuppressWarnings("rawtypes") +- private final ScheduledFuture af = mock(ScheduledFuture.class); ++ private final ScheduledFuture af = mock(); + + @Before + @SuppressWarnings("unchecked") +@@ -96,7 +96,7 @@ public class HealthCheckRegistryTest { + + @Test + public void addingListenerCatchesExistingHealthChecks() { +- HealthCheckRegistryListener listener = mock(HealthCheckRegistryListener.class); ++ HealthCheckRegistryListener listener = mock(); + HealthCheckRegistry registry = new HealthCheckRegistry(); + registry.register("hc1", hc1); + registry.register("hc2", hc2); +@@ -110,7 +110,7 @@ public class HealthCheckRegistryTest { + + @Test + public void removedListenerDoesNotReceiveUpdates() { +- HealthCheckRegistryListener listener = mock(HealthCheckRegistryListener.class); ++ HealthCheckRegistryListener listener = mock(); + HealthCheckRegistry registry = new HealthCheckRegistry(); + registry.addListener(listener); + registry.register("hc1", hc1); +--- a/metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java ++++ b/metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java +@@ -29,7 +29,7 @@ public class HealthCheckTest { + } + } + +- private final HealthCheck underlying = mock(HealthCheck.class); ++ private final HealthCheck underlying = mock(); + private final HealthCheck healthCheck = new ExampleHealthCheck(underlying); + + @Test +@@ -89,7 +89,7 @@ public class HealthCheckTest { + + @Test + public void canHaveUnhealthyResultsWithExceptions() { +- final RuntimeException e = mock(RuntimeException.class); ++ final RuntimeException e = mock(); + when(e.getMessage()).thenReturn("oh noes"); + + final HealthCheck.Result result = HealthCheck.Result.unhealthy(e); +@@ -144,7 +144,7 @@ public class HealthCheckTest { + + @Test + public void canHaveUnHealthyBuilderWithDetailAndError() { +- final RuntimeException e = mock(RuntimeException.class); ++ final RuntimeException e = mock(); + when(e.getMessage()).thenReturn("oh noes"); + + final HealthCheck.Result result = +@@ -161,7 +161,7 @@ public class HealthCheckTest { + + @Test + public void returnsResultsWhenExecuted() { +- final HealthCheck.Result result = mock(HealthCheck.Result.class); ++ final HealthCheck.Result result = mock(); + when(underlying.execute()).thenReturn(result); + + assertThat(healthCheck.execute()).isEqualTo(result); +@@ -171,7 +171,7 @@ public class HealthCheckTest { + + @Test + public void wrapsExceptionsWhenExecuted() { +- final RuntimeException e = mock(RuntimeException.class); ++ final RuntimeException e = mock(); + when(e.getMessage()).thenReturn("oh noes"); + + when(underlying.execute()).thenThrow(e); +@@ -181,7 +181,7 @@ public class HealthCheckTest { + assertThat(actual.getMessage()).isEqualTo("oh noes"); + assertThat(actual.getError()).isEqualTo(e); + assertThat(actual.getDetails()).isNull(); +- assertThat(actual.getDuration()).isGreaterThanOrEqualTo(0); ++ assertThat(actual.getDuration()).isNotNegative(); + } + + @Test +--- a/metrics-healthchecks/src/test/java/com/codahale/metrics/health/SharedHealthCheckRegistriesTest.java ++++ b/metrics-healthchecks/src/test/java/com/codahale/metrics/health/SharedHealthCheckRegistriesTest.java +@@ -30,7 +30,7 @@ public class SharedHealthCheckRegistriesTest { + public void returnsSetOfCreatedRegistries() { + SharedHealthCheckRegistries.getOrCreate("db"); + +- assertThat(SharedHealthCheckRegistries.names()).containsOnly("db"); ++ assertThat(SharedHealthCheckRegistries.names()).containsExactly("db"); + } + + @Test +--- a/metrics-healthchecks/src/test/java/com/codahale/metrics/health/jvm/ThreadDeadlockHealthCheckTest.java ++++ b/metrics-healthchecks/src/test/java/com/codahale/metrics/health/jvm/ThreadDeadlockHealthCheckTest.java +@@ -1,12 +1,12 @@ + package com.codahale.metrics.health.jvm; + ++import static java.util.Collections.emptySet; + import static org.assertj.core.api.Assertions.assertThat; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.when; + + import com.codahale.metrics.health.HealthCheck; + import com.codahale.metrics.jvm.ThreadDeadlockDetector; +-import java.util.Collections; + import java.util.Set; + import java.util.TreeSet; + import org.junit.Test; +@@ -14,10 +14,10 @@ import org.junit.Test; + public class ThreadDeadlockHealthCheckTest { + @Test + public void isHealthyIfNoThreadsAreDeadlocked() { +- final ThreadDeadlockDetector detector = mock(ThreadDeadlockDetector.class); ++ final ThreadDeadlockDetector detector = mock(); + final ThreadDeadlockHealthCheck healthCheck = new ThreadDeadlockHealthCheck(detector); + +- when(detector.getDeadlockedThreads()).thenReturn(Collections.emptySet()); ++ when(detector.getDeadlockedThreads()).thenReturn(emptySet()); + + assertThat(healthCheck.execute().isHealthy()).isTrue(); + } +@@ -28,7 +28,7 @@ public class ThreadDeadlockHealthCheckTest { + threads.add("one"); + threads.add("two"); + +- final ThreadDeadlockDetector detector = mock(ThreadDeadlockDetector.class); ++ final ThreadDeadlockDetector detector = mock(); + final ThreadDeadlockHealthCheck healthCheck = new ThreadDeadlockHealthCheck(detector); + + when(detector.getDeadlockedThreads()).thenReturn(threads); +--- a/metrics-httpasyncclient/src/test/java/com/codahale/metrics/httpasyncclient/InstrumentedHttpClientsTimerTest.java ++++ b/metrics-httpasyncclient/src/test/java/com/codahale/metrics/httpasyncclient/InstrumentedHttpClientsTimerTest.java +@@ -45,7 +45,7 @@ public class InstrumentedHttpClientsTimerTest extends HttpClientTestBase { + chac.start(); + asyncHttpClient = chac; + +- Timer timer = mock(Timer.class); ++ Timer timer = mock(); + when(timer.time()).thenReturn(context); + when(metricRegistry.timer(any())).thenReturn(timer); + } +@@ -71,13 +71,13 @@ public class InstrumentedHttpClientsTimerTest extends HttpClientTestBase { + verify(context, timeout(200).times(1)).stop(); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void timerIsStoppedCorrectlyWithProvidedFutureCallbackCompleted() throws Exception { + HttpHost host = startServerWithGlobalRequestHandler(STATUS_OK); + HttpGet get = new HttpGet("/?q=something"); + +- FutureCallback futureCallback = mock(FutureCallback.class); ++ FutureCallback futureCallback = mock(); + + // Timer hasn't been stopped prior to executing the request + verify(context, never()).stop(); +@@ -98,14 +98,14 @@ public class InstrumentedHttpClientsTimerTest extends HttpClientTestBase { + verify(context, timeout(200).times(1)).stop(); + } + +- @Test + @SuppressWarnings("unchecked") ++ @Test + public void timerIsStoppedCorrectlyWithProvidedFutureCallbackFailed() throws Exception { + // There should be nothing listening on this port + HttpHost host = HttpHost.create(String.format("http://127.0.0.1:%d", findAvailableLocalPort())); + HttpGet get = new HttpGet("/?q=something"); + +- FutureCallback futureCallback = mock(FutureCallback.class); ++ FutureCallback futureCallback = mock(); + + // Timer hasn't been stopped prior to executing the request + verify(context, never()).stop(); +--- a/metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/InstrumentedHttpClientConnectionManagerTest.java ++++ b/metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/InstrumentedHttpClientConnectionManagerTest.java +@@ -4,12 +4,14 @@ import static junit.framework.TestCase.assertTrue; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.entry; + import static org.mockito.ArgumentMatchers.any; ++import static org.mockito.Mockito.atLeast; ++import static org.mockito.Mockito.mock; ++import static org.mockito.Mockito.verify; + + import com.codahale.metrics.MetricRegistry; + import org.junit.Assert; + import org.junit.Test; + import org.mockito.ArgumentCaptor; +-import org.mockito.Mockito; + + public class InstrumentedHttpClientConnectionManagerTest { + private final MetricRegistry metricRegistry = new MetricRegistry(); +@@ -36,7 +38,7 @@ public class InstrumentedHttpClientConnectionManagerTest { + + @Test + public void configurableViaBuilder() { +- final MetricRegistry registry = Mockito.mock(MetricRegistry.class); ++ final MetricRegistry registry = mock(); + + InstrumentedHttpClientConnectionManager.builder(registry) + .name("some-name") +@@ -45,7 +47,7 @@ public class InstrumentedHttpClientConnectionManagerTest { + .close(); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(String.class); +- Mockito.verify(registry, Mockito.atLeast(1)).registerGauge(argumentCaptor.capture(), any()); ++ verify(registry, atLeast(1)).registerGauge(argumentCaptor.capture(), any()); + assertTrue(argumentCaptor.getValue().contains("some-other-name")); + } + } +--- a/metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/InstrumentedHttpClientsTest.java ++++ b/metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/InstrumentedHttpClientsTest.java +@@ -22,9 +22,8 @@ import org.junit.Before; + import org.junit.Test; + + public class InstrumentedHttpClientsTest { +- private final HttpClientMetricNameStrategy metricNameStrategy = +- mock(HttpClientMetricNameStrategy.class); +- private final MetricRegistryListener registryListener = mock(MetricRegistryListener.class); ++ private final HttpClientMetricNameStrategy metricNameStrategy = mock(); ++ private final MetricRegistryListener registryListener = mock(); + private final MetricRegistry metricRegistry = new MetricRegistry(); + private final HttpClient client = + InstrumentedHttpClients.custom(metricRegistry, metricNameStrategy) +--- a/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedAsyncClientConnectionManagerTest.java ++++ b/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedAsyncClientConnectionManagerTest.java +@@ -4,12 +4,14 @@ import static junit.framework.TestCase.assertTrue; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.entry; + import static org.mockito.ArgumentMatchers.any; ++import static org.mockito.Mockito.atLeast; ++import static org.mockito.Mockito.mock; ++import static org.mockito.Mockito.verify; + + import com.codahale.metrics.MetricRegistry; + import org.junit.Assert; + import org.junit.Test; + import org.mockito.ArgumentCaptor; +-import org.mockito.Mockito; + + public class InstrumentedAsyncClientConnectionManagerTest { + private final MetricRegistry metricRegistry = new MetricRegistry(); +@@ -43,7 +45,7 @@ public class InstrumentedAsyncClientConnectionManagerTest { + + @Test + public void configurableViaBuilder() { +- final MetricRegistry registry = Mockito.mock(MetricRegistry.class); ++ final MetricRegistry registry = mock(); + + InstrumentedAsyncClientConnectionManager.builder(registry) + .name("some-name") +@@ -52,7 +54,7 @@ public class InstrumentedAsyncClientConnectionManagerTest { + .close(); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(String.class); +- Mockito.verify(registry, Mockito.atLeast(1)).registerGauge(argumentCaptor.capture(), any()); ++ verify(registry, atLeast(1)).registerGauge(argumentCaptor.capture(), any()); + assertTrue(argumentCaptor.getValue().contains("some-other-name")); + } + } +--- a/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java ++++ b/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java +@@ -1,5 +1,6 @@ + package com.codahale.metrics.httpclient5; + ++import static java.nio.charset.StandardCharsets.US_ASCII; + import static org.assertj.core.api.Assertions.assertThat; + import static org.awaitility.Awaitility.await; + import static org.junit.Assert.fail; +@@ -17,7 +18,6 @@ import com.sun.net.httpserver.HttpExchange; + import com.sun.net.httpserver.HttpServer; + import java.io.IOException; + import java.net.InetSocketAddress; +-import java.nio.charset.StandardCharsets; + import java.util.concurrent.CountDownLatch; + import java.util.concurrent.ExecutionException; + import java.util.concurrent.Future; +@@ -82,7 +82,7 @@ public class InstrumentedHttpAsyncClientsTest { + exchange -> { + exchange.sendResponseHeaders(200, 0L); + exchange.setStreams(null, null); +- exchange.getResponseBody().write("TEST".getBytes(StandardCharsets.US_ASCII)); ++ exchange.getResponseBody().write("TEST".getBytes(US_ASCII)); + exchange.close(); + }); + httpServer.start(); +@@ -187,7 +187,7 @@ public class InstrumentedHttpAsyncClientsTest { + exchange -> { + exchange.sendResponseHeaders(200, 0L); + exchange.setStreams(null, null); +- exchange.getResponseBody().write("TEST".getBytes(StandardCharsets.US_ASCII)); ++ exchange.getResponseBody().write("TEST".getBytes(US_ASCII)); + exchange.close(); + }); + httpServer.start(); +--- a/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientConnectionManagerTest.java ++++ b/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientConnectionManagerTest.java +@@ -4,12 +4,14 @@ import static junit.framework.TestCase.assertTrue; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.entry; + import static org.mockito.ArgumentMatchers.any; ++import static org.mockito.Mockito.atLeast; ++import static org.mockito.Mockito.mock; ++import static org.mockito.Mockito.verify; + + import com.codahale.metrics.MetricRegistry; + import org.junit.Assert; + import org.junit.Test; + import org.mockito.ArgumentCaptor; +-import org.mockito.Mockito; + + public class InstrumentedHttpClientConnectionManagerTest { + private final MetricRegistry metricRegistry = new MetricRegistry(); +@@ -41,7 +43,7 @@ public class InstrumentedHttpClientConnectionManagerTest { + + @Test + public void configurableViaBuilder() { +- final MetricRegistry registry = Mockito.mock(MetricRegistry.class); ++ final MetricRegistry registry = mock(); + + InstrumentedHttpClientConnectionManager.builder(registry) + .name("some-name") +@@ -50,7 +52,7 @@ public class InstrumentedHttpClientConnectionManagerTest { + .close(); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(String.class); +- Mockito.verify(registry, Mockito.atLeast(1)).registerGauge(argumentCaptor.capture(), any()); ++ verify(registry, atLeast(1)).registerGauge(argumentCaptor.capture(), any()); + assertTrue(argumentCaptor.getValue().contains("some-other-name")); + } + } +--- a/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientsTest.java ++++ b/metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientsTest.java +@@ -22,9 +22,8 @@ import org.junit.Before; + import org.junit.Test; + + public class InstrumentedHttpClientsTest { +- private final HttpClientMetricNameStrategy metricNameStrategy = +- mock(HttpClientMetricNameStrategy.class); +- private final MetricRegistryListener registryListener = mock(MetricRegistryListener.class); ++ private final HttpClientMetricNameStrategy metricNameStrategy = mock(); ++ private final MetricRegistryListener registryListener = mock(); + private final MetricRegistry metricRegistry = new MetricRegistry(); + private final HttpClient client = + InstrumentedHttpClients.custom(metricRegistry, metricNameStrategy) +--- a/metrics-jakarta-servlet/src/test/java/io/dropwizard/metrics/servlet/InstrumentedFilterContextListenerTest.java ++++ b/metrics-jakarta-servlet/src/test/java/io/dropwizard/metrics/servlet/InstrumentedFilterContextListenerTest.java +@@ -10,7 +10,7 @@ import jakarta.servlet.ServletContextEvent; + import org.junit.Test; + + public class InstrumentedFilterContextListenerTest { +- private final MetricRegistry registry = mock(MetricRegistry.class); ++ private final MetricRegistry registry = mock(); + private final InstrumentedFilterContextListener listener = + new InstrumentedFilterContextListener() { + @Override +@@ -21,9 +21,9 @@ public class InstrumentedFilterContextListenerTest { + + @Test + public void injectsTheMetricRegistryIntoTheServletContext() { +- final ServletContext context = mock(ServletContext.class); ++ final ServletContext context = mock(); + +- final ServletContextEvent event = mock(ServletContextEvent.class); ++ final ServletContextEvent event = mock(); + when(event.getServletContext()).thenReturn(context); + + listener.contextInitialized(event); +--- a/metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/HealthCheckServlet.java ++++ b/metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/HealthCheckServlet.java +@@ -83,7 +83,7 @@ public class HealthCheckServlet extends HttpServlet { + super.init(config); + + final ServletContext context = config.getServletContext(); +- if (null == registry) { ++ if (registry == null) { + final Object registryAttr = context.getAttribute(HEALTH_CHECK_REGISTRY); + if (registryAttr instanceof HealthCheckRegistry) { + this.registry = (HealthCheckRegistry) registryAttr; +--- a/metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java ++++ b/metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java +@@ -131,7 +131,7 @@ public class MetricsServlet extends HttpServlet { + super.init(config); + + final ServletContext context = config.getServletContext(); +- if (null == registry) { ++ if (registry == null) { + final Object registryAttr = context.getAttribute(METRICS_REGISTRY); + if (registryAttr instanceof MetricRegistry) { + this.registry = (MetricRegistry) registryAttr; +--- a/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java ++++ b/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java +@@ -4,7 +4,6 @@ import static org.assertj.core.api.Assertions.assertThat; + import static org.mockito.Mockito.eq; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.never; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -102,9 +101,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.getStatus()).isEqualTo(200); + assertThat(response.getContent()) + .isEqualTo( +- "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"" +- + EXPECTED_TIMESTAMP +- + "\"}}"); ++ "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"%s\"}}", ++ EXPECTED_TIMESTAMP); + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + } + +@@ -143,9 +141,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.getStatus()).isEqualTo(200); + assertThat(response.getContent()) + .isEqualTo( +- "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"" +- + EXPECTED_TIMESTAMP +- + "\"}}"); ++ "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"%s\"}}", ++ EXPECTED_TIMESTAMP); + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + } + +@@ -217,15 +214,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.getContent()) + .isEqualTo( + String.format( +- "{%n" +- + " \"fun\" : {%n" +- + " \"healthy\" : true,%n" +- + " \"message\" : \"foo bar 123\",%n" +- + " \"duration\" : 0,%n" +- + " \"timestamp\" : \"" +- + EXPECTED_TIMESTAMP +- + "\"" +- + "%n }%n}")); ++ "{%n \"fun\" : {%n \"healthy\" : true,%n \"message\" : \"foo bar 123\",%n \"duration\" : 0,%n \"timestamp\" : \"%s\"%n }%n}", ++ EXPECTED_TIMESTAMP)); + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + } + +@@ -240,25 +230,25 @@ public class HealthCheckServletTest extends AbstractServletTest { + @Test + public void constructorWithRegistryAsArgumentIsUsedInPreferenceOverServletConfig() + throws Exception { +- final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final HealthCheckRegistry healthCheckRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + + final io.dropwizard.metrics.servlets.HealthCheckServlet healthCheckServlet = + new io.dropwizard.metrics.servlets.HealthCheckServlet(healthCheckRegistry); + healthCheckServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); ++ verify(servletConfig).getServletContext(); + verify(servletContext, never()) + .getAttribute(eq(io.dropwizard.metrics.servlets.HealthCheckServlet.HEALTH_CHECK_REGISTRY)); + } + + @Test + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception { +- final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final HealthCheckRegistry healthCheckRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute( + eq(io.dropwizard.metrics.servlets.HealthCheckServlet.HEALTH_CHECK_REGISTRY))) +@@ -268,16 +258,16 @@ public class HealthCheckServletTest extends AbstractServletTest { + new io.dropwizard.metrics.servlets.HealthCheckServlet(null); + healthCheckServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); +- verify(servletContext, times(1)) ++ verify(servletConfig).getServletContext(); ++ verify(servletContext) + .getAttribute(eq(io.dropwizard.metrics.servlets.HealthCheckServlet.HEALTH_CHECK_REGISTRY)); + } + + @Test(expected = ServletException.class) + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() + throws Exception { +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute( + eq(io.dropwizard.metrics.servlets.HealthCheckServlet.HEALTH_CHECK_REGISTRY))) +--- a/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletContextListenerTest.java ++++ b/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletContextListenerTest.java +@@ -17,7 +17,7 @@ import org.junit.Before; + import org.junit.Test; + + public class MetricsServletContextListenerTest extends AbstractServletTest { +- private final Clock clock = mock(Clock.class); ++ private final Clock clock = mock(); + private final MetricRegistry registry = new MetricRegistry(); + private final String allowedOrigin = "some.other.origin"; + +--- a/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletTest.java ++++ b/metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletTest.java +@@ -1,10 +1,8 @@ + package io.dropwizard.metrics.servlets; + + import static org.assertj.core.api.Assertions.assertThat; +-import static org.mockito.ArgumentMatchers.eq; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.never; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -24,7 +22,7 @@ import org.junit.Before; + import org.junit.Test; + + public class MetricsServletTest extends AbstractServletTest { +- private final Clock clock = mock(Clock.class); ++ private final Clock clock = mock(); + private final MetricRegistry registry = new MetricRegistry(); + private ServletTester tester; + +@@ -128,22 +126,8 @@ public class MetricsServletTest extends AbstractServletTest { + assertThat(response.get("Access-Control-Allow-Origin")).isEqualTo("*"); + assertThat(response.getContent()) + .isEqualTo( +- callbackParamVal +- + "({" +- + "\"version\":\"4.0.0\"," +- + "\"gauges\":{" +- + "\"g1\":{\"value\":100}" +- + "}," +- + "\"counters\":{" +- + "\"c\":{\"count\":1}" +- + "}," +- + "\"histograms\":{" +- + "\"h\":{\"count\":1,\"max\":1,\"mean\":1.0,\"min\":1,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0}" +- + "}," +- + "\"meters\":{" +- + "\"m\":{\"count\":1,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":3333333.3333333335,\"units\":\"events/second\"}},\"timers\":{\"t\":{\"count\":1,\"max\":1.0,\"mean\":1.0,\"min\":1.0,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":1.0E7,\"duration_units\":\"seconds\",\"rate_units\":\"calls/second\"}" +- + "}" +- + "})"); ++ "%s({\"version\":\"4.0.0\",\"gauges\":{\"g1\":{\"value\":100}},\"counters\":{\"c\":{\"count\":1}},\"histograms\":{\"h\":{\"count\":1,\"max\":1,\"mean\":1.0,\"min\":1,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0}},\"meters\":{\"m\":{\"count\":1,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":3333333.3333333335,\"units\":\"events/second\"}},\"timers\":{\"t\":{\"count\":1,\"max\":1.0,\"mean\":1.0,\"min\":1.0,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":1.0E7,\"duration_units\":\"seconds\",\"rate_units\":\"calls/second\"}}})", ++ callbackParamVal); + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + } + +@@ -223,47 +207,47 @@ public class MetricsServletTest extends AbstractServletTest { + @Test + public void constructorWithRegistryAsArgumentIsUsedInPreferenceOverServletConfig() + throws Exception { +- final MetricRegistry metricRegistry = mock(MetricRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final MetricRegistry metricRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + + final io.dropwizard.metrics.servlets.MetricsServlet metricsServlet = + new io.dropwizard.metrics.servlets.MetricsServlet(metricRegistry); + metricsServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); ++ verify(servletConfig).getServletContext(); + verify(servletContext, never()) +- .getAttribute(eq(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY)); ++ .getAttribute(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY); + } + + @Test + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception { +- final MetricRegistry metricRegistry = mock(MetricRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final MetricRegistry metricRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute( +- eq(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY))) ++ io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY)) + .thenReturn(metricRegistry); + + final io.dropwizard.metrics.servlets.MetricsServlet metricsServlet = + new io.dropwizard.metrics.servlets.MetricsServlet(null); + metricsServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); +- verify(servletContext, times(1)) +- .getAttribute(eq(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY)); ++ verify(servletConfig).getServletContext(); ++ verify(servletContext) ++ .getAttribute(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY); + } + + @Test(expected = ServletException.class) + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() + throws Exception { +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute( +- eq(io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY))) ++ io.dropwizard.metrics.servlets.MetricsServlet.METRICS_REGISTRY)) + .thenReturn("IRELLEVANT_STRING"); + + final io.dropwizard.metrics.servlets.MetricsServlet metricsServlet = new MetricsServlet(null); +--- a/metrics-jcache/src/main/java/com/codahale/metrics/jcache/JCacheGaugeSet.java ++++ b/metrics-jcache/src/main/java/com/codahale/metrics/jcache/JCacheGaugeSet.java +@@ -1,6 +1,7 @@ + package com.codahale.metrics.jcache; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.Collections.unmodifiableMap; + + import com.codahale.metrics.Metric; + import com.codahale.metrics.MetricSet; +@@ -8,7 +9,6 @@ import com.codahale.metrics.jvm.JmxAttributeGauge; + import java.lang.management.ManagementFactory; + import java.lang.reflect.Method; + import java.util.ArrayList; +-import java.util.Collections; + import java.util.HashMap; + import java.util.List; + import java.util.Locale; +@@ -51,7 +51,7 @@ public class JCacheGaugeSet implements MetricSet { + } + } + +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + + private Set getCacheBeans() { +--- a/metrics-jcache/src/test/java/JCacheGaugeSetTest.java ++++ b/metrics-jcache/src/test/java/JCacheGaugeSetTest.java +@@ -71,18 +71,18 @@ public class JCacheGaugeSetTest { + assertThat( + (Float) + registry.getGauges().get("jcache.statistics.myCache.average-get-time").getValue()) +- .isGreaterThan(0.0f); ++ .isPositive(); + assertThat( + (Float) + registry.getGauges().get("jcache.statistics.myCache.average-put-time").getValue()) +- .isGreaterThan(0.0f); ++ .isPositive(); + assertThat( + (Float) + registry + .getGauges() + .get("jcache.statistics.myCache.average-remove-time") + .getValue()) +- .isGreaterThan(0.0f); ++ .isPositive(); + } + + @After +--- a/metrics-jdbi/src/main/java/com/codahale/metrics/jdbi/strategies/NameStrategies.java ++++ b/metrics-jdbi/src/main/java/com/codahale/metrics/jdbi/strategies/NameStrategies.java +@@ -45,7 +45,7 @@ public final class NameStrategies { + public String getStatementName(StatementContext statementContext) { + final String rawSql = statementContext.getRawSql(); + +- if (rawSql == null || rawSql.length() == 0) { ++ if (rawSql == null || rawSql.isEmpty()) { + return EMPTY_SQL; + } + return null; +--- a/metrics-jdbi/src/test/java/com/codahale/metrics/jdbi/InstrumentedTimingCollectorTest.java ++++ b/metrics-jdbi/src/test/java/com/codahale/metrics/jdbi/InstrumentedTimingCollectorTest.java +@@ -23,7 +23,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn(getClass()).when(ctx).getSqlObjectType(); + doReturn(getClass().getMethod("updatesTimerForSqlObjects")).when(ctx).getSqlObjectMethod(); +@@ -42,7 +42,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn(getClass()).when(ctx).getSqlObjectType(); + +@@ -60,7 +60,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + + collector.collect(TimeUnit.SECONDS.toNanos(2), ctx); +@@ -77,7 +77,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + + collector.collect(TimeUnit.SECONDS.toNanos(2), ctx); + +@@ -93,7 +93,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("don't know what it is but it's not SQL").when(ctx).getRawSql(); + + collector.collect(TimeUnit.SECONDS.toNanos(3), ctx); +@@ -110,7 +110,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn(getClass().getName()).when(ctx).getAttribute(NameStrategies.STATEMENT_CLASS); + doReturn("updatesTimerForContextClass").when(ctx).getAttribute(NameStrategies.STATEMENT_NAME); +@@ -129,7 +129,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn("foo/bar.stg").when(ctx).getAttribute(NameStrategies.STATEMENT_GROUP); + doReturn("updatesTimerForTemplateFile").when(ctx).getAttribute(NameStrategies.STATEMENT_NAME); +@@ -148,7 +148,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn("my-group").when(ctx).getAttribute(NameStrategies.STATEMENT_GROUP); + doReturn("updatesTimerForContextGroupAndName") +@@ -169,7 +169,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new SmartNameStrategy(); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn("my-group").when(ctx).getAttribute(NameStrategies.STATEMENT_GROUP); + doReturn("my-type").when(ctx).getAttribute(NameStrategies.STATEMENT_TYPE); +@@ -192,7 +192,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new ShortNameStrategy("jdbi"); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn(getClass()).when(ctx).getSqlObjectType(); + doReturn(getClass().getMethod("updatesTimerForShortSqlObjectStrategy")) +@@ -215,7 +215,7 @@ public class InstrumentedTimingCollectorTest { + final StatementNameStrategy strategy = new ShortNameStrategy("jdbi"); + final InstrumentedTimingCollector collector = + new InstrumentedTimingCollector(registry, strategy); +- final StatementContext ctx = mock(StatementContext.class); ++ final StatementContext ctx = mock(); + doReturn("SELECT 1").when(ctx).getRawSql(); + doReturn(getClass().getName()).when(ctx).getAttribute(NameStrategies.STATEMENT_CLASS); + doReturn("updatesTimerForShortContextClassStrategy") +--- a/metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/InstrumentedSqlLoggerTest.java ++++ b/metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/InstrumentedSqlLoggerTest.java +@@ -16,12 +16,12 @@ import org.junit.Test; + public class InstrumentedSqlLoggerTest { + @Test + public void logsExecutionTime() { +- final MetricRegistry mockRegistry = mock(MetricRegistry.class); +- final StatementNameStrategy mockNameStrategy = mock(StatementNameStrategy.class); ++ final MetricRegistry mockRegistry = mock(); ++ final StatementNameStrategy mockNameStrategy = mock(); + final InstrumentedSqlLogger logger = new InstrumentedSqlLogger(mockRegistry, mockNameStrategy); + +- final StatementContext mockContext = mock(StatementContext.class); +- final Timer mockTimer = mock(Timer.class); ++ final StatementContext mockContext = mock(); ++ final Timer mockTimer = mock(); + + final String statementName = "my-fake-name"; + final long fakeElapsed = 1234L; +@@ -38,12 +38,12 @@ public class InstrumentedSqlLoggerTest { + + @Test + public void logsExceptionTime() { +- final MetricRegistry mockRegistry = mock(MetricRegistry.class); +- final StatementNameStrategy mockNameStrategy = mock(StatementNameStrategy.class); ++ final MetricRegistry mockRegistry = mock(); ++ final StatementNameStrategy mockNameStrategy = mock(); + final InstrumentedSqlLogger logger = new InstrumentedSqlLogger(mockRegistry, mockNameStrategy); + +- final StatementContext mockContext = mock(StatementContext.class); +- final Timer mockTimer = mock(Timer.class); ++ final StatementContext mockContext = mock(); ++ final Timer mockTimer = mock(); + + final String statementName = "my-fake-name"; + final long fakeElapsed = 1234L; +--- a/metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/strategies/AbstractStrategyTest.java ++++ b/metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/strategies/AbstractStrategyTest.java +@@ -10,7 +10,7 @@ import org.junit.Before; + public class AbstractStrategyTest { + + MetricRegistry registry = new MetricRegistry(); +- StatementContext ctx = mock(StatementContext.class); ++ StatementContext ctx = mock(); + + @Before + public void setUp() throws Exception { +--- a/metrics-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java ++++ b/metrics-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Clock; + import com.codahale.metrics.ExponentiallyDecayingReservoir; +@@ -19,7 +22,6 @@ import com.codahale.metrics.annotation.Timed; + import java.lang.annotation.Annotation; + import java.lang.reflect.Method; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -159,7 +161,7 @@ public class InstrumentedResourceMethodApplicationListener + this.level = responseMetered.level(); + this.meters = + COARSE_METER_LEVELS.contains(level) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(metricName, "1xx-responses")), // 1xx + registry.meter(name(metricName, "2xx-responses")), // 2xx +@@ -167,11 +169,9 @@ public class InstrumentedResourceMethodApplicationListener + registry.meter(name(metricName, "4xx-responses")), // 4xx + registry.meter(name(metricName, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + this.responseCodeMeters = +- DETAILED_METER_LEVELS.contains(level) +- ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ DETAILED_METER_LEVELS.contains(level) ? new ConcurrentHashMap<>() : emptyMap(); + this.metricRegistry = registry; + } + +@@ -305,9 +305,9 @@ public class InstrumentedResourceMethodApplicationListener + : null; + + if (metric != null) { +- if (metric.cause.isAssignableFrom(event.getException().getClass()) ++ if (metric.cause.isInstance(event.getException()) + || (event.getException().getCause() != null +- && metric.cause.isAssignableFrom(event.getException().getCause().getClass()))) { ++ && metric.cause.isInstance(event.getException().getCause()))) { + metric.meter.mark(); + } + } +@@ -418,14 +418,11 @@ public class InstrumentedResourceMethodApplicationListener + + @Override + public RequestEventListener onRequest(final RequestEvent event) { +- final RequestEventListener listener = +- new ChainedRequestEventListener( +- new TimerRequestEventListener(timers, clock), +- new MeterRequestEventListener(meters), +- new ExceptionMeterRequestEventListener(exceptionMeters), +- new ResponseMeterRequestEventListener(responseMeters)); +- +- return listener; ++ return new ChainedRequestEventListener( ++ new TimerRequestEventListener(timers, clock), ++ new MeterRequestEventListener(meters), ++ new ExceptionMeterRequestEventListener(exceptionMeters), ++ new ResponseMeterRequestEventListener(responseMeters)); + } + + private T getClassLevelAnnotation( +@@ -598,8 +595,7 @@ public class InstrumentedResourceMethodApplicationListener + @Override + public int hashCode() { + int result = type.hashCode(); +- result = 31 * result + method.hashCode(); +- return result; ++ return 31 * result + method.hashCode(); + } + } + } +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonFilterMetricsJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonFilterMetricsJerseyTest.java +@@ -35,8 +35,7 @@ public class SingletonFilterMetricsJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry, testClock, true)); + config = config.register(new TestRequestFilter(testClock)); +- config = config.register(new InstrumentedFilteredResource(testClock)); +- return config; ++ return config.register(new InstrumentedFilteredResource(testClock)); + } + + @Before +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsExceptionMeteredPerClassJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsExceptionMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceExceptionMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceExceptionMeteredPerClass.class); + } + + @Test +@@ -51,7 +49,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -76,7 +74,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + assertThat(target("subresource/exception-metered").request().get(String.class)) + .isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("subresource/exception-metered") +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsJerseyTest.java +@@ -38,9 +38,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResource.class); +- +- return config; ++ return config.register(InstrumentedResource.class); + } + + @Test +@@ -67,7 +65,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -87,12 +85,12 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + final Meter meter200 = + registry.meter(name(InstrumentedResource.class, "responseMeteredCoarse", "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("response-metered-coarse").request().get().getStatus()).isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(0); + } + + @Test +@@ -107,9 +105,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + registry.meter( + name(InstrumentedResource.class, "responseMeteredDetailed", "201-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); +- assertThat(meter201.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); ++ assertThat(meter201.getCount()).isEqualTo(0); + assertThat(target("response-metered-detailed").request().get().getStatus()).isEqualTo(200); + assertThat( + target("response-metered-detailed") +@@ -119,9 +117,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + .getStatus()) + .isEqualTo(201); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isOne(); +- assertThat(meter201.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(1); ++ assertThat(meter201.getCount()).isEqualTo(1); + } + + @Test +@@ -131,12 +129,12 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + final Meter meter200 = + registry.meter(name(InstrumentedResource.class, "responseMeteredAll", "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("response-metered-all").request().get().getStatus()).isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + + @Test +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsMeteredPerClassJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsMeteredPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsMeteredPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceMeteredPerClass.class); + } + + @Test +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsResponseMeteredPerClassJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsResponseMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + + config = config.register(new MetricsFeature(this.registry)); + config = config.register(InstrumentedResourceResponseMeteredPerClass.class); +- config = config.register(new TestExceptionMapper()); +- +- return config; ++ return config.register(new TestExceptionMapper()); + } + + @Test +@@ -140,12 +138,12 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + "responseMeteredPerClass", + "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("subresource/responseMeteredPerClass").request().get().getStatus()) + .isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + } +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsTimedPerClassJerseyTest.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/SingletonMetricsTimedPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsTimedPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceTimedPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceTimedPerClass.class); + } + + @Test +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedFilteredResource.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedFilteredResource.java +@@ -18,24 +18,24 @@ public class InstrumentedFilteredResource { + } + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick++; + return "yay"; + } + + @GET +- @Timed(name = "fancyName") + @Path("/named") ++ @Timed(name = "fancyName") + public String named() { + testClock.tick++; + return "fancy"; + } + + @GET +- @Timed(name = "absolutelyFancy", absolute = true) + @Path("/absolute") ++ @Timed(name = "absolutelyFancy", absolute = true) + public String absolute() { + testClock.tick++; + return "absolute"; +@@ -50,8 +50,8 @@ public class InstrumentedFilteredResource { + public class InstrumentedFilteredSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick += 2; + return "yay"; +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedResource.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedResource.java +@@ -21,8 +21,8 @@ import javax.ws.rs.core.Response; + @Produces(MediaType.TEXT_PLAIN) + public class InstrumentedResource { + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +@@ -34,8 +34,8 @@ public class InstrumentedResource { + return "woo"; + } + +- @GET + @ExceptionMetered(cause = IOException.class) ++ @GET + @Path("/exception-metered") + public String exceptionMetered(@QueryParam("splode") @DefaultValue("false") boolean splode) + throws IOException { +@@ -46,24 +46,24 @@ public class InstrumentedResource { + } + + @GET +- @ResponseMetered(level = DETAILED) + @Path("/response-metered-detailed") ++ @ResponseMetered(level = DETAILED) + public Response responseMeteredDetailed( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = COARSE) + @Path("/response-metered-coarse") ++ @ResponseMetered(level = COARSE) + public Response responseMeteredCoarse( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = ALL) + @Path("/response-metered-all") ++ @ResponseMetered(level = ALL) + public Response responseMeteredAll( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); +--- a/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedSubResource.java ++++ b/metrics-jersey2/src/test/java/com/codahale/metrics/jersey2/resources/InstrumentedSubResource.java +@@ -10,8 +10,8 @@ import javax.ws.rs.core.MediaType; + public class InstrumentedSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +--- a/metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java ++++ b/metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Clock; + import com.codahale.metrics.ExponentiallyDecayingReservoir; +@@ -21,7 +24,6 @@ import jakarta.ws.rs.ext.Provider; + import java.lang.annotation.Annotation; + import java.lang.reflect.Method; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -159,7 +161,7 @@ public class InstrumentedResourceMethodApplicationListener + this.level = responseMetered.level(); + this.meters = + COARSE_METER_LEVELS.contains(level) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(metricName, "1xx-responses")), // 1xx + registry.meter(name(metricName, "2xx-responses")), // 2xx +@@ -167,11 +169,9 @@ public class InstrumentedResourceMethodApplicationListener + registry.meter(name(metricName, "4xx-responses")), // 4xx + registry.meter(name(metricName, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + this.responseCodeMeters = +- DETAILED_METER_LEVELS.contains(level) +- ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ DETAILED_METER_LEVELS.contains(level) ? new ConcurrentHashMap<>() : emptyMap(); + this.metricRegistry = registry; + } + +@@ -305,9 +305,9 @@ public class InstrumentedResourceMethodApplicationListener + : null; + + if (metric != null) { +- if (metric.cause.isAssignableFrom(event.getException().getClass()) ++ if (metric.cause.isInstance(event.getException()) + || (event.getException().getCause() != null +- && metric.cause.isAssignableFrom(event.getException().getCause().getClass()))) { ++ && metric.cause.isInstance(event.getException().getCause()))) { + metric.meter.mark(); + } + } +@@ -418,14 +418,11 @@ public class InstrumentedResourceMethodApplicationListener + + @Override + public RequestEventListener onRequest(final RequestEvent event) { +- final RequestEventListener listener = +- new ChainedRequestEventListener( +- new TimerRequestEventListener(timers, clock), +- new MeterRequestEventListener(meters), +- new ExceptionMeterRequestEventListener(exceptionMeters), +- new ResponseMeterRequestEventListener(responseMeters)); +- +- return listener; ++ return new ChainedRequestEventListener( ++ new TimerRequestEventListener(timers, clock), ++ new MeterRequestEventListener(meters), ++ new ExceptionMeterRequestEventListener(exceptionMeters), ++ new ResponseMeterRequestEventListener(responseMeters)); + } + + private T getClassLevelAnnotation( +@@ -598,8 +595,7 @@ public class InstrumentedResourceMethodApplicationListener + @Override + public int hashCode() { + int result = type.hashCode(); +- result = 31 * result + method.hashCode(); +- return result; ++ return 31 * result + method.hashCode(); + } + } + } +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonFilterMetricsJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonFilterMetricsJerseyTest.java +@@ -35,8 +35,7 @@ public class SingletonFilterMetricsJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry, testClock, true)); + config = config.register(new TestRequestFilter(testClock)); +- config = config.register(new InstrumentedFilteredResource(testClock)); +- return config; ++ return config.register(new InstrumentedFilteredResource(testClock)); + } + + @Before +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsExceptionMeteredPerClassJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsExceptionMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceExceptionMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceExceptionMeteredPerClass.class); + } + + @Test +@@ -51,7 +49,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -76,7 +74,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + assertThat(target("subresource/exception-metered").request().get(String.class)) + .isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("subresource/exception-metered") +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsJerseyTest.java +@@ -38,9 +38,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResource.class); +- +- return config; ++ return config.register(InstrumentedResource.class); + } + + @Test +@@ -67,7 +65,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -92,9 +90,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + registry.meter( + name(InstrumentedResource.class, "responseMeteredDetailed", "201-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); +- assertThat(meter201.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); ++ assertThat(meter201.getCount()).isEqualTo(0); + assertThat(target("response-metered-detailed").request().get().getStatus()).isEqualTo(200); + assertThat( + target("response-metered-detailed") +@@ -104,9 +102,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + .getStatus()) + .isEqualTo(201); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isOne(); +- assertThat(meter201.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(1); ++ assertThat(meter201.getCount()).isEqualTo(1); + } + + @Test +@@ -116,12 +114,12 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + final Meter meter200 = + registry.meter(name(InstrumentedResource.class, "responseMeteredAll", "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("response-metered-all").request().get().getStatus()).isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + + @Test +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsMeteredPerClassJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsMeteredPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsMeteredPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceMeteredPerClass.class); + } + + @Test +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsResponseMeteredPerClassJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsResponseMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + + config = config.register(new MetricsFeature(this.registry)); + config = config.register(InstrumentedResourceResponseMeteredPerClass.class); +- config = config.register(new TestExceptionMapper()); +- +- return config; ++ return config.register(new TestExceptionMapper()); + } + + @Test +@@ -140,12 +138,12 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + "responseMeteredPerClass", + "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("subresource/responseMeteredPerClass").request().get().getStatus()) + .isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + } +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsTimedPerClassJerseyTest.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/SingletonMetricsTimedPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsTimedPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceTimedPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceTimedPerClass.class); + } + + @Test +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedFilteredResource.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedFilteredResource.java +@@ -18,24 +18,24 @@ public class InstrumentedFilteredResource { + } + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick++; + return "yay"; + } + + @GET +- @Timed(name = "fancyName") + @Path("/named") ++ @Timed(name = "fancyName") + public String named() { + testClock.tick++; + return "fancy"; + } + + @GET +- @Timed(name = "absolutelyFancy", absolute = true) + @Path("/absolute") ++ @Timed(name = "absolutelyFancy", absolute = true) + public String absolute() { + testClock.tick++; + return "absolute"; +@@ -50,8 +50,8 @@ public class InstrumentedFilteredResource { + public class InstrumentedFilteredSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick += 2; + return "yay"; +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedResource.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedResource.java +@@ -21,8 +21,8 @@ import java.io.IOException; + @Produces(MediaType.TEXT_PLAIN) + public class InstrumentedResource { + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +@@ -34,8 +34,8 @@ public class InstrumentedResource { + return "woo"; + } + +- @GET + @ExceptionMetered(cause = IOException.class) ++ @GET + @Path("/exception-metered") + public String exceptionMetered(@QueryParam("splode") @DefaultValue("false") boolean splode) + throws IOException { +@@ -46,24 +46,24 @@ public class InstrumentedResource { + } + + @GET +- @ResponseMetered(level = DETAILED) + @Path("/response-metered-detailed") ++ @ResponseMetered(level = DETAILED) + public Response responseMeteredDetailed( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = COARSE) + @Path("/response-metered-coarse") ++ @ResponseMetered(level = COARSE) + public Response responseMeteredCoarse( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = ALL) + @Path("/response-metered-all") ++ @ResponseMetered(level = ALL) + public Response responseMeteredAll( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); +--- a/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedSubResource.java ++++ b/metrics-jersey3/src/test/java/com/codahale/metrics/jersey3/resources/InstrumentedSubResource.java +@@ -10,8 +10,8 @@ import jakarta.ws.rs.core.MediaType; + public class InstrumentedSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +--- a/metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java ++++ b/metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Clock; + import com.codahale.metrics.ExponentiallyDecayingReservoir; +@@ -21,7 +24,6 @@ import jakarta.ws.rs.ext.Provider; + import java.lang.annotation.Annotation; + import java.lang.reflect.Method; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -159,7 +161,7 @@ public class InstrumentedResourceMethodApplicationListener + this.level = responseMetered.level(); + this.meters = + COARSE_METER_LEVELS.contains(level) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(metricName, "1xx-responses")), // 1xx + registry.meter(name(metricName, "2xx-responses")), // 2xx +@@ -167,11 +169,9 @@ public class InstrumentedResourceMethodApplicationListener + registry.meter(name(metricName, "4xx-responses")), // 4xx + registry.meter(name(metricName, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + this.responseCodeMeters = +- DETAILED_METER_LEVELS.contains(level) +- ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ DETAILED_METER_LEVELS.contains(level) ? new ConcurrentHashMap<>() : emptyMap(); + this.metricRegistry = registry; + } + +@@ -305,9 +305,9 @@ public class InstrumentedResourceMethodApplicationListener + : null; + + if (metric != null) { +- if (metric.cause.isAssignableFrom(event.getException().getClass()) ++ if (metric.cause.isInstance(event.getException()) + || (event.getException().getCause() != null +- && metric.cause.isAssignableFrom(event.getException().getCause().getClass()))) { ++ && metric.cause.isInstance(event.getException().getCause()))) { + metric.meter.mark(); + } + } +@@ -418,14 +418,11 @@ public class InstrumentedResourceMethodApplicationListener + + @Override + public RequestEventListener onRequest(final RequestEvent event) { +- final RequestEventListener listener = +- new ChainedRequestEventListener( +- new TimerRequestEventListener(timers, clock), +- new MeterRequestEventListener(meters), +- new ExceptionMeterRequestEventListener(exceptionMeters), +- new ResponseMeterRequestEventListener(responseMeters)); +- +- return listener; ++ return new ChainedRequestEventListener( ++ new TimerRequestEventListener(timers, clock), ++ new MeterRequestEventListener(meters), ++ new ExceptionMeterRequestEventListener(exceptionMeters), ++ new ResponseMeterRequestEventListener(responseMeters)); + } + + private T getClassLevelAnnotation( +@@ -598,8 +595,7 @@ public class InstrumentedResourceMethodApplicationListener + @Override + public int hashCode() { + int result = type.hashCode(); +- result = 31 * result + method.hashCode(); +- return result; ++ return 31 * result + method.hashCode(); + } + } + } +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonFilterMetricsJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonFilterMetricsJerseyTest.java +@@ -35,8 +35,7 @@ public class SingletonFilterMetricsJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry, testClock, true)); + config = config.register(new TestRequestFilter(testClock)); +- config = config.register(new InstrumentedFilteredResource(testClock)); +- return config; ++ return config.register(new InstrumentedFilteredResource(testClock)); + } + + @Before +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsExceptionMeteredPerClassJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsExceptionMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceExceptionMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceExceptionMeteredPerClass.class); + } + + @Test +@@ -51,7 +49,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -76,7 +74,7 @@ public class SingletonMetricsExceptionMeteredPerClassJerseyTest extends JerseyTe + assertThat(target("subresource/exception-metered").request().get(String.class)) + .isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("subresource/exception-metered") +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsJerseyTest.java +@@ -38,9 +38,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + ResourceConfig config = new ResourceConfig(); + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResource.class); +- +- return config; ++ return config.register(InstrumentedResource.class); + } + + @Test +@@ -67,7 +65,7 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + + assertThat(target("exception-metered").request().get(String.class)).isEqualTo("fuh"); + +- assertThat(meter.getCount()).isZero(); ++ assertThat(meter.getCount()).isEqualTo(0); + + try { + target("exception-metered").queryParam("splode", true).request().get(String.class); +@@ -87,12 +85,12 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + final Meter meter200 = + registry.meter(name(InstrumentedResource.class, "responseMeteredCoarse", "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("response-metered-coarse").request().get().getStatus()).isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(0); + } + + @Test +@@ -107,9 +105,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + registry.meter( + name(InstrumentedResource.class, "responseMeteredDetailed", "201-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); +- assertThat(meter201.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); ++ assertThat(meter201.getCount()).isEqualTo(0); + assertThat(target("response-metered-detailed").request().get().getStatus()).isEqualTo(200); + assertThat( + target("response-metered-detailed") +@@ -119,9 +117,9 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + .getStatus()) + .isEqualTo(201); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isOne(); +- assertThat(meter201.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(1); ++ assertThat(meter201.getCount()).isEqualTo(1); + } + + @Test +@@ -131,12 +129,12 @@ public class SingletonMetricsJerseyTest extends JerseyTest { + final Meter meter200 = + registry.meter(name(InstrumentedResource.class, "responseMeteredAll", "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("response-metered-all").request().get().getStatus()).isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + + @Test +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsMeteredPerClassJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsMeteredPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsMeteredPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceMeteredPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceMeteredPerClass.class); + } + + @Test +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsResponseMeteredPerClassJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsResponseMeteredPerClassJerseyTest.java +@@ -35,9 +35,7 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + + config = config.register(new MetricsFeature(this.registry)); + config = config.register(InstrumentedResourceResponseMeteredPerClass.class); +- config = config.register(new TestExceptionMapper()); +- +- return config; ++ return config.register(new TestExceptionMapper()); + } + + @Test +@@ -140,12 +138,12 @@ public class SingletonMetricsResponseMeteredPerClassJerseyTest extends JerseyTes + "responseMeteredPerClass", + "200-responses")); + +- assertThat(meter2xx.getCount()).isZero(); +- assertThat(meter200.getCount()).isZero(); ++ assertThat(meter2xx.getCount()).isEqualTo(0); ++ assertThat(meter200.getCount()).isEqualTo(0); + assertThat(target("subresource/responseMeteredPerClass").request().get().getStatus()) + .isEqualTo(200); + +- assertThat(meter2xx.getCount()).isOne(); +- assertThat(meter200.getCount()).isOne(); ++ assertThat(meter2xx.getCount()).isEqualTo(1); ++ assertThat(meter200.getCount()).isEqualTo(1); + } + } +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsTimedPerClassJerseyTest.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/SingletonMetricsTimedPerClassJerseyTest.java +@@ -32,9 +32,7 @@ public class SingletonMetricsTimedPerClassJerseyTest extends JerseyTest { + ResourceConfig config = new ResourceConfig(); + + config = config.register(new MetricsFeature(this.registry)); +- config = config.register(InstrumentedResourceTimedPerClass.class); +- +- return config; ++ return config.register(InstrumentedResourceTimedPerClass.class); + } + + @Test +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedFilteredResource.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedFilteredResource.java +@@ -18,24 +18,24 @@ public class InstrumentedFilteredResource { + } + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick++; + return "yay"; + } + + @GET +- @Timed(name = "fancyName") + @Path("/named") ++ @Timed(name = "fancyName") + public String named() { + testClock.tick++; + return "fancy"; + } + + @GET +- @Timed(name = "absolutelyFancy", absolute = true) + @Path("/absolute") ++ @Timed(name = "absolutelyFancy", absolute = true) + public String absolute() { + testClock.tick++; + return "absolute"; +@@ -50,8 +50,8 @@ public class InstrumentedFilteredResource { + public class InstrumentedFilteredSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + testClock.tick += 2; + return "yay"; +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedResource.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedResource.java +@@ -21,8 +21,8 @@ import java.io.IOException; + @Produces(MediaType.TEXT_PLAIN) + public class InstrumentedResource { + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +@@ -34,8 +34,8 @@ public class InstrumentedResource { + return "woo"; + } + +- @GET + @ExceptionMetered(cause = IOException.class) ++ @GET + @Path("/exception-metered") + public String exceptionMetered(@QueryParam("splode") @DefaultValue("false") boolean splode) + throws IOException { +@@ -46,24 +46,24 @@ public class InstrumentedResource { + } + + @GET +- @ResponseMetered(level = DETAILED) + @Path("/response-metered-detailed") ++ @ResponseMetered(level = DETAILED) + public Response responseMeteredDetailed( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = COARSE) + @Path("/response-metered-coarse") ++ @ResponseMetered(level = COARSE) + public Response responseMeteredCoarse( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); + } + + @GET +- @ResponseMetered(level = ALL) + @Path("/response-metered-all") ++ @ResponseMetered(level = ALL) + public Response responseMeteredAll( + @QueryParam("status_code") @DefaultValue("200") int statusCode) { + return Response.status(Response.Status.fromStatusCode(statusCode)).build(); +--- a/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedSubResource.java ++++ b/metrics-jersey31/src/test/java/io/dropwizard/metrics/jersey31/resources/InstrumentedSubResource.java +@@ -10,8 +10,8 @@ import jakarta.ws.rs.core.MediaType; + public class InstrumentedSubResource { + + @GET +- @Timed + @Path("/timed") ++ @Timed + public String timed() { + return "yay"; + } +--- a/metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHandler.java ++++ b/metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHandler.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -13,7 +16,6 @@ import com.codahale.metrics.Timer; + import com.codahale.metrics.annotation.ResponseMeteredLevel; + import java.io.IOException; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -172,10 +174,10 @@ public class InstrumentedHandler extends HandlerWrapper { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + metricRegistry.meter(name(prefix, NAME_1XX_RESPONSES)), // 1xx + metricRegistry.meter(name(prefix, NAME_2XX_RESPONSES)), // 2xx +@@ -183,7 +185,7 @@ public class InstrumentedHandler extends HandlerWrapper { + metricRegistry.meter(name(prefix, NAME_4XX_RESPONSES)), // 4xx + metricRegistry.meter(name(prefix, NAME_5XX_RESPONSES)) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, NAME_GET_REQUESTS)); + this.postRequests = metricRegistry.timer(name(prefix, NAME_POST_REQUESTS)); +--- a/metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListener.java ++++ b/metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -14,7 +17,6 @@ import com.codahale.metrics.annotation.ResponseMeteredLevel; + import java.io.IOException; + import java.nio.ByteBuffer; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -132,10 +134,10 @@ public class InstrumentedHttpChannelListener implements Listener { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(prefix, "1xx-responses")), // 1xx + registry.meter(name(prefix, "2xx-responses")), // 2xx +@@ -143,7 +145,7 @@ public class InstrumentedHttpChannelListener implements Listener { + registry.meter(name(prefix, "4xx-responses")), // 4xx + registry.meter(name(prefix, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, "get-requests")); + this.postRequests = metricRegistry.timer(name(prefix, "post-requests")); +--- a/metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHandlerTest.java ++++ b/metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHandlerTest.java +@@ -1,12 +1,12 @@ + package io.dropwizard.metrics.jetty10; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.assertThatCode; + + import com.codahale.metrics.MetricRegistry; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import java.util.concurrent.TimeUnit; + import javax.servlet.AsyncContext; + import javax.servlet.ServletException; +@@ -114,8 +114,8 @@ public class InstrumentedHandlerTest { + assertThatCode(handler::doStop).doesNotThrowAnyException(); + } + +- @Test + @Ignore("flaky on virtual machines") ++ @Test + public void responseTimesAreRecordedForAsyncResponses() throws Exception { + + final ContentResponse response = client.GET(uri("/async")); +@@ -126,15 +126,14 @@ public class InstrumentedHandlerTest { + } + + private void assertResponseTimesValid() { +- assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()) +- .isGreaterThan(0L); ++ assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()).isPositive(); + + assertThat(registry.getTimers().get(metricName() + ".get-requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + + assertThat(registry.getTimers().get(metricName() + ".requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + } + +@@ -197,7 +196,7 @@ public class InstrumentedHandlerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async\n".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async\n".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListenerTest.java ++++ b/metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListenerTest.java +@@ -1,11 +1,11 @@ + package io.dropwizard.metrics.jetty10; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + + import com.codahale.metrics.MetricRegistry; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import javax.servlet.AsyncContext; + import javax.servlet.ServletOutputStream; + import javax.servlet.WriteListener; +@@ -187,7 +187,7 @@ public class InstrumentedHttpChannelListenerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHandler.java ++++ b/metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHandler.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -18,7 +21,6 @@ import jakarta.servlet.http.HttpServletRequest; + import jakarta.servlet.http.HttpServletResponse; + import java.io.IOException; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -172,10 +174,10 @@ public class InstrumentedHandler extends HandlerWrapper { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + metricRegistry.meter(name(prefix, NAME_1XX_RESPONSES)), // 1xx + metricRegistry.meter(name(prefix, NAME_2XX_RESPONSES)), // 2xx +@@ -183,7 +185,7 @@ public class InstrumentedHandler extends HandlerWrapper { + metricRegistry.meter(name(prefix, NAME_4XX_RESPONSES)), // 4xx + metricRegistry.meter(name(prefix, NAME_5XX_RESPONSES)) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, NAME_GET_REQUESTS)); + this.postRequests = metricRegistry.timer(name(prefix, NAME_POST_REQUESTS)); +--- a/metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListener.java ++++ b/metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -18,7 +21,6 @@ import jakarta.servlet.http.HttpServletResponse; + import java.io.IOException; + import java.nio.ByteBuffer; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -132,10 +134,10 @@ public class InstrumentedHttpChannelListener implements Listener { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(prefix, "1xx-responses")), // 1xx + registry.meter(name(prefix, "2xx-responses")), // 2xx +@@ -143,7 +145,7 @@ public class InstrumentedHttpChannelListener implements Listener { + registry.meter(name(prefix, "4xx-responses")), // 4xx + registry.meter(name(prefix, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, "get-requests")); + this.postRequests = metricRegistry.timer(name(prefix, "post-requests")); +--- a/metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHandlerTest.java ++++ b/metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHandlerTest.java +@@ -1,6 +1,7 @@ + package io.dropwizard.metrics.jetty11; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.assertThatCode; + +@@ -12,7 +13,6 @@ import jakarta.servlet.WriteListener; + import jakarta.servlet.http.HttpServletRequest; + import jakarta.servlet.http.HttpServletResponse; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import java.util.concurrent.TimeUnit; + import org.eclipse.jetty.client.HttpClient; + import org.eclipse.jetty.client.api.ContentResponse; +@@ -114,8 +114,8 @@ public class InstrumentedHandlerTest { + assertThatCode(handler::doStop).doesNotThrowAnyException(); + } + +- @Test + @Ignore("flaky on virtual machines") ++ @Test + public void responseTimesAreRecordedForAsyncResponses() throws Exception { + + final ContentResponse response = client.GET(uri("/async")); +@@ -126,17 +126,15 @@ public class InstrumentedHandlerTest { + } + + private void assertResponseTimesValid() { +- assertThat(registry.getMeters().get(metricName() + ".2xx-responses").getCount()) +- .isGreaterThan(0L); +- assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()) +- .isGreaterThan(0L); ++ assertThat(registry.getMeters().get(metricName() + ".2xx-responses").getCount()).isPositive(); ++ assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()).isPositive(); + + assertThat(registry.getTimers().get(metricName() + ".get-requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + + assertThat(registry.getTimers().get(metricName() + ".requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + } + +@@ -199,7 +197,7 @@ public class InstrumentedHandlerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async\n".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async\n".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListenerTest.java ++++ b/metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListenerTest.java +@@ -1,6 +1,7 @@ + package io.dropwizard.metrics.jetty11; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + + import com.codahale.metrics.MetricRegistry; +@@ -10,7 +11,6 @@ import jakarta.servlet.WriteListener; + import jakarta.servlet.http.HttpServletRequest; + import jakarta.servlet.http.HttpServletResponse; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import org.eclipse.jetty.client.HttpClient; + import org.eclipse.jetty.client.api.ContentResponse; + import org.eclipse.jetty.server.Request; +@@ -187,7 +187,7 @@ public class InstrumentedHttpChannelListenerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHandler.java ++++ b/metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHandler.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -13,7 +16,6 @@ import com.codahale.metrics.Timer; + import com.codahale.metrics.annotation.ResponseMeteredLevel; + import java.io.IOException; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -180,10 +182,10 @@ public class InstrumentedHandler extends HandlerWrapper { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + metricRegistry.meter(name(prefix, NAME_1XX_RESPONSES)), // 1xx + metricRegistry.meter(name(prefix, NAME_2XX_RESPONSES)), // 2xx +@@ -191,7 +193,7 @@ public class InstrumentedHandler extends HandlerWrapper { + metricRegistry.meter(name(prefix, NAME_4XX_RESPONSES)), // 4xx + metricRegistry.meter(name(prefix, NAME_5XX_RESPONSES)) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, NAME_GET_REQUESTS)); + this.postRequests = metricRegistry.timer(name(prefix, NAME_POST_REQUESTS)); +--- a/metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListener.java ++++ b/metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListener.java +@@ -4,6 +4,9 @@ import static com.codahale.metrics.MetricRegistry.name; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.COARSE; + import static com.codahale.metrics.annotation.ResponseMeteredLevel.DETAILED; ++import static java.util.Collections.emptyList; ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableList; + + import com.codahale.metrics.Counter; + import com.codahale.metrics.Meter; +@@ -14,7 +17,6 @@ import com.codahale.metrics.annotation.ResponseMeteredLevel; + import java.io.IOException; + import java.nio.ByteBuffer; + import java.util.Arrays; +-import java.util.Collections; + import java.util.EnumSet; + import java.util.List; + import java.util.Map; +@@ -132,10 +134,10 @@ public class InstrumentedHttpChannelListener implements Listener { + this.responseCodeMeters = + DETAILED_METER_LEVELS.contains(responseMeteredLevel) + ? new ConcurrentHashMap<>() +- : Collections.emptyMap(); ++ : emptyMap(); + this.responses = + COARSE_METER_LEVELS.contains(responseMeteredLevel) +- ? Collections.unmodifiableList( ++ ? unmodifiableList( + Arrays.asList( + registry.meter(name(prefix, "1xx-responses")), // 1xx + registry.meter(name(prefix, "2xx-responses")), // 2xx +@@ -143,7 +145,7 @@ public class InstrumentedHttpChannelListener implements Listener { + registry.meter(name(prefix, "4xx-responses")), // 4xx + registry.meter(name(prefix, "5xx-responses")) // 5xx + )) +- : Collections.emptyList(); ++ : emptyList(); + + this.getRequests = metricRegistry.timer(name(prefix, "get-requests")); + this.postRequests = metricRegistry.timer(name(prefix, "post-requests")); +--- a/metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHandlerTest.java ++++ b/metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHandlerTest.java +@@ -1,12 +1,12 @@ + package com.codahale.metrics.jetty9; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.assertThatCode; + + import com.codahale.metrics.MetricRegistry; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import java.util.concurrent.TimeUnit; + import javax.servlet.AsyncContext; + import javax.servlet.ServletException; +@@ -114,8 +114,8 @@ public class InstrumentedHandlerTest { + assertThatCode(handler::doStop).doesNotThrowAnyException(); + } + +- @Test + @Ignore("flaky on virtual machines") ++ @Test + public void responseTimesAreRecordedForAsyncResponses() throws Exception { + + final ContentResponse response = client.GET(uri("/async")); +@@ -126,17 +126,15 @@ public class InstrumentedHandlerTest { + } + + private void assertResponseTimesValid() { +- assertThat(registry.getMeters().get(metricName() + ".2xx-responses").getCount()) +- .isGreaterThan(0L); +- assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()) +- .isGreaterThan(0L); ++ assertThat(registry.getMeters().get(metricName() + ".2xx-responses").getCount()).isPositive(); ++ assertThat(registry.getMeters().get(metricName() + ".200-responses").getCount()).isPositive(); + + assertThat(registry.getTimers().get(metricName() + ".get-requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + + assertThat(registry.getTimers().get(metricName() + ".requests").getSnapshot().getMedian()) +- .isGreaterThan(0.0) ++ .isPositive() + .isLessThan(TimeUnit.SECONDS.toNanos(1)); + } + +@@ -199,7 +197,7 @@ public class InstrumentedHandlerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async\n".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async\n".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListenerTest.java ++++ b/metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListenerTest.java +@@ -1,11 +1,11 @@ + package com.codahale.metrics.jetty9; + + import static com.codahale.metrics.annotation.ResponseMeteredLevel.ALL; ++import static java.nio.charset.StandardCharsets.UTF_8; + import static org.assertj.core.api.Assertions.assertThat; + + import com.codahale.metrics.MetricRegistry; + import java.io.IOException; +-import java.nio.charset.StandardCharsets; + import javax.servlet.AsyncContext; + import javax.servlet.ServletOutputStream; + import javax.servlet.WriteListener; +@@ -187,7 +187,7 @@ public class InstrumentedHttpChannelListenerTest { + @Override + public void onWritePossible() throws IOException { + servletOutputStream.write( +- "some content from the async".getBytes(StandardCharsets.UTF_8)); ++ "some content from the async".getBytes(UTF_8)); + context.complete(); + } + +--- a/metrics-jmx/src/main/java/com/codahale/metrics/jmx/DefaultObjectNameFactory.java ++++ b/metrics-jmx/src/main/java/com/codahale/metrics/jmx/DefaultObjectNameFactory.java +@@ -36,9 +36,8 @@ public class DefaultObjectNameFactory implements ObjectNameFactory { + || shouldQuote(objectName.getKeyProperty("type"))) { + properties.put("type", ObjectName.quote(type)); + } +- objectName = new ObjectName(domain, properties); ++ return new ObjectName(domain, properties); + +- return objectName; + } catch (MalformedObjectNameException e) { + try { + return new ObjectName(domain, "name", ObjectName.quote(name)); +--- a/metrics-jmx/src/main/java/com/codahale/metrics/jmx/JmxReporter.java ++++ b/metrics-jmx/src/main/java/com/codahale/metrics/jmx/JmxReporter.java +@@ -1,5 +1,8 @@ + package com.codahale.metrics.jmx; + ++import static java.util.Collections.emptyMap; ++import static java.util.Collections.unmodifiableMap; ++ + import com.codahale.metrics.Counter; + import com.codahale.metrics.Gauge; + import com.codahale.metrics.Histogram; +@@ -12,7 +15,6 @@ import com.codahale.metrics.Reporter; + import com.codahale.metrics.Timer; + import java.io.Closeable; + import java.lang.management.ManagementFactory; +-import java.util.Collections; + import java.util.Locale; + import java.util.Map; + import java.util.concurrent.ConcurrentHashMap; +@@ -60,8 +62,8 @@ public class JmxReporter implements Reporter, Closeable { + this.durationUnit = TimeUnit.MILLISECONDS; + this.domain = "metrics"; + this.objectNameFactory = new DefaultObjectNameFactory(); +- this.specificDurationUnits = Collections.emptyMap(); +- this.specificRateUnits = Collections.emptyMap(); ++ this.specificDurationUnits = emptyMap(); ++ this.specificRateUnits = emptyMap(); + } + + /** +@@ -128,7 +130,7 @@ public class JmxReporter implements Reporter, Closeable { + * @return {@code this} + */ + public Builder specificDurationUnits(Map specificDurationUnits) { +- this.specificDurationUnits = Collections.unmodifiableMap(specificDurationUnits); ++ this.specificDurationUnits = unmodifiableMap(specificDurationUnits); + return this; + } + +@@ -139,7 +141,7 @@ public class JmxReporter implements Reporter, Closeable { + * @return {@code this} + */ + public Builder specificRateUnits(Map specificRateUnits) { +- this.specificRateUnits = Collections.unmodifiableMap(specificRateUnits); ++ this.specificRateUnits = unmodifiableMap(specificRateUnits); + return this; + } + +--- a/metrics-jmx/src/test/java/com/codahale/metrics/jmx/JmxReporterTest.java ++++ b/metrics-jmx/src/test/java/com/codahale/metrics/jmx/JmxReporterTest.java +@@ -1,5 +1,6 @@ + package com.codahale.metrics.jmx; + ++import static java.util.UUID.randomUUID; + import static org.assertj.core.api.Assertions.assertThat; + import static org.assertj.core.api.Assertions.entry; + import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown; +@@ -20,7 +21,6 @@ import com.codahale.metrics.Timer; + import java.lang.management.ManagementFactory; + import java.util.SortedMap; + import java.util.TreeMap; +-import java.util.UUID; + import java.util.concurrent.TimeUnit; + import javax.management.Attribute; + import javax.management.AttributeList; +@@ -36,7 +36,7 @@ import org.junit.Test; + @SuppressWarnings("rawtypes") + public class JmxReporterTest { + private final MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); +- private final String name = UUID.randomUUID().toString().replaceAll("[{\\-}]", ""); ++ private final String name = randomUUID().toString().replaceAll("[{\\-}]", ""); + private final MetricRegistry registry = new MetricRegistry(); + + private final JmxReporter reporter = +@@ -48,12 +48,12 @@ public class JmxReporterTest { + .filter(MetricFilter.ALL) + .build(); + +- private final Gauge gauge = mock(Gauge.class); +- private final Counter counter = mock(Counter.class); +- private final Histogram histogram = mock(Histogram.class); +- private final Meter meter = mock(Meter.class); +- private final Timer timer = mock(Timer.class); +- private final ObjectNameFactory mockObjectNameFactory = mock(ObjectNameFactory.class); ++ private final Gauge gauge = mock(); ++ private final Counter counter = mock(); ++ private final Histogram histogram = mock(); ++ private final Meter meter = mock(); ++ private final Timer timer = mock(); ++ private final ObjectNameFactory mockObjectNameFactory = mock(); + private final ObjectNameFactory concreteObjectNameFactory = reporter.getObjectNameFactory(); + + @Before +@@ -64,7 +64,7 @@ public class JmxReporterTest { + + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot hSnapshot = mock(Snapshot.class); ++ final Snapshot hSnapshot = mock(); + when(hSnapshot.getMax()).thenReturn(2L); + when(hSnapshot.getMean()).thenReturn(3.0); + when(hSnapshot.getMin()).thenReturn(4L); +@@ -91,7 +91,7 @@ public class JmxReporterTest { + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot tSnapshot = mock(Snapshot.class); ++ final Snapshot tSnapshot = mock(); + when(tSnapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(tSnapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(tSnapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +@@ -274,7 +274,7 @@ public class JmxReporterTest { + + @Test + public void objectNameModifyingMBeanServer() throws Exception { +- MBeanServer mockedMBeanServer = mock(MBeanServer.class); ++ MBeanServer mockedMBeanServer = mock(); + + // overwrite the objectName + when(mockedMBeanServer.registerMBean(any(Object.class), any(ObjectName.class))) +--- a/metrics-json/src/main/java/com/codahale/metrics/json/HealthCheckModule.java ++++ b/metrics-json/src/main/java/com/codahale/metrics/json/HealthCheckModule.java +@@ -1,5 +1,7 @@ + package com.codahale.metrics.json; + ++import static java.util.Collections.singletonList; ++ + import com.codahale.metrics.health.HealthCheck; + import com.fasterxml.jackson.core.JsonGenerator; + import com.fasterxml.jackson.core.Version; +@@ -8,7 +10,6 @@ import com.fasterxml.jackson.databind.SerializerProvider; + import com.fasterxml.jackson.databind.module.SimpleSerializers; + import com.fasterxml.jackson.databind.ser.std.StdSerializer; + import java.io.IOException; +-import java.util.Collections; + import java.util.Map; + + public class HealthCheckModule extends Module { +@@ -79,7 +80,6 @@ public class HealthCheckModule extends Module { + + @Override + public void setupModule(SetupContext context) { +- context.addSerializers( +- new SimpleSerializers(Collections.singletonList(new HealthCheckResultSerializer()))); ++ context.addSerializers(new SimpleSerializers(singletonList(new HealthCheckResultSerializer()))); + } + } +--- a/metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java ++++ b/metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java +@@ -17,8 +17,7 @@ public class HealthCheckModuleTest { + public void serializesAHealthyResult() throws Exception { + HealthCheck.Result result = HealthCheck.Result.healthy(); + assertThat(mapper.writeValueAsString(result)) +- .isEqualTo( +- "{\"healthy\":true,\"duration\":0,\"timestamp\":\"" + result.getTimestamp() + "\"}"); ++ .isEqualTo("{\"healthy\":true,\"duration\":0,\"timestamp\":\"%s\"}", result.getTimestamp()); + } + + @Test +@@ -26,14 +25,8 @@ public class HealthCheckModuleTest { + HealthCheck.Result result = HealthCheck.Result.healthy("yay for %s", "me"); + assertThat(mapper.writeValueAsString(result)) + .isEqualTo( +- "{" +- + "\"healthy\":true," +- + "\"message\":\"yay for me\"," +- + "\"duration\":0," +- + "\"timestamp\":\"" +- + result.getTimestamp() +- + "\"" +- + "}"); ++ "{\"healthy\":true,\"message\":\"yay for me\",\"duration\":0,\"timestamp\":\"%s\"}", ++ result.getTimestamp()); + } + + @Test +@@ -41,14 +34,8 @@ public class HealthCheckModuleTest { + HealthCheck.Result result = HealthCheck.Result.unhealthy("boo"); + assertThat(mapper.writeValueAsString(result)) + .isEqualTo( +- "{" +- + "\"healthy\":false," +- + "\"message\":\"boo\"," +- + "\"duration\":0," +- + "\"timestamp\":\"" +- + result.getTimestamp() +- + "\"" +- + "}"); ++ "{\"healthy\":false,\"message\":\"boo\",\"duration\":0,\"timestamp\":\"%s\"}", ++ result.getTimestamp()); + } + + @Test +@@ -60,19 +47,8 @@ public class HealthCheckModuleTest { + HealthCheck.Result result = HealthCheck.Result.unhealthy(e); + assertThat(mapper.writeValueAsString(result)) + .isEqualTo( +- "{" +- + "\"healthy\":false," +- + "\"message\":\"oh no\"," +- + "\"error\":{" +- + "\"type\":\"java.lang.RuntimeException\"," +- + "\"message\":\"oh no\"," +- + "\"stack\":[\"Blah.bloo(Blah.java:100)\"]" +- + "}," +- + "\"duration\":0," +- + "\"timestamp\":\"" +- + result.getTimestamp() +- + "\"" +- + "}"); ++ "{\"healthy\":false,\"message\":\"oh no\",\"error\":{\"type\":\"java.lang.RuntimeException\",\"message\":\"oh no\",\"stack\":[\"Blah.bloo(Blah.java:100)\"]},\"duration\":0,\"timestamp\":\"%s\"}", ++ result.getTimestamp()); + } + + @Test +@@ -88,24 +64,8 @@ public class HealthCheckModuleTest { + HealthCheck.Result result = HealthCheck.Result.unhealthy(b); + assertThat(mapper.writeValueAsString(result)) + .isEqualTo( +- "{" +- + "\"healthy\":false," +- + "\"message\":\"oh well\"," +- + "\"error\":{" +- + "\"type\":\"java.lang.RuntimeException\"," +- + "\"message\":\"oh well\"," +- + "\"stack\":[\"Blah.blee(Blah.java:150)\"]," +- + "\"cause\":{" +- + "\"type\":\"java.lang.RuntimeException\"," +- + "\"message\":\"oh no\"," +- + "\"stack\":[\"Blah.bloo(Blah.java:100)\"]" +- + "}" +- + "}," +- + "\"duration\":0," +- + "\"timestamp\":\"" +- + result.getTimestamp() +- + "\"" +- + "}"); ++ "{\"healthy\":false,\"message\":\"oh well\",\"error\":{\"type\":\"java.lang.RuntimeException\",\"message\":\"oh well\",\"stack\":[\"Blah.blee(Blah.java:150)\"],\"cause\":{\"type\":\"java.lang.RuntimeException\",\"message\":\"oh no\",\"stack\":[\"Blah.bloo(Blah.java:100)\"]}},\"duration\":0,\"timestamp\":\"%s\"}", ++ result.getTimestamp()); + } + + @Test +@@ -129,23 +89,7 @@ public class HealthCheckModuleTest { + + assertThat(mapper.writeValueAsString(result)) + .isEqualTo( +- "{" +- + "\"healthy\":true," +- + "\"duration\":0," +- + "\"boolean\":true," +- + "\"integer\":1," +- + "\"long\":2," +- + "\"float\":3.546," +- + "\"double\":4.567," +- + "\"BigInteger\":12345," +- + "\"BigDecimal\":12345.56789," +- + "\"String\":\"string\"," +- + "\"complex\":{" +- + "\"field\":\"value\"" +- + "}," +- + "\"timestamp\":\"" +- + result.getTimestamp() +- + "\"" +- + "}"); ++ "{\"healthy\":true,\"duration\":0,\"boolean\":true,\"integer\":1,\"long\":2,\"float\":3.546,\"double\":4.567,\"BigInteger\":12345,\"BigDecimal\":12345.56789,\"String\":\"string\",\"complex\":{\"field\":\"value\"},\"timestamp\":\"%s\"}", ++ result.getTimestamp()); + } + } +--- a/metrics-json/src/test/java/com/codahale/metrics/json/MetricsModuleTest.java ++++ b/metrics-json/src/test/java/com/codahale/metrics/json/MetricsModuleTest.java +@@ -42,7 +42,7 @@ public class MetricsModuleTest { + + @Test + public void serializesCounters() throws Exception { +- final Counter counter = mock(Counter.class); ++ final Counter counter = mock(); + when(counter.getCount()).thenReturn(100L); + + assertThat(mapper.writeValueAsString(counter)).isEqualTo("{\"count\":100}"); +@@ -50,10 +50,10 @@ public class MetricsModuleTest { + + @Test + public void serializesHistograms() throws Exception { +- final Histogram histogram = mock(Histogram.class); ++ final Histogram histogram = mock(); + when(histogram.getCount()).thenReturn(1L); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(2L); + when(snapshot.getMean()).thenReturn(3.0); + when(snapshot.getMin()).thenReturn(4L); +@@ -107,7 +107,7 @@ public class MetricsModuleTest { + + @Test + public void serializesMeters() throws Exception { +- final Meter meter = mock(Meter.class); ++ final Meter meter = mock(); + when(meter.getCount()).thenReturn(1L); + when(meter.getMeanRate()).thenReturn(2.0); + when(meter.getOneMinuteRate()).thenReturn(5.0); +@@ -127,14 +127,14 @@ public class MetricsModuleTest { + + @Test + public void serializesTimers() throws Exception { +- final Timer timer = mock(Timer.class); ++ final Timer timer = mock(); + when(timer.getCount()).thenReturn(1L); + when(timer.getMeanRate()).thenReturn(2.0); + when(timer.getOneMinuteRate()).thenReturn(3.0); + when(timer.getFiveMinuteRate()).thenReturn(4.0); + when(timer.getFifteenMinuteRate()).thenReturn(5.0); + +- final Snapshot snapshot = mock(Snapshot.class); ++ final Snapshot snapshot = mock(); + when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100)); + when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200)); + when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300)); +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/BufferPoolMetricSet.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/BufferPoolMetricSet.java +@@ -1,10 +1,10 @@ + package com.codahale.metrics.jvm; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.Collections.unmodifiableMap; + + import com.codahale.metrics.Metric; + import com.codahale.metrics.MetricSet; +-import java.util.Collections; + import java.util.HashMap; + import java.util.Map; + import javax.management.JMException; +@@ -46,6 +46,6 @@ public class BufferPoolMetricSet implements MetricSet { + } + } + } +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + } +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/GarbageCollectorMetricSet.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/GarbageCollectorMetricSet.java +@@ -1,6 +1,7 @@ + package com.codahale.metrics.jvm; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.Collections.unmodifiableMap; + + import com.codahale.metrics.Gauge; + import com.codahale.metrics.Metric; +@@ -9,7 +10,6 @@ import java.lang.management.GarbageCollectorMXBean; + import java.lang.management.ManagementFactory; + import java.util.ArrayList; + import java.util.Collection; +-import java.util.Collections; + import java.util.HashMap; + import java.util.List; + import java.util.Map; +@@ -43,6 +43,6 @@ public class GarbageCollectorMetricSet implements MetricSet { + gauges.put(name(name, "count"), (Gauge) gc::getCollectionCount); + gauges.put(name(name, "time"), (Gauge) gc::getCollectionTime); + } +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + } +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/JvmAttributeGaugeSet.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/JvmAttributeGaugeSet.java +@@ -1,11 +1,12 @@ + package com.codahale.metrics.jvm; + ++import static java.util.Collections.unmodifiableMap; ++ + import com.codahale.metrics.Gauge; + import com.codahale.metrics.Metric; + import com.codahale.metrics.MetricSet; + import java.lang.management.ManagementFactory; + import java.lang.management.RuntimeMXBean; +-import java.util.Collections; + import java.util.HashMap; + import java.util.Locale; + import java.util.Map; +@@ -46,6 +47,6 @@ public class JvmAttributeGaugeSet implements MetricSet { + runtime.getSpecVersion())); + gauges.put("uptime", (Gauge) runtime::getUptime); + +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + } +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java +@@ -1,6 +1,7 @@ + package com.codahale.metrics.jvm; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.Collections.unmodifiableMap; + + import com.codahale.metrics.Gauge; + import com.codahale.metrics.Metric; +@@ -12,7 +13,6 @@ import java.lang.management.MemoryPoolMXBean; + import java.lang.management.MemoryUsage; + import java.util.ArrayList; + import java.util.Collection; +-import java.util.Collections; + import java.util.HashMap; + import java.util.List; + import java.util.Map; +@@ -122,6 +122,6 @@ public class MemoryUsageGaugeSet implements MetricSet { + gauges.put(name(poolName, "init"), (Gauge) () -> pool.getUsage().getInit()); + } + +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + } +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadDeadlockDetector.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadDeadlockDetector.java +@@ -1,9 +1,11 @@ + package com.codahale.metrics.jvm; + ++import static java.util.Collections.emptySet; ++import static java.util.Collections.unmodifiableSet; ++ + import java.lang.management.ManagementFactory; + import java.lang.management.ThreadInfo; + import java.lang.management.ThreadMXBean; +-import java.util.Collections; + import java.util.HashSet; + import java.util.Set; + +@@ -40,19 +42,16 @@ public class ThreadDeadlockDetector { + for (ThreadInfo info : threads.getThreadInfo(ids, MAX_STACK_TRACE_DEPTH)) { + final StringBuilder stackTrace = new StringBuilder(); + for (StackTraceElement element : info.getStackTrace()) { +- stackTrace.append("\t at ").append(element.toString()).append(String.format("%n")); ++ stackTrace.append("\t at ").append(element).append(String.format("%n")); + } + + deadlocks.add( + String.format( + "%s locked on %s (owned by %s):%n%s", +- info.getThreadName(), +- info.getLockName(), +- info.getLockOwnerName(), +- stackTrace.toString())); ++ info.getThreadName(), info.getLockName(), info.getLockOwnerName(), stackTrace)); + } +- return Collections.unmodifiableSet(deadlocks); ++ return unmodifiableSet(deadlocks); + } +- return Collections.emptySet(); ++ return emptySet(); + } + } +--- a/metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadStatesGaugeSet.java ++++ b/metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadStatesGaugeSet.java +@@ -1,6 +1,7 @@ + package com.codahale.metrics.jvm; + + import static com.codahale.metrics.MetricRegistry.name; ++import static java.util.Collections.unmodifiableMap; + + import com.codahale.metrics.Gauge; + import com.codahale.metrics.Metric; +@@ -8,7 +9,6 @@ import com.codahale.metrics.MetricSet; + import java.lang.management.ManagementFactory; + import java.lang.management.ThreadInfo; + import java.lang.management.ThreadMXBean; +-import java.util.Collections; + import java.util.HashMap; + import java.util.Map; + import java.util.Set; +@@ -56,7 +56,7 @@ public class ThreadStatesGaugeSet implements MetricSet { + "deadlock.count", (Gauge) () -> deadlockDetector.getDeadlockedThreads().size()); + gauges.put("deadlocks", (Gauge>) deadlockDetector::getDeadlockedThreads); + +- return Collections.unmodifiableMap(gauges); ++ return unmodifiableMap(gauges); + } + + private int getThreadCount(Thread.State state) { +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/BufferPoolMetricSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/BufferPoolMetricSetTest.java +@@ -13,7 +13,7 @@ import org.junit.Test; + + @SuppressWarnings("rawtypes") + public class BufferPoolMetricSetTest { +- private final MBeanServer mBeanServer = mock(MBeanServer.class); ++ private final MBeanServer mBeanServer = mock(); + private final BufferPoolMetricSet buffers = new BufferPoolMetricSet(mBeanServer); + + private ObjectName mapped; +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ClassLoadingGaugeSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ClassLoadingGaugeSetTest.java +@@ -12,7 +12,7 @@ import org.junit.Test; + @SuppressWarnings("rawtypes") + public class ClassLoadingGaugeSetTest { + +- private final ClassLoadingMXBean cl = mock(ClassLoadingMXBean.class); ++ private final ClassLoadingMXBean cl = mock(); + private final ClassLoadingGaugeSet gauges = new ClassLoadingGaugeSet(cl); + + @Before +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/CpuTimeClockTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/CpuTimeClockTest.java +@@ -12,10 +12,10 @@ public class CpuTimeClockTest { + public void cpuTimeClock() { + final CpuTimeClock clock = new CpuTimeClock(); + +- assertThat((double) clock.getTime()).isEqualTo(System.currentTimeMillis(), offset(250D)); ++ assertThat((double) clock.getTime()).isCloseTo(System.currentTimeMillis(), offset(250D)); + + assertThat((double) clock.getTick()) +- .isEqualTo( ++ .isCloseTo( + ManagementFactory.getThreadMXBean().getCurrentThreadCpuTime(), offset(1000000.0)); + } + } +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/FileDescriptorRatioGaugeTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/FileDescriptorRatioGaugeTest.java +@@ -13,7 +13,7 @@ import org.junit.Test; + + @SuppressWarnings("UnusedDeclaration") + public class FileDescriptorRatioGaugeTest { +- private final UnixOperatingSystemMXBean os = mock(UnixOperatingSystemMXBean.class); ++ private final UnixOperatingSystemMXBean os = mock(); + + private final FileDescriptorRatioGauge gauge = new FileDescriptorRatioGauge(os); + +@@ -33,9 +33,7 @@ public class FileDescriptorRatioGaugeTest { + OperatingSystemMXBean osBean = ManagementFactory.getOperatingSystemMXBean(); + assumeTrue(osBean instanceof com.sun.management.UnixOperatingSystemMXBean); + +- assertThat(new FileDescriptorRatioGauge().getValue()) +- .isGreaterThanOrEqualTo(0.0) +- .isLessThanOrEqualTo(1.0); ++ assertThat(new FileDescriptorRatioGauge().getValue()).isNotNegative().isLessThanOrEqualTo(1.0); + } + + @Test +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/GarbageCollectorMetricSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/GarbageCollectorMetricSetTest.java +@@ -1,20 +1,20 @@ + package com.codahale.metrics.jvm; + ++import static java.util.Collections.singletonList; + import static org.assertj.core.api.Assertions.assertThat; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.when; + + import com.codahale.metrics.Gauge; + import java.lang.management.GarbageCollectorMXBean; +-import java.util.Collections; + import org.junit.Before; + import org.junit.Test; + + @SuppressWarnings("unchecked") + public class GarbageCollectorMetricSetTest { +- private final GarbageCollectorMXBean gc = mock(GarbageCollectorMXBean.class); ++ private final GarbageCollectorMXBean gc = mock(); + private final GarbageCollectorMetricSet metrics = +- new GarbageCollectorMetricSet(Collections.singletonList(gc)); ++ new GarbageCollectorMetricSet(singletonList(gc)); + + @Before + public void setUp() { +@@ -42,6 +42,6 @@ public class GarbageCollectorMetricSetTest { + + @Test + public void autoDiscoversGCs() { +- assertThat(new GarbageCollectorMetricSet().getMetrics().keySet()).isNotEmpty(); ++ assertThat(new GarbageCollectorMetricSet().getMetrics()).isNotEmpty(); + } + } +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/JmxAttributeGaugeTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/JmxAttributeGaugeTest.java +@@ -53,7 +53,7 @@ public class JmxAttributeGaugeTest { + JmxAttributeGauge gauge = new JmxAttributeGauge(mBeanServer, objectName, "LoadedClassCount"); + + assertThat(gauge.getValue()).isInstanceOf(Integer.class); +- assertThat((Integer) gauge.getValue()).isGreaterThan(0); ++ assertThat((Integer) gauge.getValue()).isPositive(); + } + + @Test +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/JvmAttributeGaugeSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/JvmAttributeGaugeSetTest.java +@@ -11,7 +11,7 @@ import org.junit.Test; + + @SuppressWarnings("unchecked") + public class JvmAttributeGaugeSetTest { +- private final RuntimeMXBean runtime = mock(RuntimeMXBean.class); ++ private final RuntimeMXBean runtime = mock(); + private final JvmAttributeGaugeSet gauges = new JvmAttributeGaugeSet(runtime); + + @Before +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/MemoryUsageGaugeSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/MemoryUsageGaugeSetTest.java +@@ -14,14 +14,14 @@ import org.junit.Test; + + @SuppressWarnings("rawtypes") + public class MemoryUsageGaugeSetTest { +- private final MemoryUsage heap = mock(MemoryUsage.class); +- private final MemoryUsage nonHeap = mock(MemoryUsage.class); +- private final MemoryUsage pool = mock(MemoryUsage.class); +- private final MemoryUsage weirdPool = mock(MemoryUsage.class); +- private final MemoryUsage weirdCollection = mock(MemoryUsage.class); +- private final MemoryMXBean mxBean = mock(MemoryMXBean.class); +- private final MemoryPoolMXBean memoryPool = mock(MemoryPoolMXBean.class); +- private final MemoryPoolMXBean weirdMemoryPool = mock(MemoryPoolMXBean.class); ++ private final MemoryUsage heap = mock(); ++ private final MemoryUsage nonHeap = mock(); ++ private final MemoryUsage pool = mock(); ++ private final MemoryUsage weirdPool = mock(); ++ private final MemoryUsage weirdCollection = mock(); ++ private final MemoryMXBean mxBean = mock(); ++ private final MemoryPoolMXBean memoryPool = mock(); ++ private final MemoryPoolMXBean weirdMemoryPool = mock(); + + private final MemoryUsageGaugeSet gauges = + new MemoryUsageGaugeSet(mxBean, Arrays.asList(memoryPool, weirdMemoryPool)); +@@ -262,6 +262,6 @@ public class MemoryUsageGaugeSetTest { + + @Test + public void autoDetectsMemoryUsageBeanAndMemoryPools() { +- assertThat(new MemoryUsageGaugeSet().getMetrics().keySet()).isNotEmpty(); ++ assertThat(new MemoryUsageGaugeSet().getMetrics()).isNotEmpty(); + } + } +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadDeadlockDetectorTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadDeadlockDetectorTest.java +@@ -12,7 +12,7 @@ import java.util.Locale; + import org.junit.Test; + + public class ThreadDeadlockDetectorTest { +- private final ThreadMXBean threads = mock(ThreadMXBean.class); ++ private final ThreadMXBean threads = mock(); + private final ThreadDeadlockDetector detector = new ThreadDeadlockDetector(threads); + + @Test +@@ -24,7 +24,7 @@ public class ThreadDeadlockDetectorTest { + + @Test + public void returnsASetOfThreadsIfAnyAreDeadlocked() { +- final ThreadInfo thread1 = mock(ThreadInfo.class); ++ final ThreadInfo thread1 = mock(); + when(thread1.getThreadName()).thenReturn("thread1"); + when(thread1.getLockName()).thenReturn("lock2"); + when(thread1.getLockOwnerName()).thenReturn("thread2"); +@@ -35,7 +35,7 @@ public class ThreadDeadlockDetectorTest { + new StackTraceElement("Blah", "blee", "Blah.java", 100) + }); + +- final ThreadInfo thread2 = mock(ThreadInfo.class); ++ final ThreadInfo thread2 = mock(); + when(thread2.getThreadName()).thenReturn("thread2"); + when(thread2.getLockName()).thenReturn("lock1"); + when(thread2.getLockOwnerName()).thenReturn("thread1"); +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadDumpTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadDumpTest.java +@@ -15,10 +15,10 @@ import org.junit.Test; + // TODO: 3/12/13 -- improve test coverage for ThreadDump + + public class ThreadDumpTest { +- private final ThreadMXBean threadMXBean = mock(ThreadMXBean.class); ++ private final ThreadMXBean threadMXBean = mock(); + private final ThreadDump threadDump = new ThreadDump(threadMXBean); + +- private final ThreadInfo runnable = mock(ThreadInfo.class); ++ private final ThreadInfo runnable = mock(); + + @Before + public void setUp() { +@@ -39,8 +39,8 @@ public class ThreadDumpTest { + final ByteArrayOutputStream output = new ByteArrayOutputStream(); + threadDump.dump(output); + +- assertThat(output.toString()) +- .isEqualTo( ++ assertThat(output) ++ .hasToString( + String.format( + "\"runnable\" id=100 state=RUNNABLE%n" + + " at Blah.blee(Blah.java:100)%n" +--- a/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadStatesGaugeSetTest.java ++++ b/metrics-jvm/src/test/java/com/codahale/metrics/jvm/ThreadStatesGaugeSetTest.java +@@ -13,17 +13,17 @@ import org.junit.Before; + import org.junit.Test; + + public class ThreadStatesGaugeSetTest { +- private final ThreadMXBean threads = mock(ThreadMXBean.class); +- private final ThreadDeadlockDetector detector = mock(ThreadDeadlockDetector.class); ++ private final ThreadMXBean threads = mock(); ++ private final ThreadDeadlockDetector detector = mock(); + private final ThreadStatesGaugeSet gauges = new ThreadStatesGaugeSet(threads, detector); + private final long[] ids = new long[] {1, 2, 3}; + +- private final ThreadInfo newThread = mock(ThreadInfo.class); +- private final ThreadInfo runnableThread = mock(ThreadInfo.class); +- private final ThreadInfo blockedThread = mock(ThreadInfo.class); +- private final ThreadInfo waitingThread = mock(ThreadInfo.class); +- private final ThreadInfo timedWaitingThread = mock(ThreadInfo.class); +- private final ThreadInfo terminatedThread = mock(ThreadInfo.class); ++ private final ThreadInfo newThread = mock(); ++ private final ThreadInfo runnableThread = mock(); ++ private final ThreadInfo blockedThread = mock(); ++ private final ThreadInfo waitingThread = mock(); ++ private final ThreadInfo timedWaitingThread = mock(); ++ private final ThreadInfo terminatedThread = mock(); + + private final Set deadlocks = new HashSet<>(); + +--- a/metrics-log4j2/src/test/java/com/codahale/metrics/log4j2/InstrumentedAppenderTest.java ++++ b/metrics-log4j2/src/test/java/com/codahale/metrics/log4j2/InstrumentedAppenderTest.java +@@ -18,7 +18,7 @@ public class InstrumentedAppenderTest { + + private final MetricRegistry registry = new MetricRegistry(); + private final InstrumentedAppender appender = new InstrumentedAppender(registry); +- private final LogEvent event = mock(LogEvent.class); ++ private final LogEvent event = mock(); + + @Before + public void setUp() { +--- a/metrics-logback/src/test/java/com/codahale/metrics/logback/InstrumentedAppenderTest.java ++++ b/metrics-logback/src/test/java/com/codahale/metrics/logback/InstrumentedAppenderTest.java +@@ -18,7 +18,7 @@ public class InstrumentedAppenderTest { + + private final MetricRegistry registry = new MetricRegistry(); + private final InstrumentedAppender appender = new InstrumentedAppender(registry); +- private final ILoggingEvent event = mock(ILoggingEvent.class); ++ private final ILoggingEvent event = mock(); + + @Before + public void setUp() { +--- a/metrics-logback13/src/test/java/io/dropwizard/metrics/logback13/InstrumentedAppenderTest.java ++++ b/metrics-logback13/src/test/java/io/dropwizard/metrics/logback13/InstrumentedAppenderTest.java +@@ -18,7 +18,7 @@ public class InstrumentedAppenderTest { + + private final MetricRegistry registry = new MetricRegistry(); + private final InstrumentedAppender appender = new InstrumentedAppender(registry); +- private final ILoggingEvent event = mock(ILoggingEvent.class); ++ private final ILoggingEvent event = mock(); + + @Before + public void setUp() { +--- a/metrics-logback14/src/test/java/io/dropwizard/metrics/logback14/InstrumentedAppenderTest.java ++++ b/metrics-logback14/src/test/java/io/dropwizard/metrics/logback14/InstrumentedAppenderTest.java +@@ -18,7 +18,7 @@ public class InstrumentedAppenderTest { + + private final MetricRegistry registry = new MetricRegistry(); + private final InstrumentedAppender appender = new InstrumentedAppender(registry); +- private final ILoggingEvent event = mock(ILoggingEvent.class); ++ private final ILoggingEvent event = mock(); + + @Before + public void setUp() { +--- a/metrics-servlet/src/test/java/com/codahale/metrics/servlet/InstrumentedFilterContextListenerTest.java ++++ b/metrics-servlet/src/test/java/com/codahale/metrics/servlet/InstrumentedFilterContextListenerTest.java +@@ -10,7 +10,7 @@ import javax.servlet.ServletContextEvent; + import org.junit.Test; + + public class InstrumentedFilterContextListenerTest { +- private final MetricRegistry registry = mock(MetricRegistry.class); ++ private final MetricRegistry registry = mock(); + private final InstrumentedFilterContextListener listener = + new InstrumentedFilterContextListener() { + @Override +@@ -21,9 +21,9 @@ public class InstrumentedFilterContextListenerTest { + + @Test + public void injectsTheMetricRegistryIntoTheServletContext() { +- final ServletContext context = mock(ServletContext.class); ++ final ServletContext context = mock(); + +- final ServletContextEvent event = mock(ServletContextEvent.class); ++ final ServletContextEvent event = mock(); + when(event.getServletContext()).thenReturn(context); + + listener.contextInitialized(event); +--- a/metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java ++++ b/metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java +@@ -99,7 +99,7 @@ public class HealthCheckServlet extends HttpServlet { + super.init(config); + + final ServletContext context = config.getServletContext(); +- if (null == registry) { ++ if (registry == null) { + final Object registryAttr = context.getAttribute(HEALTH_CHECK_REGISTRY); + if (registryAttr instanceof HealthCheckRegistry) { + this.registry = (HealthCheckRegistry) registryAttr; +--- a/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java ++++ b/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java +@@ -131,7 +131,7 @@ public class MetricsServlet extends HttpServlet { + super.init(config); + + final ServletContext context = config.getServletContext(); +- if (null == registry) { ++ if (registry == null) { + final Object registryAttr = context.getAttribute(METRICS_REGISTRY); + if (registryAttr instanceof MetricRegistry) { + this.registry = (MetricRegistry) registryAttr; +--- a/metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java ++++ b/metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java +@@ -3,7 +3,6 @@ package com.codahale.metrics.servlets; + import static org.assertj.core.api.Assertions.assertThat; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.never; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -94,9 +93,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + assertThat(response.getContent()) + .isEqualTo( +- "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"" +- + EXPECTED_TIMESTAMP +- + "\"}}"); ++ "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"%s\"}}", ++ EXPECTED_TIMESTAMP); + } + + @Test +@@ -110,9 +108,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + assertThat(response.getContent()) + .isEqualTo( +- "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"" +- + EXPECTED_TIMESTAMP +- + "\"}}"); ++ "{\"fun\":{\"healthy\":true,\"message\":\"whee\",\"duration\":0,\"timestamp\":\"%s\"}}", ++ EXPECTED_TIMESTAMP); + } + + @Test +@@ -168,15 +165,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + assertThat(response.getContent()) + .isEqualTo( + String.format( +- "{%n" +- + " \"fun\" : {%n" +- + " \"healthy\" : true,%n" +- + " \"message\" : \"foo bar 123\",%n" +- + " \"duration\" : 0,%n" +- + " \"timestamp\" : \"" +- + EXPECTED_TIMESTAMP +- + "\"" +- + "%n }%n}")); ++ "{%n \"fun\" : {%n \"healthy\" : true,%n \"message\" : \"foo bar 123\",%n \"duration\" : 0,%n \"timestamp\" : \"%s\"%n }%n}", ++ EXPECTED_TIMESTAMP)); + } + + private static HealthCheck.Result healthyResultWithMessage(String message) { +@@ -198,23 +188,23 @@ public class HealthCheckServletTest extends AbstractServletTest { + @Test + public void constructorWithRegistryAsArgumentIsUsedInPreferenceOverServletConfig() + throws Exception { +- final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final HealthCheckRegistry healthCheckRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + + final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(healthCheckRegistry); + healthCheckServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); ++ verify(servletConfig).getServletContext(); + verify(servletContext, never()).getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY); + } + + @Test + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception { +- final HealthCheckRegistry healthCheckRegistry = mock(HealthCheckRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final HealthCheckRegistry healthCheckRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY)) + .thenReturn(healthCheckRegistry); +@@ -222,15 +212,15 @@ public class HealthCheckServletTest extends AbstractServletTest { + final HealthCheckServlet healthCheckServlet = new HealthCheckServlet(null); + healthCheckServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); +- verify(servletContext, times(1)).getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY); ++ verify(servletConfig).getServletContext(); ++ verify(servletContext).getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY); + } + + @Test(expected = ServletException.class) + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() + throws Exception { +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY)) + .thenReturn("IRELLEVANT_STRING"); +@@ -242,8 +232,8 @@ public class HealthCheckServletTest extends AbstractServletTest { + @Test + public void constructorWithObjectMapperAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() + throws Exception { +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + when(servletContext.getAttribute(HealthCheckServlet.HEALTH_CHECK_REGISTRY)) + .thenReturn(registry); +--- a/metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletContextListenerTest.java ++++ b/metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletContextListenerTest.java +@@ -17,7 +17,7 @@ import org.junit.Before; + import org.junit.Test; + + public class MetricsServletContextListenerTest extends AbstractServletTest { +- private final Clock clock = mock(Clock.class); ++ private final Clock clock = mock(); + private final MetricRegistry registry = new MetricRegistry(); + private final String allowedOrigin = "some.other.origin"; + +--- a/metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletTest.java ++++ b/metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletTest.java +@@ -1,10 +1,8 @@ + package com.codahale.metrics.servlets; + + import static org.assertj.core.api.Assertions.assertThat; +-import static org.mockito.ArgumentMatchers.eq; + import static org.mockito.Mockito.mock; + import static org.mockito.Mockito.never; +-import static org.mockito.Mockito.times; + import static org.mockito.Mockito.verify; + import static org.mockito.Mockito.when; + +@@ -24,7 +22,7 @@ import org.junit.Before; + import org.junit.Test; + + public class MetricsServletTest extends AbstractServletTest { +- private final Clock clock = mock(Clock.class); ++ private final Clock clock = mock(); + private final MetricRegistry registry = new MetricRegistry(); + private ServletTester tester; + +@@ -128,22 +126,8 @@ public class MetricsServletTest extends AbstractServletTest { + assertThat(response.get("Access-Control-Allow-Origin")).isEqualTo("*"); + assertThat(response.getContent()) + .isEqualTo( +- callbackParamVal +- + "({" +- + "\"version\":\"4.0.0\"," +- + "\"gauges\":{" +- + "\"g1\":{\"value\":100}" +- + "}," +- + "\"counters\":{" +- + "\"c\":{\"count\":1}" +- + "}," +- + "\"histograms\":{" +- + "\"h\":{\"count\":1,\"max\":1,\"mean\":1.0,\"min\":1,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0}" +- + "}," +- + "\"meters\":{" +- + "\"m\":{\"count\":1,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":3333333.3333333335,\"units\":\"events/second\"}},\"timers\":{\"t\":{\"count\":1,\"max\":1.0,\"mean\":1.0,\"min\":1.0,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":1.0E7,\"duration_units\":\"seconds\",\"rate_units\":\"calls/second\"}" +- + "}" +- + "})"); ++ "%s({\"version\":\"4.0.0\",\"gauges\":{\"g1\":{\"value\":100}},\"counters\":{\"c\":{\"count\":1}},\"histograms\":{\"h\":{\"count\":1,\"max\":1,\"mean\":1.0,\"min\":1,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0}},\"meters\":{\"m\":{\"count\":1,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":3333333.3333333335,\"units\":\"events/second\"}},\"timers\":{\"t\":{\"count\":1,\"max\":1.0,\"mean\":1.0,\"min\":1.0,\"p50\":1.0,\"p75\":1.0,\"p95\":1.0,\"p98\":1.0,\"p99\":1.0,\"p999\":1.0,\"stddev\":0.0,\"m15_rate\":0.0,\"m1_rate\":0.0,\"m5_rate\":0.0,\"mean_rate\":1.0E7,\"duration_units\":\"seconds\",\"rate_units\":\"calls/second\"}}})", ++ callbackParamVal); + assertThat(response.get(HttpHeader.CONTENT_TYPE)).isEqualTo("application/json"); + } + +@@ -223,41 +207,40 @@ public class MetricsServletTest extends AbstractServletTest { + @Test + public void constructorWithRegistryAsArgumentIsUsedInPreferenceOverServletConfig() + throws Exception { +- final MetricRegistry metricRegistry = mock(MetricRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final MetricRegistry metricRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); + + final MetricsServlet metricsServlet = new MetricsServlet(metricRegistry); + metricsServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); +- verify(servletContext, never()).getAttribute(eq(MetricsServlet.METRICS_REGISTRY)); ++ verify(servletConfig).getServletContext(); ++ verify(servletContext, never()).getAttribute(MetricsServlet.METRICS_REGISTRY); + } + + @Test + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNull() throws Exception { +- final MetricRegistry metricRegistry = mock(MetricRegistry.class); +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final MetricRegistry metricRegistry = mock(); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); +- when(servletContext.getAttribute(eq(MetricsServlet.METRICS_REGISTRY))) +- .thenReturn(metricRegistry); ++ when(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)).thenReturn(metricRegistry); + + final MetricsServlet metricsServlet = new MetricsServlet(null); + metricsServlet.init(servletConfig); + +- verify(servletConfig, times(1)).getServletContext(); +- verify(servletContext, times(1)).getAttribute(eq(MetricsServlet.METRICS_REGISTRY)); ++ verify(servletConfig).getServletContext(); ++ verify(servletContext).getAttribute(MetricsServlet.METRICS_REGISTRY); + } + + @Test(expected = ServletException.class) + public void constructorWithRegistryAsArgumentUsesServletConfigWhenNullButWrongTypeInContext() + throws Exception { +- final ServletContext servletContext = mock(ServletContext.class); +- final ServletConfig servletConfig = mock(ServletConfig.class); ++ final ServletContext servletContext = mock(); ++ final ServletConfig servletConfig = mock(); + when(servletConfig.getServletContext()).thenReturn(servletContext); +- when(servletContext.getAttribute(eq(MetricsServlet.METRICS_REGISTRY))) ++ when(servletContext.getAttribute(MetricsServlet.METRICS_REGISTRY)) + .thenReturn("IRELLEVANT_STRING"); + + final MetricsServlet metricsServlet = new MetricsServlet(null); diff --git a/integration-tests/metrics-v4.2.19-expected-warnings.txt b/integration-tests/metrics-v4.2.19-expected-warnings.txt index b9eae8e494e..e7e82b304a2 100644 --- a/integration-tests/metrics-v4.2.19-expected-warnings.txt +++ b/integration-tests/metrics-v4.2.19-expected-warnings.txt @@ -1,6 +1,131 @@ -metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[37,12] [removal] SecurityManager in java.lang has been deprecated and marked for removal -metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[37,38] [removal] getSecurityManager() in System has been deprecated and marked for removal -metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[269,32] [removal] getSecurityManager() in System has been deprecated and marked for removal -metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[269,6] [removal] SecurityManager in java.lang has been deprecated and marked for removal +metrics-caffeine/src/test/java/com/codahale/metrics/caffeine/MetricsStatsCounterTest.java:[89,9] [deprecation] recordEviction() in MetricsStatsCounter has been deprecated +metrics-caffeine/src/test/java/com/codahale/metrics/caffeine/MetricsStatsCounterTest.java:[96,9] [deprecation] recordEviction(int) in MetricsStatsCounter has been deprecated +metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java:[150,8] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java:[154,8] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java:[81,68] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[124,20] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[162,12] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[167,11] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[173,17] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[198,8] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[201,21] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[204,11] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[241,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[250,36] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[266,6] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-collectd/src/main/java/com/codahale/metrics/collectd/Sender.java:[22,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterTest.java:[249,43] [Refaster Rule] ImmutableMapRules.ImmutableMapOf1: Refactoring opportunity +metrics-collectd/src/test/java/com/codahale/metrics/collectd/CollectdReporterTest.java:[255,40] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java:[57,41] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/CsvReporter.java:[382,35] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-core/src/main/java/com/codahale/metrics/InstrumentedExecutorService.java:[196,25] [try] auto-closeable resource durationContext is never referenced in body of corresponding try statement +metrics-core/src/main/java/com/codahale/metrics/InstrumentedExecutorService.java:[218,25] [try] auto-closeable resource context is never referenced in body of corresponding try statement +metrics-core/src/main/java/com/codahale/metrics/LockFreeExponentiallyDecayingReservoir.java:[240,6] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/MetricRegistry.java:[101,4] [Refaster Rule] PreconditionsRules.RequireNonNullWithMessageStatement: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/MetricRegistry.java:[50,21] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[218,19] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[39,4] [Refaster Rule] PreconditionsRules.RequireNonNullWithMessageStatement: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[608,21] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[614,21] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[620,21] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[132,16] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[145,4] [Refaster Rule] PreconditionsRules.RequireNonNullWithMessageStatement: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[158,78] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[176,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[38,12] [removal] SecurityManager in java.lang has been deprecated and marked for removal +metrics-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[38,38] [removal] getSecurityManager() in System has been deprecated and marked for removal +metrics-core/src/main/java/com/codahale/metrics/SharedMetricRegistries.java:[87,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/Slf4jReporter.java:[82,46] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/UniformSnapshot.java:[50,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-core/src/main/java/com/codahale/metrics/WeightedSnapshot.java:[67,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-core/src/test/java/com/codahale/metrics/SharedMetricRegistriesTest.java:[12,62] [deprecation] none() in ExpectedException has been deprecated +metrics-core/src/test/java/com/codahale/metrics/WeightedSnapshotTest.java:[19,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/Graphite.java:[119,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/Graphite.java:[66,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/Graphite.java:[70,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteRabbitMQ.java:[112,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[429,17] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[434,19] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[447,20] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[84,46] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteUDP.java:[46,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-graphite/src/main/java/com/codahale/metrics/graphite/PickledGraphite.java:[176,4] [Refaster Rule] PreconditionsRules.CheckStateWithMessage: Refactoring opportunity +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java:[177,46] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java:[462,16] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java:[47,44] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java:[478,42] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteReporterTest.java:[57,44] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-healthchecks/src/main/java/com/codahale/metrics/health/AsyncHealthCheckDecorator.java:[80,4] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[270,32] [removal] getSecurityManager() in System has been deprecated and marked for removal +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[270,6] [removal] SecurityManager in java.lang has been deprecated and marked for removal +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[96,6] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java:[189,46] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java:[203,46] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-healthchecks/src/test/java/com/codahale/metrics/health/SharedHealthCheckRegistriesTest.java:[13,70] [deprecation] none() in ExpectedException has been deprecated +metrics-healthchecks/src/test/java/com/codahale/metrics/health/jvm/ThreadDeadlockHealthCheckTest.java:[20,61] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[101,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[112,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[120,22] [deprecation] rewriteURI(URI,HttpHost,boolean) in URIUtils has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[31,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[38,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[45,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[54,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[63,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[70,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[78,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[86,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient/src/test/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategiesTest.java:[94,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[23,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[30,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[37,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[44,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[53,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[62,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[69,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[80,4] [deprecation] assertThat(T,Matcher) in Assert has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/HttpClientMetricNameStrategiesTest.java:[88,22] [deprecation] rewriteURI(URI,HttpHost,boolean) in URIUtils has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java:[126,8] [deprecation] SimpleHttpRequests in org.apache.hc.client5.http.async.methods has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java:[182,10] [deprecation] SimpleHttpRequests in org.apache.hc.client5.http.async.methods has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java:[26,47] [deprecation] SimpleHttpRequests in org.apache.hc.client5.http.async.methods has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpAsyncClientsTest.java:[77,8] [deprecation] SimpleHttpRequests in org.apache.hc.client5.http.async.methods has been deprecated +metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientsTest.java:[67,12] [deprecation] execute(ClassicHttpRequest) in HttpClient has been deprecated +metrics-jakarta-servlet/src/main/java/io/dropwizard/metrics/servlet/AbstractInstrumentedFilter.java:[67,27] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[29,67] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-jdbi3/src/main/java/com/codahale/metrics/jdbi3/InstrumentedTimingCollector.java:[9,33] [deprecation] TimingCollector in org.jdbi.v3.core.statement has been deprecated +metrics-jdbi3/src/main/java/com/codahale/metrics/jdbi3/strategies/DefaultNameStrategy.java:[15,28] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/strategies/SmartNameStrategyTest.java:[17,10] [deprecation] InstrumentedTimingCollector in com.codahale.metrics.jdbi3 has been deprecated +metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/strategies/SmartNameStrategyTest.java:[23,20] [deprecation] InstrumentedTimingCollector in com.codahale.metrics.jdbi3 has been deprecated +metrics-jdbi3/src/test/java/com/codahale/metrics/jdbi3/strategies/SmartNameStrategyTest.java:[8,33] [deprecation] InstrumentedTimingCollector in com.codahale.metrics.jdbi3 has been deprecated +metrics-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java:[172,25] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java:[174,86] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java:[543,29] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java:[172,25] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java:[174,86] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java:[543,29] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java:[172,25] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java:[174,86] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java:[543,29] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHandler.java:[177,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHandler.java:[188,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListener.java:[137,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty10/src/main/java/io/dropwizard/metrics/jetty10/InstrumentedHttpChannelListener.java:[148,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHandler.java:[177,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHandler.java:[188,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListener.java:[137,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty11/src/main/java/io/dropwizard/metrics/jetty11/InstrumentedHttpChannelListener.java:[148,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHandler.java:[185,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHandler.java:[196,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListener.java:[137,22] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jetty9/src/main/java/com/codahale/metrics/jetty9/InstrumentedHttpChannelListener.java:[148,23] [Refaster Rule] ImmutableListRules.ImmutableListOf: Refactoring opportunity +metrics-jmx/src/main/java/com/codahale/metrics/jmx/JmxReporter.java:[65,43] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jmx/src/main/java/com/codahale/metrics/jmx/JmxReporter.java:[66,39] [Refaster Rule] ImmutableMapRules.ImmutableMapOf: Refactoring opportunity +metrics-jmx/src/main/java/com/codahale/metrics/jmx/JmxReporter.java:[92,6] [Refaster Rule] PreconditionsRules.CheckArgumentWithMessage: Refactoring opportunity +metrics-json/src/main/java/com/codahale/metrics/json/HealthCheckModule.java:[83,62] [Refaster Rule] ImmutableListRules.ImmutableListOf1: Refactoring opportunity +metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadDeadlockDetector.java:[55,19] [Refaster Rule] ImmutableSetRules.ImmutableSetOf: Refactoring opportunity metrics-jvm/src/test/java/com/codahale/metrics/jvm/FileDescriptorRatioGaugeSunManagementNotExistsTest.java:[55,10] [removal] AccessController in java.security has been deprecated and marked for removal metrics-jvm/src/test/java/com/codahale/metrics/jvm/FileDescriptorRatioGaugeSunManagementNotExistsTest.java:[9,20] [removal] AccessController in java.security has been deprecated and marked for removal +metrics-jvm/src/test/java/com/codahale/metrics/jvm/GarbageCollectorMetricSetTest.java:[17,49] [Refaster Rule] ImmutableListRules.ImmutableListOf1: Refactoring opportunity +metrics-log4j2/src/main/java/com/codahale/metrics/log4j2/InstrumentedAppender.java:[85,4] [deprecation] AbstractAppender(String,Filter,Layout,boolean) in AbstractAppender has been deprecated +metrics-log4j2/src/main/java/com/codahale/metrics/log4j2/InstrumentedAppender.java:[96,4] [deprecation] AbstractAppender(String,Filter,Layout,boolean) in AbstractAppender has been deprecated +metrics-servlet/src/main/java/com/codahale/metrics/servlet/AbstractInstrumentedFilter.java:[67,27] [Refaster Rule] StringRules.StringIsNullOrEmpty: Refactoring opportunity +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[30,67] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone diff --git a/integration-tests/metrics-v4.2.19-init.patch b/integration-tests/metrics-v4.2.19-init.patch index 56d6e170972..613465ecb18 100644 --- a/integration-tests/metrics-v4.2.19-init.patch +++ b/integration-tests/metrics-v4.2.19-init.patch @@ -31,7 +31,7 @@ index 6192b52..bcbd571 100644 2.19.1 9+181-r4173-1 - -+ -Xplugin:ErrorProne ${error-prone.flags} -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\$StringIsNullOrEmpty)).*) ++ -Xplugin:ErrorProne ${error-prone.flags} + 8 dropwizard_metrics dropwizard diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index 96f1488a12e..afed0bbe425 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -14,4 +14,6 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "" "" "$do_sync" "$report_directory" +patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" + +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "${patch_flags}" "" "" "$do_sync" "$report_directory"