From 31ee740d1c7cd80e9473fd31af998a9ee4729334 Mon Sep 17 00:00:00 2001 From: svc-excavator-bot Date: Fri, 30 Sep 2022 04:31:58 +0000 Subject: [PATCH 1/2] Excavator: Upgrades Baseline to the latest version --- build.gradle | 2 +- .../com/palantir/tritium/metrics/InternalCacheMetrics.java | 2 +- .../com/palantir/tritium/metrics/MetricRegistriesTest.java | 4 ++-- .../tritium/metrics/registry/ImmutableMetricName.java | 2 +- .../com/palantir/tritium/metrics/registry/RealMetricName.java | 2 +- .../tritium/metrics/registry/ExtraEntrySortedMapTest.java | 4 ++-- .../com/palantir/tritium/metrics/registry/TagMapTest.java | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/build.gradle b/build.gradle index 4b9501e8..d3715719 100644 --- a/build.gradle +++ b/build.gradle @@ -7,7 +7,7 @@ buildscript { dependencies { classpath 'com.palantir.gradle.jdks:gradle-jdks:0.27.0' classpath 'com.palantir.gradle.jdkslatest:gradle-jdks-latest:0.4.0' - classpath 'com.palantir.baseline:gradle-baseline-java:4.178.0' + classpath 'com.palantir.baseline:gradle-baseline-java:4.179.0' classpath 'com.palantir.gradle.consistentversions:gradle-consistent-versions:2.11.0' classpath 'com.palantir.gradle.externalpublish:gradle-external-publish-plugin:1.11.0' classpath 'com.palantir.gradle.gitversion:gradle-git-version:0.15.0' diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java index a5df2be9..cf9dd5a6 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java @@ -41,7 +41,7 @@ private InternalCacheMetrics() {} public static ImmutableMap> createMetrics(Stats stats, Function metricNamer) { ImmutableMap.Builder> builder = ImmutableMap.builder(); stats.forEach((name, gauge) -> builder.put(metricNamer.apply(name), gauge)); - return builder.build(); + return builder.buildOrThrow(); } @SuppressWarnings("NoFunctionalReturnType") diff --git a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java index b12bac87..fce417a1 100644 --- a/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java +++ b/tritium-metrics/src/test/java/com/palantir/tritium/metrics/MetricRegistriesTest.java @@ -495,7 +495,7 @@ void testRegisterAll() { .put("counter", counter) .put("timer", timer) .put("set", (MetricSet) () -> ImmutableMap.of("gauge", gauge)) - .build(); + .buildOrThrow(); MetricRegistries.registerAll(registry, "tritium", metricSet); assertThat(registry.getMetrics()) .containsExactlyInAnyOrderEntriesOf(ImmutableMap.builder() @@ -505,7 +505,7 @@ void testRegisterAll() { .put(simpleName("tritium.counter"), counter) .put(simpleName("tritium.timer"), timer) .put(simpleName("tritium.set.gauge"), gauge) - .build()); + .buildOrThrow()); } @Test diff --git a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java index 3743a300..bdf3b7b2 100644 --- a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java +++ b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java @@ -84,7 +84,7 @@ public MetricName.Builder putAllSafeTags(@Safe Map<@Safe String, @Safe ? extends : TagMap.of(ImmutableMap.builderWithExpectedSize(tagMap.size() + entries.size()) .putAll(tagMap) .putAll(entries) - .build()); + .buildOrThrow()); } return (MetricName.Builder) this; } diff --git a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/RealMetricName.java b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/RealMetricName.java index a857e134..a051a818 100644 --- a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/RealMetricName.java +++ b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/RealMetricName.java @@ -101,6 +101,6 @@ private static TagMap withEntryFallback(SortedMap tags, String e return TagMap.of(ImmutableSortedMap.naturalOrder() .putAll(tags) .put(extraTagName, extraTagValue) - .build()); + .buildOrThrow()); } } diff --git a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/ExtraEntrySortedMapTest.java b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/ExtraEntrySortedMapTest.java index 0999a229..0500380e 100644 --- a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/ExtraEntrySortedMapTest.java +++ b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/ExtraEntrySortedMapTest.java @@ -58,7 +58,7 @@ void check_TagMap_has_the_same_behaviour_as_an_ImmutableSortedMap_with_an_extra_ ImmutableSortedMap guavaWithExtra = ImmutableSortedMap.naturalOrder() .putAll(base) .put(extraKey, extraValue) - .build(); + .buildOrThrow(); SortedMap extraMap = TagMap.of(base).withEntry(extraKey, extraValue); @@ -84,7 +84,7 @@ void check_TagMap_has_the_same_behaviour_as_an_ImmutableSortedMap_with_an_extra_ .put("keySet", SortedMap::keySet) .put("entrySet", SortedMap::entrySet) .put("values", shortByteSortedMap -> ImmutableList.copyOf(shortByteSortedMap.values())) - .build(); + .buildOrThrow(); methodCalls.forEach((methodCallName, methodCall) -> { assertThat(methodCall.apply(extraMap)) diff --git a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TagMapTest.java b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TagMapTest.java index 68e8d3f5..64a4c4e5 100644 --- a/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TagMapTest.java +++ b/tritium-registry/src/test/java/com/palantir/tritium/metrics/registry/TagMapTest.java @@ -84,7 +84,7 @@ void testNaturalOrder() { Comparator immutableSortedMapComparator = ImmutableSortedMap.naturalOrder() .put("a", "b") .put("c", "d") - .build() + .buildOrThrow() .comparator(); assertThat(TagMap.isNaturalOrder(immutableSortedMapComparator)) .as("Expected ImmutableSortedMap comparator %s to be natural", immutableSortedMapComparator) From c5de9701368334465e36959be09518638c45207b Mon Sep 17 00:00:00 2001 From: David Schlosnagle Date: Fri, 30 Sep 2022 20:19:26 -0400 Subject: [PATCH 2/2] Adjust generated output --- .../java/com/palantir/tritium/metrics/InternalCacheMetrics.java | 2 +- .../palantir/tritium/metrics/registry/ImmutableMetricName.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java index cf9dd5a6..146ee364 100644 --- a/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java +++ b/tritium-metrics/src/main/java/com/palantir/tritium/metrics/InternalCacheMetrics.java @@ -39,7 +39,7 @@ public final class InternalCacheMetrics { private InternalCacheMetrics() {} public static ImmutableMap> createMetrics(Stats stats, Function metricNamer) { - ImmutableMap.Builder> builder = ImmutableMap.builder(); + ImmutableMap.Builder> builder = ImmutableMap.builderWithExpectedSize(12); stats.forEach((name, gauge) -> builder.put(metricNamer.apply(name), gauge)); return builder.buildOrThrow(); } diff --git a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java index bdf3b7b2..9fd61edf 100644 --- a/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java +++ b/tritium-registry/src/main/java/com/palantir/tritium/metrics/registry/ImmutableMetricName.java @@ -84,7 +84,7 @@ public MetricName.Builder putAllSafeTags(@Safe Map<@Safe String, @Safe ? extends : TagMap.of(ImmutableMap.builderWithExpectedSize(tagMap.size() + entries.size()) .putAll(tagMap) .putAll(entries) - .buildOrThrow()); + .buildKeepingLast()); } return (MetricName.Builder) this; }