Skip to content
This repository was archived by the owner on Dec 1, 2025. It is now read-only.

Commit 631c788

Browse files
committed
Fixing MeterCache mess.
1 parent 707b2d6 commit 631c788

File tree

6 files changed

+18
-11
lines changed

6 files changed

+18
-11
lines changed

.github/workflows/build.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ jobs:
2727
max-parallel: 100
2828
matrix:
2929
spring_boot_version:
30-
- 3.4.6
31-
- 3.5.0
30+
- 3.4.8
31+
- 3.5.4
3232

3333
env:
3434
SPRING_BOOT_VERSION: ${{ matrix.spring_boot_version }}

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.14.1] - 2025-07-24
9+
10+
### Fixed
11+
- Flakiness of equals method in TagsSetArray.
12+
813
## [1.14.0] - 2025-07-10
914

1015
### Changed

build.libraries.gradle

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
ext {
2-
springBootVersion = "${System.getenv("SPRING_BOOT_VERSION") ?: "3.2.2"}"
2+
springBootVersion = "${System.getenv("SPRING_BOOT_VERSION") ?: "3.4.8"}"
33

44
libraries = [
55
// version defined
6-
awaitility : "org.awaitility:awaitility:4.2.2",
7-
commonsIo : "commons-io:commons-io:2.17.0",
8-
guava : 'com.google.guava:guava:33.3.1-jre',
6+
awaitility : "org.awaitility:awaitility:4.3.0",
7+
commonsIo : "commons-io:commons-io:2.20.0",
8+
guava : 'com.google.guava:guava:33.4.0-jre',
99
jakartaValidationApi : 'jakarta.validation:jakarta.validation-api:3.0.2',
1010
javaxValidationApi : "javax.validation:validation-api:2.0.1.Final",
1111
roaringBitmap : 'org.roaringbitmap:RoaringBitmap:1.3.0',

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=1.14.0
1+
version=1.14.1

tw-base-utils/src/main/java/com/transferwise/common/baseutils/meters/cache/TagsSet.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,10 @@ public boolean equals(Object other) {
6161
return Arrays.equals(this.tags, ((ArrayTagsSet) other).tags);
6262
}
6363

64+
// Cloning is necessary to avoid Micrometer sorting our own array, making equals method flaky.
6465
@Override
6566
public Tags getMicrometerTags() {
66-
return Tags.of(tags);
67+
return Tags.of(Arrays.copyOf(tags, tags.length));
6768
}
6869
}
6970

tw-base-utils/src/test/java/com/transferwise/common/baseutils/meters/cache/MeterCacheTest.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,14 @@ void counterCacheWorksWithTags() {
5959
final var tag2 = Tag.of("tag2", "tagValue2");
6060
final var counterName = "my.test.counter";
6161

62-
var counter0 = meterCache.counter(counterName, TagsSet.of(tag0, tag1));
63-
var counter1 = meterCache.counter(counterName, TagsSet.of(tag0, tag1));
62+
// Notice the reverse order of tags, so that micrometer will be reordering them.
63+
var counter0 = meterCache.counter(counterName, TagsSet.of(tag1, tag0));
64+
var counter1 = meterCache.counter(counterName, TagsSet.of(tag1, tag0));
6465

6566
assertSame(counter0, counter1);
6667
assertEquals(1, meterCache.size());
6768

68-
var counter2 = meterCache.counter(counterName, TagsSet.of(tag1, tag0));
69+
var counter2 = meterCache.counter(counterName, TagsSet.of(tag0, tag1));
6970
//Even when cache is different, the underlying meterRegistry provides same counter.
7071
assertSame(counter0, counter2);
7172
assertEquals(2, meterCache.size());

0 commit comments

Comments
 (0)