Skip to content

Commit 240cdd3

Browse files
Merge branch '1.14.x' into 1.15.x
2 parents 8f9ec4f + 7ef45ea commit 240cdd3

File tree

3 files changed

+24
-14
lines changed

3 files changed

+24
-14
lines changed

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ subprojects {
7676
options.errorprone.disableWarningsInGeneratedCode = true
7777
options.errorprone.excludedPaths = ".*/build/generated/.*"
7878
options.errorprone.error(
79+
"AlmostJavadoc",
7980
"ArrayAsKeyOfSetOrMap",
8081
"AttemptedNegativeZero",
8182
"BadImport",

concurrency-tests/src/jcstress/java/io/micrometer/concurrencytests/MeterRegistryConcurrencyTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,8 @@ public void arbiter(Z_Result r) {
9696
// @formatter:off
9797
/*
9898
When configuring a MeterFilter after a Meter has already been registered, existing meters will be marked stale.
99-
Subsequent calls to {@code getOrCreateMeter} for those Meters create a new Meter with all MeterFilters applied.
100-
If multiple concurrent calls to {@code getOrCreateMeter} interleave, it's possible not all see the new Meter.
99+
Subsequent calls to getOrCreateMeter() for those Meters create a new Meter with all MeterFilters applied.
100+
If multiple concurrent calls to getOrCreateMeter() interleave, it's possible not all see the new Meter.
101101
We ideally want both to get the new meter, but we don't want to pay the cost associated with that level of safety
102102
given the expected rarity of this situation happening, so we aim to get as close as possible for cheap.
103103

micrometer-core/src/test/java/io/micrometer/core/testsupport/system/OutputCapture.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,15 @@ class OutputCapture implements CapturedOutput {
4848

4949
private final Deque<SystemCapture> systemCaptures = new ArrayDeque<>();
5050

51-
private final AtomicReference<String> out = new AtomicReference<>(null);
51+
private final AtomicReference<Object> out = new AtomicReference<>();
5252

53-
private final AtomicReference<String> err = new AtomicReference<>(null);
53+
private final AtomicReference<Object> err = new AtomicReference<>();
5454

55-
private final AtomicReference<String> all = new AtomicReference<>(null);
55+
private final AtomicReference<Object> all = new AtomicReference<>();
56+
57+
OutputCapture() {
58+
clearExisting();
59+
}
5660

5761
/**
5862
* Push a new system capture session onto the stack.
@@ -128,20 +132,21 @@ void reset() {
128132
}
129133

130134
void clearExisting() {
131-
this.out.set(null);
132-
this.err.set(null);
133-
this.all.set(null);
135+
this.out.set(new NoOutput());
136+
this.err.set(new NoOutput());
137+
this.all.set(new NoOutput());
134138
}
135139

136-
private String get(AtomicReference<String> existing, Predicate<Type> filter) {
140+
private String get(AtomicReference<Object> existing, Predicate<Type> filter) {
137141
Assert.state(!this.systemCaptures.isEmpty(),
138142
"No system captures found. Please check your output capture registration.");
139-
String result = existing.get();
140-
if (result == null) {
141-
result = build(filter);
142-
existing.compareAndSet(null, result);
143+
Object existingOutput = existing.get();
144+
if (existingOutput instanceof String) {
145+
return (String) existingOutput;
143146
}
144-
return result;
147+
String builtOutput = build(filter);
148+
existing.compareAndSet(existingOutput, builtOutput);
149+
return builtOutput;
145150
}
146151

147152
String build(Predicate<Type> filter) {
@@ -306,4 +311,8 @@ enum Type {
306311

307312
}
308313

314+
static class NoOutput {
315+
316+
}
317+
309318
}

0 commit comments

Comments
 (0)