From 4ec06781478bbd01301ea05f2f8457a8aaee429f Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 23 Nov 2023 14:55:54 +0100 Subject: [PATCH 01/27] Initial metrics integration test --- .../metrics-v4.2.19-expected-changes.patch | 6660 +++++++++++++++++ .../metrics-v4.2.19-expected-warnings.txt | 8 + integration-tests/metrics-v4.2.19-init.patch | 219 + integration-tests/metrics-v4.2.19.sh | 180 + 4 files changed, 7067 insertions(+) create mode 100644 integration-tests/metrics-v4.2.19-expected-changes.patch create mode 100644 integration-tests/metrics-v4.2.19-expected-warnings.txt create mode 100644 integration-tests/metrics-v4.2.19-init.patch create mode 100755 integration-tests/metrics-v4.2.19.sh diff --git a/integration-tests/metrics-v4.2.19-expected-changes.patch b/integration-tests/metrics-v4.2.19-expected-changes.patch new file mode 100644 index 0000000000..5d6d51f6b8 --- /dev/null +++ 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 new file mode 100644 index 0000000000..972ecad639 --- /dev/null +++ b/integration-tests/metrics-v4.2.19-expected-warnings.txt @@ -0,0 +1,8 @@ +metrics-core/src/main/java/com/codahale/metrics/CsvReporter.java:[382,36] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[429,18] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[434,20] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[447,21] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java:[189,47] [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,47] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[29,68] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[30,68] [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 new file mode 100644 index 0000000000..8ce1957ec7 --- /dev/null +++ b/integration-tests/metrics-v4.2.19-init.patch @@ -0,0 +1,219 @@ +diff --git 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 +index a248dd8..4e7f053 100644 +--- 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 +@@ -188,6 +188,7 @@ public class MetricsServlet extends HttpServlet { + return mapper.writer(); + } + ++ @SuppressWarnings("IdentityConversion") + protected TimeUnit parseTimeUnit(String value, TimeUnit defaultValue) { + try { + return TimeUnit.valueOf(String.valueOf(value).toUpperCase(Locale.US)); +diff --git a/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java b/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java +index 0bd1297..7c69a08 100644 +--- a/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java ++++ b/metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java +@@ -189,6 +189,7 @@ public class MetricsServlet extends HttpServlet { + return mapper.writer(); + } + ++ @SuppressWarnings("IdentityConversion") + protected TimeUnit parseTimeUnit(String value, TimeUnit defaultValue) { + try { + return TimeUnit.valueOf(String.valueOf(value).toUpperCase(Locale.US)); +diff --git a/pom.xml b/pom.xml +index 6192b52..f1eebbe 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -66,7 +66,7 @@ + 4.13.1 + 1.3 + 3.11.0 +- 2.19.1 ++ -Xplugin:ErrorProne ${error-prone.flags} -Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\$StringIsNullOrEmpty)).*) + 9+181-r4173-1 + + dropwizard_metrics +@@ -137,60 +137,110 @@ + + + +- jdk8 +- +- 1.8 +- ++ error-prone-compile + + +- +- org.apache.maven.plugins +- maven-compiler-plugin ++ ++ org.apache.maven.plugins ++ maven-compiler-plugin ++ ${maven-compiler-plugin.version} ++ ++ ++ error-prone-compile ++ compile ++ ++ compile ++ + +- +- -J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${errorprone.javac.version}/javac-${errorprone.javac.version}.jar +- ++ false ++ 1.8 ++ 1.8 ++ ++ -Xpkginfo:always ++ -XDcompilePolicy=simple ++ ${error-prone-support.flags} ++ ++ ++ ++ com.google.errorprone ++ error_prone_core ++ ${error-prone.version} ++ ++ ++ tech.picnic.error-prone-support ++ error-prone-contrib ++ ${error-prone-support.version} ++ ++ ++ tech.picnic.error-prone-support ++ refaster-runner ++ ${error-prone-support.version} ++ ++ + +- ++ ++ ++ + +- ++ + + +- jdk17 +- +- [17,) +- ++ error-prone-test-compile + +- +- +- org.apache.maven.plugins +- maven-compiler-plugin +- +- +- -Xlint:all +- -XDcompilePolicy=simple +- -Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.* +- -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED +- -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED +- -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED +- -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED +- +- +- +- com.google.errorprone +- error_prone_core +- ${errorprone.version} +- +- +- +- +- ++ ++ ++ org.apache.maven.plugins ++ maven-compiler-plugin ++ ${maven-compiler-plugin.version} ++ ++ ++ ++ default-testCompile ++ test-compile ++ ++ testCompile ++ ++ ++ true ++ ++ ++ ++ error-prone-test-compile ++ test-compile ++ ++ testCompile ++ ++ ++ false ++ 1.8 ++ 1.8 ++ ++ -Xpkginfo:always ++ -XDcompilePolicy=simple ++ ${error-prone-support.flags} ++ ++ ++ ++ com.google.errorprone ++ error_prone_core ++ ${error-prone.version} ++ ++ ++ tech.picnic.error-prone-support ++ error-prone-contrib ++ ${error-prone-support.version} ++ ++ ++ tech.picnic.error-prone-support ++ refaster-runner ++ ${error-prone-support.version} ++ ++ ++ ++ ++ ++ ++ + + + +@@ -315,23 +365,13 @@ + org.apache.maven.plugins + maven-compiler-plugin + +- 1.8 +- 1.8 +- true ++ false + true + true + + -Xlint:all + -XDcompilePolicy=simple +- -Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.* + +- +- +- com.google.errorprone +- error_prone_core +- ${errorprone.version} +- +- + + + diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh new file mode 100755 index 0000000000..425e075b2a --- /dev/null +++ b/integration-tests/metrics-v4.2.19.sh @@ -0,0 +1,180 @@ +#!/usr/bin/env bash + +set -e -u -o pipefail + +integration_test_root="$(readlink -f "$(dirname "${0}")")" +error_prone_support_root="${integration_test_root}/.." +repos_root="${integration_test_root}/.repos" + +test_name="$(basename "${0}" .sh)" +project=metrics +repository=https://github.com/dropwizard/metrics.git +revision=v4.2.19 + +if [ "${#}" -gt 2 ] || ([ "${#}" = 2 ] && [ "${1:---sync}" != '--sync' ]); then + echo "Usage: ${0} [--sync] []" + exit 1 +fi +do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" +report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" + +if [ -n "${report_directory}" ]; then + mkdir -p "${report_directory}" +else + report_directory="$(mktemp -d)" + trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT +fi + +# XXX: Configure Renovate to manage the AssertJ version declared here. +shared_build_flags=" + -Perror-prone-compile,error-prone-test-compile + -Dassertj.version=3.24.2 + -Derror-prone.version=$( + mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=version.error-prone -q -DforceStdout + ) + -Derror-prone-support.version=$( + mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout + ) + -DadditionalSourceDirectories=\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java + " + +# XXX: Configure Renovate to manage the fmt-maven-plugin version declared here. +# XXX: Once GitHub actions uses Maven 3.9.2+, we can inline this variable with +# version reference `${fmt.version}`, and `-Dfmt.version=2.21.1` added to +# `shared_build_flags`. +format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format' + +error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*' + +error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( + find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ + | xargs -0 grep -hoP '[^.]+$' \ + | paste -s -d ',' +)" + +error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( + find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ + | xargs -0 grep -hoP '[^.]+$' \ + | sed -r 's,(.*),-Xep:\1:WARN,' \ + | paste -s -d ' ' +)" + +echo "Shared build flags: ${shared_build_flags}" +echo "Error Prone patch flags: ${error_prone_patch_flags}" +echo "Error Prone validation flags: ${error_prone_validation_flags}" + +mkdir -p "${repos_root}" + +# Make sure that the targeted tag of the project's Git repository is checked +# out. +project_root="${repos_root}/${project}" +if [ ! -d "${project_root}" ]; then + # The repository has not yet been cloned; create a shallow clone. + git clone --branch "${revision}" --depth 1 "${repository}" "${project_root}" +else + # The repository does already appear to exist. Try to check out the requested + # tag if possible, and fetch it otherwise. + # + # Under certain circumstances this does not cause the relevant tag to be + # created, so if necessary we manually create it. + git -C "${project_root}" checkout --force "${revision}" 2>/dev/null \ + || ( + git -C "${project_root}" fetch --depth 1 "${repository}" "${revision}" \ + && git -C "${project_root}" checkout --force FETCH_HEAD \ + && (git -C "${project_root}" tag "${revision}" || true) + ) +fi + +pushd "${project_root}" + +# Make sure that Git is sufficiently configured to enable committing to the +# project's Git repository. +git config user.email || git config user.email "integration-test@example.com" +git config user.name || git config user.name "Integration Test" + +# Prepare the code for analysis by (a) applying the minimal set of changes +# required to run Error Prone with Error Prone Support and (b) formatting the +# code using the same method by which it will be formatted after each +# compilation round. The initial formatting operation ensures that subsequent +# modifications can be rendered in a clean manner. +git clean -fdx +git apply < "${integration_test_root}/${test_name}-init.patch" +git commit -m 'dependency: Introduce Error Prone Support' . +mvn ${shared_build_flags} "${format_goal}" +git commit -m 'minor: Reformat using Google Java Format' . +diff_base="$(git rev-parse HEAD)" + +# Apply Error Prone Support-suggested changes until a fixed point is reached. +function apply_patch() { + local extra_build_args="${1}" + + mvn ${shared_build_flags} ${extra_build_args} \ + package "${format_goal}" \ + -Derror-prone.flags="${error_prone_patch_flags}" \ + -DskipTests + + if ! git diff --exit-code; then + git commit -m 'minor: Apply patches' . + + # Changes were applied, so another compilation round may apply yet more + # changes. For performance reasons we perform incremental compilation, + # enabled using a misleading flag. (See + # https://issues.apache.org/jira/browse/MCOMPILER-209 for details.) + apply_patch '-Dmaven.compiler.useIncrementalCompilation=false' + elif [ "${extra_build_args}" != 'clean' ]; then + # No changes were applied. We'll attempt one more round in which all files + # are recompiled, because there are cases in which violations are missed + # during incremental compilation. + apply_patch 'clean' + fi +} +apply_patch '' + +# Run one more full build and log the output. +# +# By also running the tests, we validate that the (majority of) applied changes +# are behavior preserving. Some tests are skipped: +# - The `metadataFilesGenerationAllFiles` test is skipped because it makes line +# number assertions that will fail when the code is formatted or patched. +# - The `allCheckSectionJavaDocs` test is skipped because is validates that +# Javadoc has certain closing tags that are removed by Google Java Format. +validation_build_log="${report_directory}/${test_name}-validation-build-log.txt" +mvn ${shared_build_flags} \ + clean package \ + -Derror-prone.flags="${error_prone_validation_flags}" \ + | tee "${validation_build_log}" \ + || failure=1 + +# Collect the applied changes. +expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" +actual_changes="${report_directory}/${test_name}-changes.patch" +(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}" + +# Collect the warnings reported by Error Prone Support checks. +expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" +actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" +(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" + +# Persist or validate the applied changes and reported warnings. +if [ -n "${do_sync}" ]; then + echo 'Saving changes...' + cp "${actual_changes}" "${expected_changes}" + cp "${actual_warnings}" "${expected_warnings}" +else + echo 'Inspecting changes...' + # XXX: This "diff of diffs" also contains vacuous sections, introduced due to + # line offset differences. Try to omit those from the final output. + if ! diff -u "${expected_changes}" "${actual_changes}"; then + echo 'There are unexpected changes.' + failure=1 + fi + echo 'Inspecting emitted warnings...' + if ! diff -u "${expected_warnings}" "${actual_warnings}"; then + echo 'Diagnostics output changed.' + failure=1 + fi +fi + +if [ -n "${failure:-}" ]; then + exit 1 +fi From 11d02d468e985750d6bef37976e421d75bd315e7 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 23 Nov 2023 16:33:05 +0100 Subject: [PATCH 02/27] Integration test script --- integration-tests/integration-test.sh | 186 ++++++++++++++++++++++++++ integration-tests/metrics-v4.2.19.sh | 165 +---------------------- 2 files changed, 187 insertions(+), 164 deletions(-) create mode 100755 integration-tests/integration-test.sh diff --git a/integration-tests/integration-test.sh b/integration-tests/integration-test.sh new file mode 100755 index 0000000000..5e0e75f2eb --- /dev/null +++ b/integration-tests/integration-test.sh @@ -0,0 +1,186 @@ +#!/usr/bin/env bash + +set -e -u -o pipefail + +integration_test_root="$(readlink -f "$(dirname "${0}")")" +error_prone_support_root="${integration_test_root}/.." +repos_root="${integration_test_root}/.repos" + +if [ "${#}" -ne 10 ]; then + >&2 echo "Usage $(basename "${0}") " + + exit 1 +fi + +test_name="${1}" +project="${2}" +repository="${3}" +revision="${4}" +build_flags="${5}" +patch_flags="${6}" +validation_ep_flags="${7}" +validation_mvn_flags="${8}" +do_sync="${9}" +report_directory="${10}" + +if [ -n "${report_directory}" ]; then + mkdir -p "${report_directory}" +else + report_directory="$(mktemp -d)" + trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT +fi + +# XXX: Configure Renovate to manage the AssertJ version declared here. +shared_build_flags=" + -Perror-prone-compile,error-prone-test-compile + -Derror-prone.version=$( + mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=version.error-prone -q -DforceStdout + ) + -Derror-prone-support.version=$( + mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout + ) + -DadditionalSourceDirectories=\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java + ${build_flags} + " + +# XXX: Configure Renovate to manage the fmt-maven-plugin version declared here. +# XXX: Once GitHub actions uses Maven 3.9.2+, we can inline this variable with +# version reference `${fmt.version}`, and `-Dfmt.version=2.21.1` added to +# `shared_build_flags`. +format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format' + +error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*' + +error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( + find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ + | xargs -0 grep -hoP '[^.]+$' \ + | paste -s -d ',' +) ${patch_flags}" + +error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( + find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ + | xargs -0 grep -hoP '[^.]+$' \ + | sed -r 's,(.*),-Xep:\1:WARN,' \ + | paste -s -d ' ' +) ${validation_ep_flags}" + +echo "Shared build flags: ${shared_build_flags}" +echo "Error Prone patch flags: ${error_prone_patch_flags}" +echo "Error Prone validation flags: ${error_prone_validation_flags}" + +mkdir -p "${repos_root}" + +# Make sure that the targeted tag of the project's Git repository is checked +# out. +project_root="${repos_root}/${project}" +if [ ! -d "${project_root}" ]; then + # The repository has not yet been cloned; create a shallow clone. + git clone --branch "${revision}" --depth 1 "${repository}" "${project_root}" +else + # The repository does already appear to exist. Try to check out the requested + # tag if possible, and fetch it otherwise. + # + # Under certain circumstances this does not cause the relevant tag to be + # created, so if necessary we manually create it. + git -C "${project_root}" checkout --force "${revision}" 2>/dev/null \ + || ( + git -C "${project_root}" fetch --depth 1 "${repository}" "${revision}" \ + && git -C "${project_root}" checkout --force FETCH_HEAD \ + && (git -C "${project_root}" tag "${revision}" || true) + ) +fi + +pushd "${project_root}" + +# Make sure that Git is sufficiently configured to enable committing to the +# project's Git repository. +git config user.email || git config user.email "integration-test@example.com" +git config user.name || git config user.name "Integration Test" + +# Prepare the code for analysis by (a) applying the minimal set of changes +# required to run Error Prone with Error Prone Support and (b) formatting the +# code using the same method by which it will be formatted after each +# compilation round. The initial formatting operation ensures that subsequent +# modifications can be rendered in a clean manner. +git clean -fdx +git apply < "${integration_test_root}/${test_name}-init.patch" +git commit -m 'dependency: Introduce Error Prone Support' . +mvn ${shared_build_flags} "${format_goal}" +git commit -m 'minor: Reformat using Google Java Format' . +diff_base="$(git rev-parse HEAD)" + +# Apply Error Prone Support-suggested changes until a fixed point is reached. +function apply_patch() { + local extra_build_args="${1}" + + mvn ${shared_build_flags} ${extra_build_args} \ + package "${format_goal}" \ + -Derror-prone.flags="${error_prone_patch_flags}" \ + -DskipTests + + if ! git diff --exit-code; then + git commit -m 'minor: Apply patches' . + + # Changes were applied, so another compilation round may apply yet more + # changes. For performance reasons we perform incremental compilation, + # enabled using a misleading flag. (See + # https://issues.apache.org/jira/browse/MCOMPILER-209 for details.) + apply_patch '-Dmaven.compiler.useIncrementalCompilation=false' + elif [ "${extra_build_args}" != 'clean' ]; then + # No changes were applied. We'll attempt one more round in which all files + # are recompiled, because there are cases in which violations are missed + # during incremental compilation. + apply_patch 'clean' + fi +} +apply_patch '' + +# Run one more full build and log the output. +# +# By also running the tests, we validate that the (majority of) applied changes +# are behavior preserving. Some tests are skipped: +# - The `metadataFilesGenerationAllFiles` test is skipped because it makes line +# number assertions that will fail when the code is formatted or patched. +# - The `allCheckSectionJavaDocs` test is skipped because is validates that +# Javadoc has certain closing tags that are removed by Google Java Format. +validation_build_log="${report_directory}/${test_name}-validation-build-log.txt" +mvn ${shared_build_flags} \ + clean package \ + -Derror-prone.flags="${error_prone_validation_flags}" \ + ${validation_mvn_flags} \ + | tee "${validation_build_log}" \ + || failure=1 + +# Collect the applied changes. +expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" +actual_changes="${report_directory}/${test_name}-changes.patch" +(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}" + +# Collect the warnings reported by Error Prone Support checks. +expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" +actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" +(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" + +# Persist or validate the applied changes and reported warnings. +if [ -n "${do_sync}" ]; then + echo 'Saving changes...' + cp "${actual_changes}" "${expected_changes}" + cp "${actual_warnings}" "${expected_warnings}" +else + echo 'Inspecting changes...' + # XXX: This "diff of diffs" also contains vacuous sections, introduced due to + # line offset differences. Try to omit those from the final output. + if ! diff -u "${expected_changes}" "${actual_changes}"; then + echo 'There are unexpected changes.' + failure=1 + fi + echo 'Inspecting emitted warnings...' + if ! diff -u "${expected_warnings}" "${actual_warnings}"; then + echo 'Diagnostics output changed.' + failure=1 + fi +fi + +if [ -n "${failure:-}" ]; then + exit 1 +fi diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index 425e075b2a..eb660875ef 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -2,10 +2,6 @@ set -e -u -o pipefail -integration_test_root="$(readlink -f "$(dirname "${0}")")" -error_prone_support_root="${integration_test_root}/.." -repos_root="${integration_test_root}/.repos" - test_name="$(basename "${0}" .sh)" project=metrics repository=https://github.com/dropwizard/metrics.git @@ -18,163 +14,4 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -if [ -n "${report_directory}" ]; then - mkdir -p "${report_directory}" -else - report_directory="$(mktemp -d)" - trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT -fi - -# XXX: Configure Renovate to manage the AssertJ version declared here. -shared_build_flags=" - -Perror-prone-compile,error-prone-test-compile - -Dassertj.version=3.24.2 - -Derror-prone.version=$( - mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=version.error-prone -q -DforceStdout - ) - -Derror-prone-support.version=$( - mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout - ) - -DadditionalSourceDirectories=\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java - " - -# XXX: Configure Renovate to manage the fmt-maven-plugin version declared here. -# XXX: Once GitHub actions uses Maven 3.9.2+, we can inline this variable with -# version reference `${fmt.version}`, and `-Dfmt.version=2.21.1` added to -# `shared_build_flags`. -format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format' - -error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*' - -error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( - find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ - | paste -s -d ',' -)" - -error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( - find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ - | sed -r 's,(.*),-Xep:\1:WARN,' \ - | paste -s -d ' ' -)" - -echo "Shared build flags: ${shared_build_flags}" -echo "Error Prone patch flags: ${error_prone_patch_flags}" -echo "Error Prone validation flags: ${error_prone_validation_flags}" - -mkdir -p "${repos_root}" - -# Make sure that the targeted tag of the project's Git repository is checked -# out. -project_root="${repos_root}/${project}" -if [ ! -d "${project_root}" ]; then - # The repository has not yet been cloned; create a shallow clone. - git clone --branch "${revision}" --depth 1 "${repository}" "${project_root}" -else - # The repository does already appear to exist. Try to check out the requested - # tag if possible, and fetch it otherwise. - # - # Under certain circumstances this does not cause the relevant tag to be - # created, so if necessary we manually create it. - git -C "${project_root}" checkout --force "${revision}" 2>/dev/null \ - || ( - git -C "${project_root}" fetch --depth 1 "${repository}" "${revision}" \ - && git -C "${project_root}" checkout --force FETCH_HEAD \ - && (git -C "${project_root}" tag "${revision}" || true) - ) -fi - -pushd "${project_root}" - -# Make sure that Git is sufficiently configured to enable committing to the -# project's Git repository. -git config user.email || git config user.email "integration-test@example.com" -git config user.name || git config user.name "Integration Test" - -# Prepare the code for analysis by (a) applying the minimal set of changes -# required to run Error Prone with Error Prone Support and (b) formatting the -# code using the same method by which it will be formatted after each -# compilation round. The initial formatting operation ensures that subsequent -# modifications can be rendered in a clean manner. -git clean -fdx -git apply < "${integration_test_root}/${test_name}-init.patch" -git commit -m 'dependency: Introduce Error Prone Support' . -mvn ${shared_build_flags} "${format_goal}" -git commit -m 'minor: Reformat using Google Java Format' . -diff_base="$(git rev-parse HEAD)" - -# Apply Error Prone Support-suggested changes until a fixed point is reached. -function apply_patch() { - local extra_build_args="${1}" - - mvn ${shared_build_flags} ${extra_build_args} \ - package "${format_goal}" \ - -Derror-prone.flags="${error_prone_patch_flags}" \ - -DskipTests - - if ! git diff --exit-code; then - git commit -m 'minor: Apply patches' . - - # Changes were applied, so another compilation round may apply yet more - # changes. For performance reasons we perform incremental compilation, - # enabled using a misleading flag. (See - # https://issues.apache.org/jira/browse/MCOMPILER-209 for details.) - apply_patch '-Dmaven.compiler.useIncrementalCompilation=false' - elif [ "${extra_build_args}" != 'clean' ]; then - # No changes were applied. We'll attempt one more round in which all files - # are recompiled, because there are cases in which violations are missed - # during incremental compilation. - apply_patch 'clean' - fi -} -apply_patch '' - -# Run one more full build and log the output. -# -# By also running the tests, we validate that the (majority of) applied changes -# are behavior preserving. Some tests are skipped: -# - The `metadataFilesGenerationAllFiles` test is skipped because it makes line -# number assertions that will fail when the code is formatted or patched. -# - The `allCheckSectionJavaDocs` test is skipped because is validates that -# Javadoc has certain closing tags that are removed by Google Java Format. -validation_build_log="${report_directory}/${test_name}-validation-build-log.txt" -mvn ${shared_build_flags} \ - clean package \ - -Derror-prone.flags="${error_prone_validation_flags}" \ - | tee "${validation_build_log}" \ - || failure=1 - -# Collect the applied changes. -expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" -actual_changes="${report_directory}/${test_name}-changes.patch" -(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}" - -# Collect the warnings reported by Error Prone Support checks. -expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" -actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" -(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" - -# Persist or validate the applied changes and reported warnings. -if [ -n "${do_sync}" ]; then - echo 'Saving changes...' - cp "${actual_changes}" "${expected_changes}" - cp "${actual_warnings}" "${expected_warnings}" -else - echo 'Inspecting changes...' - # XXX: This "diff of diffs" also contains vacuous sections, introduced due to - # line offset differences. Try to omit those from the final output. - if ! diff -u "${expected_changes}" "${actual_changes}"; then - echo 'There are unexpected changes.' - failure=1 - fi - echo 'Inspecting emitted warnings...' - if ! diff -u "${expected_warnings}" "${actual_warnings}"; then - echo 'Diagnostics output changed.' - failure=1 - fi -fi - -if [ -n "${failure:-}" ]; then - exit 1 -fi +./integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "" "" "$do_sync" "$report_directory" From d18dd8af5226c8b14a510a8c59de8e684b15290f Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 30 Nov 2023 10:23:09 +0100 Subject: [PATCH 03/27] Use integration-test.sh in checkstyle --- integration-tests/checkstyle.sh | 191 +------------------------- integration-tests/integration-test.sh | 56 +++++--- 2 files changed, 43 insertions(+), 204 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index 0b1f5a5e4c..9ffdf8519c 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -2,10 +2,6 @@ set -e -u -o pipefail -integration_test_root="$(cd "$(dirname -- "${0}")" && pwd)" -error_prone_support_root="${integration_test_root}/.." -repos_root="${integration_test_root}/.repos" - test_name="$(basename "${0}" .sh)" project=checkstyle repository=https://github.com/checkstyle/checkstyle.git @@ -18,189 +14,8 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -if [ -n "${report_directory}" ]; then - mkdir -p "${report_directory}" -else - report_directory="$(mktemp -d)" - trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT -fi - -case "$(uname -s)" in - Linux*) - grep_command=grep - sed_command=sed - ;; - Darwin*) - grep_command=ggrep - sed_command=gsed - ;; - *) - echo "Unsupported distribution $(uname -s) for this script." - exit 1 - ;; -esac - # XXX: Configure Renovate to manage the AssertJ version declared here. -shared_build_flags=" - -Perror-prone-compile,error-prone-test-compile - -Dassertj.version=3.24.2 - -Derror-prone.version=$( - mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=version.error-prone -q -DforceStdout - ) - -Derror-prone-support.version=$( - mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout - ) - -DadditionalSourceDirectories=\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java - " - -# XXX: Configure Renovate to manage the fmt-maven-plugin version declared here. -# XXX: Once GitHub actions uses Maven 3.9.2+, we can inline this variable with -# version reference `${fmt.version}`, and `-Dfmt.version=2.21.1` added to -# `shared_build_flags`. -format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format' - -error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*' - -error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( - find "${error_prone_support_root}" \ - -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" \ - -not -path "*/error-prone-experimental/*" \ - -not -path "*/error-prone-guidelines/*" \ - -print0 \ - | xargs -0 "${grep_command}" -hoP '[^.]+$' \ - | paste -s -d ',' - -)" - -error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( - find "${error_prone_support_root}" \ - -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" \ - -not -path "*/error-prone-experimental/*" \ - -not -path "*/error-prone-guidelines/*" \ - -print0 \ - | xargs -0 "${grep_command}" -hoP '[^.]+$' \ - | "${sed_command}" -r 's,(.*),-Xep:\1:WARN,' \ - | paste -s -d ' ' - -)" - -echo "Shared build flags: ${shared_build_flags}" -echo "Error Prone patch flags: ${error_prone_patch_flags}" -echo "Error Prone validation flags: ${error_prone_validation_flags}" - -mkdir -p "${repos_root}" - -# Make sure that the targeted tag of the project's Git repository is checked -# out. -project_root="${repos_root}/${project}" -if [ ! -d "${project_root}" ]; then - # The repository has not yet been cloned; create a shallow clone. - git clone --branch "${revision}" --depth 1 "${repository}" "${project_root}" -else - # The repository does already appear to exist. Try to check out the requested - # tag if possible, and fetch it otherwise. - # - # Under certain circumstances this does not cause the relevant tag to be - # created, so if necessary we manually create it. - git -C "${project_root}" checkout --force "${revision}" 2>/dev/null \ - || ( - git -C "${project_root}" fetch --depth 1 "${repository}" "${revision}" \ - && git -C "${project_root}" checkout --force FETCH_HEAD \ - && (git -C "${project_root}" tag "${revision}" || true) - ) -fi - -pushd "${project_root}" +build_flags="-Dassertj.version=3.24.2" +validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" -# Make sure that Git is sufficiently configured to enable committing to the -# project's Git repository. -git config user.email || git config user.email "integration-test@example.com" -git config user.name || git config user.name "Integration Test" - -# Prepare the code for analysis by (a) applying the minimal set of changes -# required to run Error Prone with Error Prone Support and (b) formatting the -# code using the same method by which it will be formatted after each -# compilation round. The initial formatting operation ensures that subsequent -# modifications can be rendered in a clean manner. -git clean -fdx -git apply < "${integration_test_root}/${test_name}-init.patch" -git commit -m 'dependency: Introduce Error Prone Support' . -mvn ${shared_build_flags} "${format_goal}" -git commit -m 'minor: Reformat using Google Java Format' . -diff_base="$(git rev-parse HEAD)" - -# Apply Error Prone Support-suggested changes until a fixed point is reached. -function apply_patch() { - local extra_build_args="${1}" - - mvn ${shared_build_flags} ${extra_build_args} \ - package "${format_goal}" \ - -Derror-prone.configuration-args="${error_prone_patch_flags}" \ - -DskipTests - - if ! git diff --exit-code; then - git commit -m 'minor: Apply patches' . - - # Changes were applied, so another compilation round may apply yet more - # changes. For performance reasons we perform incremental compilation, - # enabled using a misleading flag. (See - # https://issues.apache.org/jira/browse/MCOMPILER-209 for details.) - apply_patch '-Dmaven.compiler.useIncrementalCompilation=false' - elif [ "${extra_build_args}" != 'clean' ]; then - # No changes were applied. We'll attempt one more round in which all files - # are recompiled, because there are cases in which violations are missed - # during incremental compilation. - apply_patch 'clean' - fi -} -apply_patch '' - -# Run one more full build and log the output. -# -# By also running the tests, we validate that the (majority of) applied changes -# are behavior preserving. Some tests are skipped: -# - The `metadataFilesGenerationAllFiles` test is skipped because it makes line -# number assertions that will fail when the code is formatted or patched. -# - The `allCheckSectionJavaDocs` test is skipped because is validates that -# Javadoc has certain closing tags that are removed by Google Java Format. -validation_build_log="${report_directory}/${test_name}-validation-build-log.txt" -mvn ${shared_build_flags} \ - clean package \ - -Derror-prone.configuration-args="${error_prone_validation_flags}" \ - -Dtest=' - !MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles, - !XdocsJavaDocsTest#allCheckSectionJavaDocs' \ - | tee "${validation_build_log}" \ - || failure=1 - -# Collect the applied changes. -expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" -actual_changes="${report_directory}/${test_name}-changes.patch" -(git diff "${diff_base}"..HEAD | "${grep_command}" -vP '^(diff|index)' || true) > "${actual_changes}" - -# Collect the warnings reported by Error Prone Support checks. -expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" -actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" -("${grep_command}" -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | "${grep_command}" -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" - -# Persist or validate the applied changes and reported warnings. -if [ -n "${do_sync}" ]; then - echo 'Saving changes...' - cp "${actual_changes}" "${expected_changes}" - cp "${actual_warnings}" "${expected_warnings}" -else - echo 'Inspecting changes...' - # XXX: This "diff of diffs" also contains vacuous sections, introduced due to - # line offset differences. Try to omit those from the final output. - if ! diff -u "${expected_changes}" "${actual_changes}"; then - echo 'There are unexpected changes. Inspect the preceding output for details.' - failure=1 - fi - echo 'Inspecting emitted warnings...' - if ! diff -u "${expected_warnings}" "${actual_warnings}"; then - echo 'Diagnostics output changed. Inspect the preceding output for details.' - failure=1 - fi -fi - -if [ -n "${failure:-}" ]; then - exit 1 -fi +./integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" diff --git a/integration-tests/integration-test.sh b/integration-tests/integration-test.sh index 5e0e75f2eb..952d97273a 100755 --- a/integration-tests/integration-test.sh +++ b/integration-tests/integration-test.sh @@ -1,14 +1,15 @@ #!/usr/bin/env bash +# This script is not meant to be invoked manually, instead it should be invoked +# through one of the integration test scripts such as the metrics or checkstyle one. set -e -u -o pipefail -integration_test_root="$(readlink -f "$(dirname "${0}")")" +integration_test_root="$(cd "$(dirname -- "${0}")" && pwd)" error_prone_support_root="${integration_test_root}/.." repos_root="${integration_test_root}/.repos" if [ "${#}" -ne 10 ]; then - >&2 echo "Usage $(basename "${0}") " - + >&2 echo "Usage $(basename "${0}") [TestName] [Project] [Repository] [Revision] [BuildFlags] [PatchFlags] [ValidationEpFlags] [ValidationMvnFlags] [DoSync] [ReportDirectory]" exit 1 fi @@ -30,6 +31,21 @@ else trap 'rm -rf -- "${report_directory}"' INT TERM HUP EXIT fi +case "$(uname -s)" in + Linux*) + grep_command=grep + sed_command=sed + ;; + Darwin*) + grep_command=ggrep + sed_command=gsed + ;; + *) + echo "Unsupported distribution $(uname -s) for this script." + exit 1 + ;; +esac + # XXX: Configure Renovate to manage the AssertJ version declared here. shared_build_flags=" -Perror-prone-compile,error-prone-test-compile @@ -52,16 +68,24 @@ format_goal='com.spotify.fmt:fmt-maven-plugin:2.21.1:format' error_prone_shared_flags='-XepExcludedPaths:(\Q${project.basedir}${file.separator}src${file.separator}\E(it|test|xdocs-examples)\Q${file.separator}resources\E|\Q${project.build.directory}${file.separator}\E).*' error_prone_patch_flags="${error_prone_shared_flags} -XepPatchLocation:IN_PLACE -XepPatchChecks:$( - find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ - | paste -s -d ',' + find "${error_prone_support_root}" \ + -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" \ + -not -path "*/error-prone-experimental/*" \ + -not -path "*/error-prone-guidelines/*" \ + -print0 \ + | xargs -0 "${grep_command}" -hoP '[^.]+$' \ + | paste -s -d ',' - ) ${patch_flags}" error_prone_validation_flags="${error_prone_shared_flags} -XepDisableAllChecks $( - find "${error_prone_support_root}" -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" -print0 \ - | xargs -0 grep -hoP '[^.]+$' \ - | sed -r 's,(.*),-Xep:\1:WARN,' \ - | paste -s -d ' ' + find "${error_prone_support_root}" \ + -path "*/META-INF/services/com.google.errorprone.bugpatterns.BugChecker" \ + -not -path "*/error-prone-experimental/*" \ + -not -path "*/error-prone-guidelines/*" \ + -print0 \ + | xargs -0 "${grep_command}" -hoP '[^.]+$' \ + | "${sed_command}" -r 's,(.*),-Xep:\1:WARN,' \ + | paste -s -d ' ' - ) ${validation_ep_flags}" echo "Shared build flags: ${shared_build_flags}" @@ -115,7 +139,7 @@ function apply_patch() { mvn ${shared_build_flags} ${extra_build_args} \ package "${format_goal}" \ - -Derror-prone.flags="${error_prone_patch_flags}" \ + -Derror-prone.configuration-args="${error_prone_patch_flags}" \ -DskipTests if ! git diff --exit-code; then @@ -146,7 +170,7 @@ apply_patch '' validation_build_log="${report_directory}/${test_name}-validation-build-log.txt" mvn ${shared_build_flags} \ clean package \ - -Derror-prone.flags="${error_prone_validation_flags}" \ + -Derror-prone.configuration-args="${error_prone_validation_flags}" \ ${validation_mvn_flags} \ | tee "${validation_build_log}" \ || failure=1 @@ -154,12 +178,12 @@ mvn ${shared_build_flags} \ # Collect the applied changes. expected_changes="${integration_test_root}/${test_name}-expected-changes.patch" actual_changes="${report_directory}/${test_name}-changes.patch" -(git diff "${diff_base}"..HEAD | grep -vP '^(diff|index)' || true) > "${actual_changes}" +(git diff "${diff_base}"..HEAD | "${grep_command}" -vP '^(diff|index)' || true) > "${actual_changes}" # Collect the warnings reported by Error Prone Support checks. expected_warnings="${integration_test_root}/${test_name}-expected-warnings.txt" actual_warnings="${report_directory}/${test_name}-validation-build-warnings.txt" -(grep -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | grep -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" +("${grep_command}" -oP "(?<=^\\Q[WARNING] ${PWD}/\\E).*" "${validation_build_log}" | "${grep_command}" -P '\] \[' || true) | LC_ALL=C sort > "${actual_warnings}" # Persist or validate the applied changes and reported warnings. if [ -n "${do_sync}" ]; then @@ -171,12 +195,12 @@ else # XXX: This "diff of diffs" also contains vacuous sections, introduced due to # line offset differences. Try to omit those from the final output. if ! diff -u "${expected_changes}" "${actual_changes}"; then - echo 'There are unexpected changes.' + echo 'There are unexpected changes. Inspect the preceding output for details.' failure=1 fi echo 'Inspecting emitted warnings...' if ! diff -u "${expected_warnings}" "${actual_warnings}"; then - echo 'Diagnostics output changed.' + echo 'Diagnostics output changed. Inspect the preceding output for details.' failure=1 fi fi From d7a3fbe9afcfeafa42214cfff8fb6007a356c818 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 30 Nov 2023 10:43:34 +0100 Subject: [PATCH 04/27] Use integration-test.sh relative to test dir --- integration-tests/checkstyle.sh | 2 +- integration-tests/metrics-v4.2.19.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index 9ffdf8519c..fc4ee882dd 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -18,4 +18,4 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ build_flags="-Dassertj.version=3.24.2" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" -./integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index eb660875ef..96f1488a12 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -14,4 +14,4 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -./integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "" "" "$do_sync" "$report_directory" +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "" "" "$do_sync" "$report_directory" From be6d3e555b8f576c62f1e461fa7de4c4f2a5b35f Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 30 Nov 2023 12:08:17 +0100 Subject: [PATCH 05/27] Run metrics on java 17 --- .../metrics-v4.2.19-expected-changes.patch | 6660 ----------------- .../metrics-v4.2.19-expected-warnings.txt | 14 +- integration-tests/metrics-v4.2.19-init.patch | 306 +- 3 files changed, 151 insertions(+), 6829 deletions(-) diff --git a/integration-tests/metrics-v4.2.19-expected-changes.patch b/integration-tests/metrics-v4.2.19-expected-changes.patch index 5d6d51f6b8..e69de29bb2 100644 --- a/integration-tests/metrics-v4.2.19-expected-changes.patch +++ b/integration-tests/metrics-v4.2.19-expected-changes.patch @@ -1,6660 +0,0 @@ ---- 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 972ecad639..b9eae8e494 100644 --- a/integration-tests/metrics-v4.2.19-expected-warnings.txt +++ b/integration-tests/metrics-v4.2.19-expected-warnings.txt @@ -1,8 +1,6 @@ -metrics-core/src/main/java/com/codahale/metrics/CsvReporter.java:[382,36] [FormatStringConcatenation] Defer string concatenation to the invoked method -metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[429,18] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) -metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[434,20] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) -metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[447,21] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) -metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java:[189,47] [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,47] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone -metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[29,68] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone -metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[30,68] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +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-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 diff --git a/integration-tests/metrics-v4.2.19-init.patch b/integration-tests/metrics-v4.2.19-init.patch index 8ce1957ec7..56d6e17097 100644 --- a/integration-tests/metrics-v4.2.19-init.patch +++ b/integration-tests/metrics-v4.2.19-init.patch @@ -23,108 +23,35 @@ index 0bd1297..7c69a08 100644 try { return TimeUnit.valueOf(String.valueOf(value).toUpperCase(Locale.US)); diff --git a/pom.xml b/pom.xml -index 6192b52..f1eebbe 100644 +index 6192b52..bcbd571 100644 --- a/pom.xml +++ b/pom.xml -@@ -66,7 +66,7 @@ - 4.13.1 - 1.3 +@@ -68,7 +68,8 @@ 3.11.0 -- 2.19.1 -+ -Xplugin:ErrorProne ${error-prone.flags} -Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\$StringIsNullOrEmpty)).*) + 2.19.1 9+181-r4173-1 - +- ++ -Xplugin:ErrorProne ${error-prone.flags} -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\$StringIsNullOrEmpty)).*) ++ 8 dropwizard_metrics -@@ -137,60 +137,110 @@ - - - -- jdk8 -- -- 1.8 -- -+ error-prone-compile - - -- -- org.apache.maven.plugins -- maven-compiler-plugin -+ -+ org.apache.maven.plugins -+ maven-compiler-plugin -+ ${maven-compiler-plugin.version} -+ -+ -+ error-prone-compile -+ compile -+ -+ compile -+ + dropwizard + https://sonarcloud.io +@@ -166,10 +167,9 @@ + org.apache.maven.plugins + maven-compiler-plugin -- -- -J-Xbootclasspath/p:${settings.localRepository}/com/google/errorprone/javac/${errorprone.javac.version}/javac-${errorprone.javac.version}.jar -- -+ false -+ 1.8 -+ 1.8 -+ -+ -Xpkginfo:always -+ -XDcompilePolicy=simple -+ ${error-prone-support.flags} -+ -+ -+ -+ com.google.errorprone -+ error_prone_core -+ ${error-prone.version} -+ -+ -+ tech.picnic.error-prone-support -+ error-prone-contrib -+ ${error-prone-support.version} -+ -+ -+ tech.picnic.error-prone-support -+ refaster-runner -+ ${error-prone-support.version} -+ -+ - -- -+ -+ -+ - -- -+ - - -- jdk17 -- -- [17,) -- -+ error-prone-test-compile - -- -- -- org.apache.maven.plugins -- maven-compiler-plugin -- - -- -Xlint:all -- -XDcompilePolicy=simple ++ + -Xlint:all + -XDcompilePolicy=simple - -Xplugin:ErrorProne -XepExcludedPaths:.*/target/generated-sources/.* -- -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.model=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED -- -J--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -- -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED -- -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED -- + -J--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED + -J--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED +@@ -181,18 +181,129 @@ + -J--add-opens=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED + -J--add-opens=jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED + - - - com.google.errorprone @@ -132,76 +59,133 @@ index 6192b52..f1eebbe 100644 - ${errorprone.version} - - -- -- -- -+ -+ -+ org.apache.maven.plugins -+ maven-compiler-plugin -+ ${maven-compiler-plugin.version} -+ -+ -+ -+ default-testCompile -+ test-compile -+ -+ testCompile -+ -+ -+ true -+ -+ -+ -+ error-prone-test-compile -+ test-compile -+ -+ testCompile -+ -+ -+ false -+ 1.8 -+ 1.8 -+ -+ -Xpkginfo:always -+ -XDcompilePolicy=simple -+ ${error-prone-support.flags} -+ -+ -+ -+ com.google.errorprone -+ error_prone_core -+ ${error-prone.version} -+ -+ -+ tech.picnic.error-prone-support -+ error-prone-contrib -+ ${error-prone-support.version} -+ -+ -+ tech.picnic.error-prone-support -+ refaster-runner -+ ${error-prone-support.version} -+ -+ -+ -+ -+ -+ -+ + + + ++ ++ error-prone-compile ++ ++ ++ ++ org.apache.maven.plugins ++ maven-compiler-plugin ++ ${maven-compiler-plugin.version} ++ ++ ++ ++ default-compile ++ compile ++ ++ compile ++ ++ ++ true ++ ++ ++ ++ error-prone-compile ++ compile ++ ++ compile ++ ++ ++ true ++ ${java.version} ++ ${java.version} ++ ++ -Xpkginfo:always ++ -XDcompilePolicy=simple ++ ${error-prone-support.flags} ++ ++ ++ ++ com.google.errorprone ++ error_prone_core ++ ${error-prone.version} ++ ++ ++ tech.picnic.error-prone-support ++ error-prone-contrib ++ ${error-prone-support.version} ++ ++ ++ tech.picnic.error-prone-support ++ refaster-runner ++ ${error-prone-support.version} ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ ++ error-prone-test-compile ++ ++ ++ ++ org.apache.maven.plugins ++ maven-compiler-plugin ++ ${maven-compiler-plugin.version} ++ ++ ++ ++ default-testCompile ++ test-compile ++ ++ testCompile ++ ++ ++ true ++ ++ ++ ++ error-prone-test-compile ++ test-compile ++ ++ testCompile ++ ++ ++ true ++ ${java.version} ++ ${java.version} ++ ++ -Xpkginfo:always ++ -XDcompilePolicy=simple ++ ${error-prone-support.flags} ++ ++ ++ ++ com.google.errorprone ++ error_prone_core ++ ${error-prone.version} ++ ++ ++ tech.picnic.error-prone-support ++ error-prone-contrib ++ ${error-prone-support.version} ++ ++ ++ tech.picnic.error-prone-support ++ refaster-runner ++ ${error-prone-support.version} ++ ++ ++ ++ ++ ++ ++ ++ ++ -@@ -315,23 +365,13 @@ - org.apache.maven.plugins - maven-compiler-plugin - -- 1.8 -- 1.8 -- true -+ false - true - true + release-sign-artifacts + +@@ -323,15 +434,7 @@ -Xlint:all -XDcompilePolicy=simple From 36f8b01add477e4ccd6adbc9539a1210b663bccb Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 13 Dec 2023 10:44:35 +0100 Subject: [PATCH 06/27] 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 e69de29bb2..5d6d51f6b8 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 b9eae8e494..e7e82b304a 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 56d6e17097..613465ecb1 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 96f1488a12..afed0bbe42 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" From 952451c87745a6d73687129c5adf6a895dd52ece Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 13 Dec 2023 11:33:19 +0100 Subject: [PATCH 07/27] clarify reason for check exclusion --- integration-tests/metrics-v4.2.19.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index afed0bbe42..64f75f6f6b 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -14,6 +14,8 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" +# XXX: We exclude the CollectorMutability and the Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty refaster rules +# as they introduce changes that expect guava to be on the classpath. 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" From 2ebd53050ce82ea780989929b88dc271df47ae9c Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 10 Jan 2024 09:45:48 +0100 Subject: [PATCH 08/27] add `additional_src_directories` flag --- integration-tests/checkstyle.sh | 3 ++- integration-tests/integration-test.sh | 17 +++++++++-------- integration-tests/metrics-v4.2.19.sh | 2 +- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index fc4ee882dd..a06ebce4c6 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -17,5 +17,6 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ # XXX: Configure Renovate to manage the AssertJ version declared here. build_flags="-Dassertj.version=3.24.2" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" +additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "$validation_mvn_flags" "$do_sync" "$report_directory" diff --git a/integration-tests/integration-test.sh b/integration-tests/integration-test.sh index 952d97273a..d9e73aa497 100755 --- a/integration-tests/integration-test.sh +++ b/integration-tests/integration-test.sh @@ -8,8 +8,8 @@ integration_test_root="$(cd "$(dirname -- "${0}")" && pwd)" error_prone_support_root="${integration_test_root}/.." repos_root="${integration_test_root}/.repos" -if [ "${#}" -ne 10 ]; then - >&2 echo "Usage $(basename "${0}") [TestName] [Project] [Repository] [Revision] [BuildFlags] [PatchFlags] [ValidationEpFlags] [ValidationMvnFlags] [DoSync] [ReportDirectory]" +if [ "${#}" -ne 11 ]; then + >&2 echo "Usage $(basename "${0}") [TestName] [Project] [Repository] [Revision] [BuildFlags] [AdditionalSourceDirectories] [PatchFlags] [ValidationEpFlags] [ValidationMvnFlags] [DoSync] [ReportDirectory]" exit 1 fi @@ -18,11 +18,12 @@ project="${2}" repository="${3}" revision="${4}" build_flags="${5}" -patch_flags="${6}" -validation_ep_flags="${7}" -validation_mvn_flags="${8}" -do_sync="${9}" -report_directory="${10}" +additional_src_directories="${6}" +patch_flags="${7}" +validation_ep_flags="${8}" +validation_mvn_flags="${9}" +do_sync="${10}" +report_directory="${11}" if [ -n "${report_directory}" ]; then mkdir -p "${report_directory}" @@ -55,7 +56,7 @@ shared_build_flags=" -Derror-prone-support.version=$( mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout ) - -DadditionalSourceDirectories=\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java + -DadditionalSourceDirectories=${additional_src_directories} ${build_flags} " diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index 64f75f6f6b..4b121c9938 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -18,4 +18,4 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ # as they introduce changes that expect guava to be on the classpath. 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" +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "${patch_flags}" "" "" "$do_sync" "$report_directory" From b6bed8698a78ecd3df5c6c1a8f16660e106745d3 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 10 Jan 2024 10:06:46 +0100 Subject: [PATCH 09/27] fix checkstyle integration test script --- integration-tests/checkstyle.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index a06ebce4c6..f489b75dd5 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -19,4 +19,4 @@ build_flags="-Dassertj.version=3.24.2" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" From 3b2a0b4563a8f601476c741327ecb53a6f22973e Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 10 Jan 2024 10:10:40 +0100 Subject: [PATCH 10/27] add matrix to integration test workflow --- .github/workflows/run-integration-tests.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 6776c89b61..c38b444d89 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -13,6 +13,9 @@ permissions: contents: read jobs: run-integration-tests: + strategy: + matrix: + integration-test: ["checkstyle.sh", "metrics-v4.2.19.sh"] name: On-demand integration test if: | github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') @@ -40,7 +43,7 @@ jobs: - name: Install project to local Maven repository run: mvn -T1C install -DskipTests -Dverification.skip - name: Run integration test - run: xvfb-run ./integration-tests/checkstyle.sh "${{ runner.temp }}/artifacts" + run: xvfb-run ./integration-tests/${{ matrix.integration-test }} "${{ runner.temp }}/artifacts" - name: Upload artifacts on failure if: ${{ failure() }} uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 From 713853dfe1b6a011a773af86d9debddbd902dfee Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 10 Jan 2024 11:03:13 +0100 Subject: [PATCH 11/27] suggestions --- .github/workflows/run-integration-tests.yml | 6 +++--- integration-tests/checkstyle.sh | 2 +- integration-tests/metrics-v4.2.19.sh | 4 ++-- .../{integration-test.sh => run-integration-test.sh} | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) rename integration-tests/{integration-test.sh => run-integration-test.sh} (99%) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index c38b444d89..81bdd89946 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -15,7 +15,7 @@ jobs: run-integration-tests: strategy: matrix: - integration-test: ["checkstyle.sh", "metrics-v4.2.19.sh"] + integration-test: ["checkstyle", "metrics-v4.2.19"] name: On-demand integration test if: | github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') @@ -43,12 +43,12 @@ jobs: - name: Install project to local Maven repository run: mvn -T1C install -DskipTests -Dverification.skip - name: Run integration test - run: xvfb-run ./integration-tests/${{ matrix.integration-test }} "${{ runner.temp }}/artifacts" + run: xvfb-run "./integration-tests/${{ matrix.integration-test }}.sh" "${{ runner.temp }}/artifacts" - name: Upload artifacts on failure if: ${{ failure() }} uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1 with: - name: integration-test-checkstyle + name: "integration-test-${{ matrix.integration-test }}" path: "${{ runner.temp }}/artifacts" - name: Remove installed project artifacts run: mvn build-helper:remove-project-artifact diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index f489b75dd5..0d41554390 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -19,4 +19,4 @@ build_flags="-Dassertj.version=3.24.2" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -"$(dirname ${0})"/integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index 4b121c9938..1918e469db 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -14,8 +14,8 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -# XXX: We exclude the CollectorMutability and the Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty refaster rules +# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` refaster rules # as they introduce changes that expect guava to be on the classpath. 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" +"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "${patch_flags}" "" "" "$do_sync" "$report_directory" diff --git a/integration-tests/integration-test.sh b/integration-tests/run-integration-test.sh similarity index 99% rename from integration-tests/integration-test.sh rename to integration-tests/run-integration-test.sh index d9e73aa497..f02be0917c 100755 --- a/integration-tests/integration-test.sh +++ b/integration-tests/run-integration-test.sh @@ -1,4 +1,5 @@ #!/usr/bin/env bash + # This script is not meant to be invoked manually, instead it should be invoked # through one of the integration test scripts such as the metrics or checkstyle one. From 5825498becfe7f24ac97cef8c054c9036eb916fb Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 11 Jan 2024 11:16:40 +0100 Subject: [PATCH 12/27] apply suggestions in init patch --- integration-tests/metrics-v4.2.19-init.patch | 6 +++--- integration-tests/metrics-v4.2.19.sh | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/integration-tests/metrics-v4.2.19-init.patch b/integration-tests/metrics-v4.2.19-init.patch index 613465ecb1..d3fa6c456d 100644 --- a/integration-tests/metrics-v4.2.19-init.patch +++ b/integration-tests/metrics-v4.2.19-init.patch @@ -23,7 +23,7 @@ index 0bd1297..7c69a08 100644 try { return TimeUnit.valueOf(String.valueOf(value).toUpperCase(Locale.US)); diff --git a/pom.xml b/pom.xml -index 6192b52..bcbd571 100644 +index 6192b52..8c312b6 100644 --- a/pom.xml +++ b/pom.xml @@ -68,7 +68,8 @@ @@ -73,7 +73,7 @@ index 6192b52..bcbd571 100644 + maven-compiler-plugin + ${maven-compiler-plugin.version} + -+ ++ + + default-compile + compile @@ -132,7 +132,7 @@ index 6192b52..bcbd571 100644 + maven-compiler-plugin + ${maven-compiler-plugin.version} + -+ ++ + + default-testCompile + test-compile diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics-v4.2.19.sh index 1918e469db..8daca93d3e 100755 --- a/integration-tests/metrics-v4.2.19.sh +++ b/integration-tests/metrics-v4.2.19.sh @@ -15,7 +15,7 @@ do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" # XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` refaster rules -# as they introduce changes that expect guava to be on the classpath. +# as they introduce changes that expect Guava to be on the classpath. patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" "$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "${patch_flags}" "" "" "$do_sync" "$report_directory" From 97989c62940d59433d5c5f8489045a4948811415 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 11 Jan 2024 11:42:36 +0100 Subject: [PATCH 13/27] trigger integration-test action --- .github/workflows/run-integration-tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 81bdd89946..7ac40e8140 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -7,6 +7,8 @@ # https://docs.github.com/en/actions/learn-github-actions/expressions#example-returning-a-json-object name: "Integration tests" on: + pull_request: + branches: [ master ] issue_comment: types: [ created ] permissions: From 4dcfb10dd97a9fe527efaebb9fd9bb0a0d14b378 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Thu, 11 Jan 2024 11:43:39 +0100 Subject: [PATCH 14/27] temporarily remove condition --- .github/workflows/run-integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 7ac40e8140..89e5118d55 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -19,8 +19,8 @@ jobs: matrix: integration-test: ["checkstyle", "metrics-v4.2.19"] name: On-demand integration test - if: | - github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') + # if: | + # github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') runs-on: ubuntu-22.04 steps: - name: Install Harden-Runner From 79931df7802167b2e80b25b3bc39c7790ada5545 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 24 Jan 2024 10:20:57 +0100 Subject: [PATCH 15/27] disable new checks as they cause errors --- integration-tests/checkstyle.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index 0d41554390..124920eb05 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -16,7 +16,10 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ # XXX: Configure Renovate to manage the AssertJ version declared here. build_flags="-Dassertj.version=3.24.2" -validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +# XXX: re-enable these once the required fixes have been added to the init patch +patch_flags="-Xep:CanonicalClassNameUsage:OFF -Xep:ErrorProneRuntimeClasspath:OFF -Xep:UnqualifiedSuggestedFixImport:OFF" +validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" + +"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" From 4dafc7e6eef0a5ab0cffa7ec2bb3c65cc12757e1 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 13 Feb 2024 09:25:52 +0100 Subject: [PATCH 16/27] Post-rebase fix --- integration-tests/checkstyle.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index 124920eb05..0aa61154b4 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -18,8 +18,8 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ build_flags="-Dassertj.version=3.24.2" additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -# XXX: re-enable these once the required fixes have been added to the init patch +# XXX: Re-enable these once the required fixes have been added to the init patch. patch_flags="-Xep:CanonicalClassNameUsage:OFF -Xep:ErrorProneRuntimeClasspath:OFF -Xep:UnqualifiedSuggestedFixImport:OFF" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" -"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "" "" "$validation_mvn_flags" "$do_sync" "$report_directory" +"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "${patch_flags}" "" "$validation_mvn_flags" "${do_sync}" "$report_directory" From dddb602869872705b27488c5dc6e224f9a322194 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 13 Feb 2024 09:29:44 +0100 Subject: [PATCH 17/27] Rename metrics files to drop the version --- .github/workflows/run-integration-tests.yml | 2 +- ...19-expected-changes.patch => metrics-expected-changes.patch} | 0 ...2.19-expected-warnings.txt => metrics-expected-warnings.txt} | 0 .../{metrics-v4.2.19-init.patch => metrics-init.patch} | 0 integration-tests/{metrics-v4.2.19.sh => metrics.sh} | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename integration-tests/{metrics-v4.2.19-expected-changes.patch => metrics-expected-changes.patch} (100%) rename integration-tests/{metrics-v4.2.19-expected-warnings.txt => metrics-expected-warnings.txt} (100%) rename integration-tests/{metrics-v4.2.19-init.patch => metrics-init.patch} (100%) rename integration-tests/{metrics-v4.2.19.sh => metrics.sh} (100%) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 89e5118d55..56d22a8142 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -17,7 +17,7 @@ jobs: run-integration-tests: strategy: matrix: - integration-test: ["checkstyle", "metrics-v4.2.19"] + integration-test: ["checkstyle", "metrics"] name: On-demand integration test # if: | # github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') diff --git a/integration-tests/metrics-v4.2.19-expected-changes.patch b/integration-tests/metrics-expected-changes.patch similarity index 100% rename from integration-tests/metrics-v4.2.19-expected-changes.patch rename to integration-tests/metrics-expected-changes.patch diff --git a/integration-tests/metrics-v4.2.19-expected-warnings.txt b/integration-tests/metrics-expected-warnings.txt similarity index 100% rename from integration-tests/metrics-v4.2.19-expected-warnings.txt rename to integration-tests/metrics-expected-warnings.txt diff --git a/integration-tests/metrics-v4.2.19-init.patch b/integration-tests/metrics-init.patch similarity index 100% rename from integration-tests/metrics-v4.2.19-init.patch rename to integration-tests/metrics-init.patch diff --git a/integration-tests/metrics-v4.2.19.sh b/integration-tests/metrics.sh similarity index 100% rename from integration-tests/metrics-v4.2.19.sh rename to integration-tests/metrics.sh From 041778308b55f8dc3198e5cf1c1748bb26ede842 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 13 Feb 2024 09:46:32 +0100 Subject: [PATCH 18/27] Style improvements --- integration-tests/checkstyle.sh | 15 ++++++++++++--- integration-tests/metrics.sh | 15 +++++++++++++-- 2 files changed, 25 insertions(+), 5 deletions(-) diff --git a/integration-tests/checkstyle.sh b/integration-tests/checkstyle.sh index 0aa61154b4..4c1ca56e7e 100755 --- a/integration-tests/checkstyle.sh +++ b/integration-tests/checkstyle.sh @@ -18,8 +18,17 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ build_flags="-Dassertj.version=3.24.2" additional_src_directories="\${project.basedir}\${file.separator}src\${file.separator}it\${file.separator}java,\${project.basedir}\${file.separator}src\${file.separator}xdocs-examples\${file.separator}java" -# XXX: Re-enable these once the required fixes have been added to the init patch. -patch_flags="-Xep:CanonicalClassNameUsage:OFF -Xep:ErrorProneRuntimeClasspath:OFF -Xep:UnqualifiedSuggestedFixImport:OFF" validation_mvn_flags="-Dtest=!MetadataGeneratorUtilTest#metadataFilesGenerationAllFiles,!XdocsJavaDocsTest#allCheckSectionJavaDocs" -"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "$build_flags" "$additional_src_directories" "${patch_flags}" "" "$validation_mvn_flags" "${do_sync}" "$report_directory" +"$(dirname "${0}")"/run-integration-test.sh \ + "${test_name}" \ + "${project}" \ + "${repository}" \ + "${revision}" \ + "${build_flags}" \ + "${additional_src_directories}" \ + "" \ + "" \ + "${validation_mvn_flags}" \ + "${do_sync}" \ + "${report_directory}" diff --git a/integration-tests/metrics.sh b/integration-tests/metrics.sh index 8daca93d3e..58284e8bcf 100755 --- a/integration-tests/metrics.sh +++ b/integration-tests/metrics.sh @@ -14,8 +14,19 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` refaster rules +# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Refaster rules # as they introduce changes that expect Guava to be on the classpath. patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" -"$(dirname ${0})"/run-integration-test.sh "$test_name" "$project" "$repository" "$revision" "" "" "${patch_flags}" "" "" "$do_sync" "$report_directory" +"$(dirname "${0}")"/run-integration-test.sh \ + "${test_name}" \ + "${project}" \ + "${repository}" \ + "${revision}" \ + "" \ + "" \ + "${patch_flags}" \ + "" \ + "" \ + "${do_sync}" \ + "${report_directory}" From 75eb8d27e1c6200a9aedd2ebd00db4f8de5203ac Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Tue, 13 Feb 2024 10:54:23 +0100 Subject: [PATCH 19/27] Typo --- integration-tests/metrics.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/metrics.sh b/integration-tests/metrics.sh index 58284e8bcf..7da98d03e8 100755 --- a/integration-tests/metrics.sh +++ b/integration-tests/metrics.sh @@ -14,7 +14,7 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Refaster rules +# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Rsefaster rules # as they introduce changes that expect Guava to be on the classpath. patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" From b9836c601782dc6226f4a292624dbeb4422f4f4a Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Fri, 1 Mar 2024 11:33:54 +0100 Subject: [PATCH 20/27] sync metrics --- .../metrics-expected-changes.patch | 6660 ----------------- .../metrics-expected-warnings.txt | 334 +- 2 files changed, 245 insertions(+), 6749 deletions(-) diff --git a/integration-tests/metrics-expected-changes.patch b/integration-tests/metrics-expected-changes.patch index 5d6d51f6b8..e69de29bb2 100644 --- a/integration-tests/metrics-expected-changes.patch +++ b/integration-tests/metrics-expected-changes.patch @@ -1,6660 +0,0 @@ ---- 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-expected-warnings.txt b/integration-tests/metrics-expected-warnings.txt index e7e82b304a..5ed79ddef6 100644 --- a/integration-tests/metrics-expected-warnings.txt +++ b/integration-tests/metrics-expected-warnings.txt @@ -1,68 +1,195 @@ +metrics-annotation/src/main/java/com/codahale/metrics/annotation/CachedGauge.java:[32,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/CachedGauge.java:[37,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/CachedGauge.java:[43,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/CachedGauge.java:[48,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Counted.java:[39,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Counted.java:[44,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Counted.java:[51,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ExceptionMetered.java:[55,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ExceptionMetered.java:[61,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ExceptionMetered.java:[68,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Gauge.java:[27,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Gauge.java:[32,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Metered.java:[36,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Metered.java:[41,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Metric.java:[39,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Metric.java:[44,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ResponseMetered.java:[37,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ResponseMetered.java:[42,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/ResponseMetered.java:[49,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Timed.java:[36,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-annotation/src/main/java/com/codahale/metrics/annotation/Timed.java:[41,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-benchmarks/src/main/java/com/codahale/metrics/benchmarks/SlidingTimeWindowReservoirsBenchmark.java:[21,3] [MissingSummary] A summary line is required on public/protected Javadocs. +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[9,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[9,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 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-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java:[193,13] [InconsistentCapitalization] Found the field 'hostName' with the same name as the parameter 'hostname' but with different capitalization. +metrics-collectd/src/main/java/com/codahale/metrics/collectd/CollectdReporter.java:[305,14] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[160,12] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[165,11] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[171,17] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[196,8] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[199,21] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[202,11] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/PacketWriter.java:[248,36] [cast] redundant cast to ByteBuffer +metrics-collectd/src/main/java/com/codahale/metrics/collectd/Sanitize.java:[7,3] [MissingSummary] A summary fragment is required; consider using the value of the @see block as a summary fragment instead. +metrics-collectd/src/test/java/com/codahale/metrics/collectd/Receiver.java:[51,16] [CatchAndPrintStackTrace] Logging or rethrowing exceptions should usually be preferred to catching and calling printStackTrace +metrics-collectd/src/test/java/com/codahale/metrics/collectd/SanitizeTest.java:[26,41] [UnnecessaryParentheses] These grouping parentheses are unnecessary; it is unlikely the code will be misinterpreted without them +metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java:[239,46] [JavaUtilDate] Date has a bad API that leads to bugs; prefer java.time.Instant or LocalDate. +metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java:[406,43] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/main/java/com/codahale/metrics/ConsoleReporter.java:[413,43] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/main/java/com/codahale/metrics/CsvReporter.java:[310,39] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/main/java/com/codahale/metrics/CsvReporter.java:[312,39] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional 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/main/java/com/codahale/metrics/MetricRegistry.java:[329,29] [TypeParameterUnusedInFormals] Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution. +metrics-core/src/main/java/com/codahale/metrics/MovingAverages.java:[26,5] [EmptyBlockTag] A block tag (@param, @return, @throws, @deprecated) has an empty description. Block tags without descriptions don't add much value for future readers of the code; consider removing the tag entirely or adding a description. +metrics-core/src/main/java/com/codahale/metrics/NoopMetricRegistry.java:[102,29] [TypeParameterUnusedInFormals] Declaring a type parameter that is only used in the return type is a misuse of generics: operations on the type parameter are unchecked, it hides unsafe casts at invocations of the method, and it interacts badly with method overload resolution. +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-core/src/main/java/com/codahale/metrics/ScheduledReporter.java:[47,21] [ThreadPriorityCheck] Relying on the thread scheduler is discouraged. +metrics-core/src/main/java/com/codahale/metrics/Slf4jReporter.java:[183,29] [InvalidInlineTag] Curly braces should be used for inline Javadoc tags: {@link ...} +metrics-core/src/main/java/com/codahale/metrics/WeightedSnapshot.java:[76,26] [UnnecessaryParentheses] These grouping parentheses are unnecessary; it is unlikely the code will be misinterpreted without them +metrics-core/src/test/java/com/codahale/metrics/ClockTest.java:[14,75] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/test/java/com/codahale/metrics/ClockTest.java:[16,66] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/test/java/com/codahale/metrics/MeterApproximationTest.java:[37,19] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/test/java/com/codahale/metrics/MeterApproximationTest.java:[48,19] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/test/java/com/codahale/metrics/MeterApproximationTest.java:[59,19] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-core/src/test/java/com/codahale/metrics/ScheduledReporterTest.java:[230,41] [DirectInvocationOnMock] Methods should not be directly invoked on the mock `mockExecutor`. Should this be part of a verify(..) call? +metrics-core/src/test/java/com/codahale/metrics/ScheduledReporterTest.java:[231,39] [DirectInvocationOnMock] Methods should not be directly invoked on the mock `mockExecutor`. Should this be part of a verify(..) call? 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-core/src/test/java/com/codahale/metrics/SlidingTimeWindowArrayReservoirTest.java:[88,15] [UnnecessaryAsync] Variables which are initialized and do not escape the current scope do not need to worry about concurrency. Using the non-concurrent type will reduce overhead and verbosity. +metrics-core/src/test/java/com/codahale/metrics/UniformSnapshotTest.java:[128,30] [DefaultCharset] Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn't match expectations. +metrics-core/src/test/java/com/codahale/metrics/WeightedSnapshotTest.java:[136,30] [DefaultCharset] Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn't match expectations. +metrics-graphite/src/main/java/com/codahale/metrics/graphite/Graphite.java:[129,57] [OperatorPrecedence] Use grouping parenthesis to make the operator precedence explicit +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[253,46] [UnnecessaryLambda] Returning a lambda from a helper method or saving it in a constant is unnecessary; prefer to implement the functional interface method directly and use a method reference instead. +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[431,17] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[436,19] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[449,20] [Slf4jLogStatement] Log statement contains 0 placeholders, but specifies 1 matching argument(s) +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[456,60] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-graphite/src/main/java/com/codahale/metrics/graphite/GraphiteReporter.java:[458,60] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteTest.java:[140,65] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteTest.java:[30,66] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteTest.java:[59,26] [DirectInvocationOnMock] Methods should not be directly invoked on the mock `socket`. Should this be part of a verify(..) call? +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java:[25,73] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java:[35,49] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java:[40,60] [StringCharset] StringCharset +metrics-graphite/src/test/java/com/codahale/metrics/graphite/GraphiteUDPTest.java:[41,34] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/PickledGraphiteTest.java:[36,66] [AddressSelection] Prefer InetAddress.getAllByName to APIs that convert a hostname to a single IP address +metrics-graphite/src/test/java/com/codahale/metrics/graphite/PickledGraphiteTest.java:[68,26] [DirectInvocationOnMock] Methods should not be directly invoked on the mock `socket`. Should this be part of a verify(..) call? +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java:[203,19] [EqualsGetClass] Prefer instanceof to getClass when implementing Object#equals. +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java:[222,32] [UnnecessaryParentheses] These grouping parentheses are unnecessary; it is unlikely the code will be misinterpreted without them +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java:[318,25] [AnnotateFormatMethod] This method uses a pair of parameters as a format string and its arguments, but the enclosing method wasn't annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings. +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java:[55,25] [AnnotateFormatMethod] This method uses a pair of parameters as a format string and its arguments, but the enclosing method wasn't annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings. +metrics-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheck.java:[79,25] [AnnotateFormatMethod] This method uses a pair of parameters as a format string and its arguments, but the enclosing method wasn't annotated @FormatMethod. Doing so gives compile-time rather than run-time protection against malformed format strings. +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-healthchecks/src/main/java/com/codahale/metrics/health/HealthCheckRegistry.java:[278,64] [ThreadPriorityCheck] Relying on the thread scheduler is discouraged. +metrics-healthchecks/src/test/java/com/codahale/metrics/health/HealthCheckTest.java:[189,46] [JavaTimeDefaultTimeZone] ZonedDateTime.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method. 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] [JavaTimeDefaultTimeZone] ZonedDateTime.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method. 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-httpasyncclient/src/test/java/com/codahale/metrics/httpasyncclient/HttpClientTestBase.java:[24,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-httpclient/src/main/java/com/codahale/metrics/httpclient/HttpClientMetricNameStrategies.java:[43,59] [StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.) 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 @@ -88,44 +215,73 @@ metrics-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedH 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-httpclient5/src/test/java/com/codahale/metrics/httpclient5/InstrumentedHttpClientsTest.java:[68,12] [deprecation] execute(ClassicHttpRequest) in HttpClient has been deprecated +metrics-jakarta-servlet/src/main/java/io/dropwizard/metrics/servlet/InstrumentedFilterContextListener.java:[14,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/AdminServlet.java:[32,30] [InlineFormatString] Prefer to create format strings inline, instead of extracting them to a single-use constant +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/HealthCheckServlet.java:[26,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/HealthCheckServlet.java:[31,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/HealthCheckServlet.java:[40,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java:[32,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java:[37,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java:[46,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/main/java/io/dropwizard/metrics/servlets/MetricsServlet.java:[55,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[104,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[145,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[219,25] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/HealthCheckServletTest.java:[30,67] [JavaTimeDefaultTimeZone] ZonedDateTime.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method. +metrics-jakarta-servlets/src/test/java/io/dropwizard/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 +metrics-jakarta-servlets/src/test/java/io/dropwizard/metrics/servlets/MetricsServletTest.java:[130,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-jcache/src/test/java/JCacheGaugeSetTest.java:[1] [DefaultPackage] Java classes shouldn't use default package 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-jersey2/src/main/java/com/codahale/metrics/jersey2/InstrumentedResourceMethodApplicationListener.java:[582,19] [EqualsGetClass] Prefer instanceof to getClass when implementing Object#equals. +metrics-jersey3/src/main/java/com/codahale/metrics/jersey3/InstrumentedResourceMethodApplicationListener.java:[582,19] [EqualsGetClass] Prefer instanceof to getClass when implementing Object#equals. +metrics-jersey31/src/main/java/io/dropwizard/metrics/jersey31/InstrumentedResourceMethodApplicationListener.java:[582,19] [EqualsGetClass] Prefer instanceof to getClass when implementing Object#equals. +metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHandlerTest.java:[134,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jetty10/src/test/java/io/dropwizard/metrics/jetty10/InstrumentedHandlerTest.java:[138,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHandlerTest.java:[136,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jetty11/src/test/java/io/dropwizard/metrics/jetty11/InstrumentedHandlerTest.java:[140,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHandlerTest.java:[136,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jetty9/src/test/java/com/codahale/metrics/jetty9/InstrumentedHandlerTest.java:[140,44] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jmx/src/main/java/com/codahale/metrics/jmx/DefaultObjectNameFactory.java:[18,45] [JdkObsolete] Hashtable performs synchronization this is usually unnecessary; prefer LinkedHashMap. +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[131,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[20,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[28,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[43,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[62,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-json/src/test/java/com/codahale/metrics/json/HealthCheckModuleTest.java:[90,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-jvm/src/main/java/com/codahale/metrics/jvm/FileDescriptorRatioGauge.java:[42,55] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/FileDescriptorRatioGauge.java:[42,91] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[107,31] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[107,56] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[77,41] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[77,57] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[93,29] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/MemoryUsageGaugeSet.java:[93,54] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/main/java/com/codahale/metrics/jvm/ThreadStatesGaugeSet.java:[47,43] [StringCaseLocaleUsage] Specify a `Locale` when calling `String#to{Lower,Upper}Case`. (Note: there are multiple suggested fixes; the third may be most appropriate if you're dealing with ASCII Strings.) +metrics-jvm/src/test/java/com/codahale/metrics/jvm/CpuTimeClockTest.java:[15,75] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional +metrics-jvm/src/test/java/com/codahale/metrics/jvm/CpuTimeClockTest.java:[19,71] [LongDoubleConversion] Conversion from long to double may lose precision; use an explicit cast to double if this was intentional 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:[67,36] [URLEqualsHashCode] Avoid hash-based containers of java.net.URL--the containers rely on equals() and hashCode(), which cause java.net.URL to make blocking internet connections. 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-jvm/src/test/java/com/codahale/metrics/jvm/ThreadDumpTest.java:[42,30] [DefaultCharset] Implicit use of the platform default charset, which can result in differing behaviour between JVM executions or incorrect behavior if the encoding of the data source doesn't match expectations. 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 +metrics-servlet/src/main/java/com/codahale/metrics/servlet/InstrumentedFilterContextListener.java:[14,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/AdminServlet.java:[32,30] [InlineFormatString] Prefer to create format strings inline, instead of extracting them to a single-use constant +metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java:[26,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java:[31,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java:[40,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/HealthCheckServlet.java:[48,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java:[32,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java:[37,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java:[46,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/main/java/com/codahale/metrics/servlets/MetricsServlet.java:[55,7] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[112,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[170,25] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[31,67] [JavaTimeDefaultTimeZone] ZonedDateTime.now() is not allowed because it silently uses the system default time-zone. You must pass an explicit time-zone (e.g., ZoneId.of("America/Los_Angeles")) to this method. +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[31,67] [TimeZoneUsage] Derive the current time from an existing `Clock` Spring bean, and don't rely on a `Clock`'s time zone +metrics-servlets/src/test/java/com/codahale/metrics/servlets/HealthCheckServletTest.java:[96,18] [FormatStringConcatenation] Defer string concatenation to the invoked method +metrics-servlets/src/test/java/com/codahale/metrics/servlets/MetricsServletTest.java:[130,18] [FormatStringConcatenation] Defer string concatenation to the invoked method From 78cac86a2844e4ad3a7600a1d796cf9e49263aaf Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 6 Mar 2024 11:02:56 +0100 Subject: [PATCH 21/27] Only run on GH comment --- .github/workflows/run-integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 56d22a8142..a771f010b9 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -19,8 +19,8 @@ jobs: matrix: integration-test: ["checkstyle", "metrics"] name: On-demand integration test - # if: | - # github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') + if: | + github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') runs-on: ubuntu-22.04 steps: - name: Install Harden-Runner From 1ff1d5705bd35090733ac145c57c44c477c74007 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 6 Mar 2024 13:42:22 +0100 Subject: [PATCH 22/27] Try to trigger metrics --- .github/workflows/run-integration-tests.yml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index a771f010b9..029da0d19a 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -15,13 +15,14 @@ permissions: contents: read jobs: run-integration-tests: + runs-on: ubuntu-22.04 + if: github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') + # XXX: Configure permissions. strategy: matrix: - integration-test: ["checkstyle", "metrics"] + integration-test: [ "metrics", "checkstyle" ] name: On-demand integration test - if: | - github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') - runs-on: ubuntu-22.04 + steps: - name: Install Harden-Runner uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # v2.7.0 From 51ec7bcbd4699c48cb074ed4ef0a63738bdf3975 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 6 Mar 2024 13:57:27 +0100 Subject: [PATCH 23/27] Try to run both variants --- .github/workflows/run-integration-tests.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-integration-tests.yml b/.github/workflows/run-integration-tests.yml index 029da0d19a..d9f71aabdd 100644 --- a/.github/workflows/run-integration-tests.yml +++ b/.github/workflows/run-integration-tests.yml @@ -16,7 +16,7 @@ permissions: jobs: run-integration-tests: runs-on: ubuntu-22.04 - if: github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') +# if: github.event.issue.pull_request && contains(github.event.comment.body, '/integration-test') # XXX: Configure permissions. strategy: matrix: @@ -39,7 +39,7 @@ jobs: - name: Check out code and set up JDK and Maven uses: s4u/setup-maven-action@6d44c18d67d9e1549907b8815efa5e4dada1801b # v1.12.0 with: - checkout-ref: "refs/pull/${{ github.event.issue.number }}/head" + checkout-ref: "refs/pull/894/head" java-version: 17.0.10 java-distribution: temurin maven-version: 3.9.6 From ee0018114de1d74caa46026c1fbda75c420be103 Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Wed, 6 Mar 2024 15:37:09 +0100 Subject: [PATCH 24/27] Dont analyse generated files --- integration-tests/metrics-init.patch | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/integration-tests/metrics-init.patch b/integration-tests/metrics-init.patch index d3fa6c456d..78052905c5 100644 --- a/integration-tests/metrics-init.patch +++ b/integration-tests/metrics-init.patch @@ -31,7 +31,7 @@ index 6192b52..8c312b6 100644 2.19.1 9+181-r4173-1 - -+ -Xplugin:ErrorProne ${error-prone.flags} ++ -Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode ${error-prone.flags} + 8 dropwizard_metrics dropwizard From 8b4cba4ac9d50bac314d05aaabb74ec5e66f1c63 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 20 Mar 2024 10:47:07 +0100 Subject: [PATCH 25/27] Fix metrics init patch --- integration-tests/metrics-init.patch | 2 +- integration-tests/metrics.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/integration-tests/metrics-init.patch b/integration-tests/metrics-init.patch index 78052905c5..9a00955441 100644 --- a/integration-tests/metrics-init.patch +++ b/integration-tests/metrics-init.patch @@ -31,7 +31,7 @@ index 6192b52..8c312b6 100644 2.19.1 9+181-r4173-1 - -+ -Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode ${error-prone.flags} ++ -Xplugin:ErrorProne -XepDisableWarningsInGeneratedCode ${error-prone.configuration-args} + 8 dropwizard_metrics dropwizard diff --git a/integration-tests/metrics.sh b/integration-tests/metrics.sh index 7da98d03e8..58284e8bcf 100755 --- a/integration-tests/metrics.sh +++ b/integration-tests/metrics.sh @@ -14,7 +14,7 @@ fi do_sync="$([ "${#}" = 0 ] || [ "${1:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ "${#}" = 1 ] || echo "${2}"))" -# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Rsefaster rules +# XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Refaster rules # as they introduce changes that expect Guava to be on the classpath. patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" From cc69b87b8976ab718bb1cde6eee408807393c807 Mon Sep 17 00:00:00 2001 From: Gijs de Jong Date: Wed, 20 Mar 2024 12:01:08 +0100 Subject: [PATCH 26/27] Try different refaster name patterns --- .../metrics-expected-warnings.txt | 196 +++++++++--------- integration-tests/metrics.sh | 2 +- 2 files changed, 99 insertions(+), 99 deletions(-) diff --git a/integration-tests/metrics-expected-warnings.txt b/integration-tests/metrics-expected-warnings.txt index 5ed79ddef6..93deb90769 100644 --- a/integration-tests/metrics-expected-warnings.txt +++ b/integration-tests/metrics-expected-warnings.txt @@ -20,104 +20,104 @@ metrics-annotation/src/main/java/com/codahale/metrics/annotation/ResponseMetered metrics-annotation/src/main/java/com/codahale/metrics/annotation/Timed.java:[36,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. metrics-annotation/src/main/java/com/codahale/metrics/annotation/Timed.java:[41,5] [MissingSummary] A summary fragment is required; consider using the value of the @return block as a summary fragment instead. metrics-benchmarks/src/main/java/com/codahale/metrics/benchmarks/SlidingTimeWindowReservoirsBenchmark.java:[21,3] [MissingSummary] A summary line is required on public/protected Javadocs. -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[3,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[4,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[5,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[6,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[7,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[8,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[9,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 -metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/SlidingTimeWindowReservoirsBenchmark_jmhType_B3.java:[9,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: SlidingTimeWindowReservoirsBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[3,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[4,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[5,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[6,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[7,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,21] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,27] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,33] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,39] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,45] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,51] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,57] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,63] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,69] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,75] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,81] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,87] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,93] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,99] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[8,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[9,15] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 +metrics-benchmarks/target/generated-sources/annotations/com/codahale/metrics/benchmarks/jmh_generated/ReservoirBenchmark_jmhType_B3.java:[9,9] [HidingField] Hiding fields of superclasses may cause confusion and errors. This field is hiding a field of the same name in superclass: ReservoirBenchmark_jmhType_B1 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:[193,13] [InconsistentCapitalization] Found the field 'hostName' with the same name as the parameter 'hostname' but with different capitalization. diff --git a/integration-tests/metrics.sh b/integration-tests/metrics.sh index 58284e8bcf..38e14fb07c 100755 --- a/integration-tests/metrics.sh +++ b/integration-tests/metrics.sh @@ -16,7 +16,7 @@ report_directory="$([ "${#}" = 0 ] || ([ -z "${do_sync}" ] && echo "${1}") || ([ # XXX: We exclude the `CollectorMutability` and the `Immutable*|Preconditions*|StringRules.StringIsNullOrEmpty` Refaster rules # as they introduce changes that expect Guava to be on the classpath. -patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^((?!(Immutable|Preconditions|StringRules\.StringIsNullOrEmpty)).*)" +patch_flags="-Xep:CollectorMutability:OFF -XepOpt:Refaster:NamePattern=^(?!ImmutableSetRules\$ImmutableSetOf).*" "$(dirname "${0}")"/run-integration-test.sh \ "${test_name}" \ From 1ac65e9f53039dcdc8d2c58c71226643c2ffa80f Mon Sep 17 00:00:00 2001 From: Rick Ossendrijver Date: Thu, 14 Nov 2024 09:28:43 +0100 Subject: [PATCH 27/27] Fix missed merge conflicts --- integration-tests/run-integration-test.sh | 25 ----------------------- 1 file changed, 25 deletions(-) diff --git a/integration-tests/run-integration-test.sh b/integration-tests/run-integration-test.sh index 80ec95a1f5..9944a7b133 100755 --- a/integration-tests/run-integration-test.sh +++ b/integration-tests/run-integration-test.sh @@ -1,15 +1,10 @@ #!/usr/bin/env bash -<<<<<<< HEAD -# This script is not meant to be invoked manually, instead it should be invoked -# through one of the integration test scripts such as the metrics or checkstyle one. -======= # Integration test framework for Maven builds. # # This script is not meant to be invoked manually. Instead it should be invoked # through one of the top-level integration test scripts, such as # `checkstyle.sh`. ->>>>>>> master set -e -u -o pipefail @@ -17,13 +12,8 @@ integration_test_root="$(cd "$(dirname -- "${0}")" && pwd)" error_prone_support_root="${integration_test_root}/.." repos_root="${integration_test_root}/.repos" -<<<<<<< HEAD -if [ "${#}" -ne 11 ]; then - >&2 echo "Usage $(basename "${0}") [TestName] [Project] [Repository] [Revision] [BuildFlags] [AdditionalSourceDirectories] [PatchFlags] [ValidationEpFlags] [ValidationMvnFlags] [DoSync] [ReportDirectory]" -======= if [ "${#}" -lt 9 ] || [ "${#}" -gt 11 ] || ([ "${#}" = 11 ] && [ "${10:---sync}" != '--sync' ]); then >&2 echo "Usage: $(basename "${0}") [--sync] []" ->>>>>>> master exit 1 fi @@ -31,15 +21,6 @@ test_name="${1}" project="${2}" repository="${3}" revision="${4}" -<<<<<<< HEAD -build_flags="${5}" -additional_src_directories="${6}" -patch_flags="${7}" -validation_ep_flags="${8}" -validation_mvn_flags="${9}" -do_sync="${10}" -report_directory="${11}" -======= additional_build_flags="${5}" additional_source_directories="${6}" patch_error_prone_flags="${7}" @@ -47,7 +28,6 @@ validation_error_prone_flags="${8}" validation_build_flags="${9}" do_sync="$([ "${#}" = 9 ] || [ "${10:-}" != '--sync' ] || echo 1)" report_directory="$([ "${#}" = 9 ] || ([ -z "${do_sync}" ] && echo "${10}") || ([ "${#}" = 10 ] || echo "${11}"))" ->>>>>>> master if [ -n "${report_directory}" ]; then mkdir -p "${report_directory}" @@ -79,13 +59,8 @@ shared_build_flags=" -Derror-prone-support.version=$( mvn -f "${error_prone_support_root}" help:evaluate -Dexpression=project.version -q -DforceStdout ) -<<<<<<< HEAD - -DadditionalSourceDirectories=${additional_src_directories} - ${build_flags} -======= -DadditionalSourceDirectories=${additional_source_directories} ${additional_build_flags} ->>>>>>> master " # XXX: Configure Renovate to manage the fmt-maven-plugin version declared here.