Skip to content

Commit fecfb6d

Browse files
Update spotless packages to v8.11.0 (#9002)
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Jack Berg <34418638+jack-berg@users.noreply.github.com>
1 parent f02bddc commit fecfb6d

256 files changed

Lines changed: 8266 additions & 10016 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎all/src/test/java/io/opentelemetry/all/NoGuavaTest.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,10 +52,9 @@ void noGuavaReferences(String artifactId, String absolutePath) throws IOExceptio
5252

5353
private static Stream<Arguments> artifactsAndJars() throws IOException {
5454
return Files.readAllLines(Path.of(System.getenv("ARTIFACTS_AND_JARS"))).stream()
55-
.map(
56-
line -> {
57-
String[] parts = line.split(":", 2);
58-
return Arguments.argumentSet(parts[0], parts[0], parts[1]);
59-
});
55+
.map(line -> {
56+
String[] parts = line.split(":", 2);
57+
return Arguments.argumentSet(parts[0], parts[0], parts[1]);
58+
});
6059
}
6160
}

‎all/src/test/java/io/opentelemetry/all/NoSharedInternalCodeTest.java‎

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,9 @@ public boolean test(JavaClass javaClass) {
110110
private static Stream<Arguments> artifactsAndJars() throws IOException {
111111
List<String> lines = Files.readAllLines(Path.of(System.getenv("ARTIFACTS_AND_JARS")));
112112
return lines.stream()
113-
.map(
114-
line -> {
115-
String[] parts = line.split(":", 2);
116-
return Arguments.argumentSet(parts[0], parts[0], parts[1]);
117-
});
113+
.map(line -> {
114+
String[] parts = line.split(":", 2);
115+
return Arguments.argumentSet(parts[0], parts[0], parts[1]);
116+
});
118117
}
119118
}

‎all/src/test/java/io/opentelemetry/all/NullGuardsTest.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -416,10 +416,8 @@ private static boolean visitSupertype(
416416
private static boolean declaresMethod(ClassModel cls, String name, String desc) {
417417
return cls.methods().stream()
418418
.filter(m -> !m.flags().has(AccessFlag.STATIC) && !m.flags().has(AccessFlag.PRIVATE))
419-
.anyMatch(
420-
m ->
421-
name.equals(m.methodName().stringValue())
422-
&& desc.equals(m.methodType().stringValue()));
419+
.anyMatch(m ->
420+
name.equals(m.methodName().stringValue()) && desc.equals(m.methodType().stringValue()));
423421
}
424422

425423
private static boolean isInAuditablePackage(ClassModel cls) {

‎api/all/src/jmh/java/io/opentelemetry/api/baggage/propagation/W3CBaggagePropagatorBenchmark.java‎

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,18 @@ public class W3CBaggagePropagatorBenchmark {
3434
static {
3535
List<String> baggages =
3636
IntStream.range(0, 100)
37-
.mapToObj(
38-
i ->
39-
"key"
40-
+ i
41-
+ " = value"
42-
+ i
43-
+ ";metaKey"
44-
+ i
45-
+ "=\tmetaVal"
46-
+ i
47-
+ ",broken)key"
48-
+ i
49-
+ "=value")
37+
.mapToObj(i ->
38+
"key"
39+
+ i
40+
+ " = value"
41+
+ i
42+
+ ";metaKey"
43+
+ i
44+
+ "=\tmetaVal"
45+
+ i
46+
+ ",broken)key"
47+
+ i
48+
+ "=value")
5049
.collect(Collectors.toList());
5150
SMALL_BAGGAGE = Collections.singletonMap("baggage", String.join(",", baggages.subList(0, 5)));
5251
LARGE_BAGGAGE = Collections.singletonMap("baggage", String.join(",", baggages));

‎api/all/src/main/java/io/opentelemetry/api/baggage/Baggage.java‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,11 @@ default BaggageEntry getEntry(String entryKey) {
127127
return null;
128128
}
129129
BaggageEntry[] result = new BaggageEntry[] {null};
130-
forEach(
131-
(key, entry) -> {
132-
if (entryKey.equals(key)) {
133-
result[0] = entry;
134-
}
135-
});
130+
forEach((key, entry) -> {
131+
if (entryKey.equals(key)) {
132+
result[0] = entry;
133+
}
134+
});
136135
return result[0];
137136
}
138137
}

‎api/all/src/main/java/io/opentelemetry/api/baggage/propagation/W3CBaggagePropagator.java‎

Lines changed: 33 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,41 +74,39 @@ public <C> void inject(Context context, @Nullable C carrier, TextMapSetter<C> se
7474
private static String baggageToString(Baggage baggage) {
7575
StringBuilder headerContent = new StringBuilder();
7676
int[] entryCount = {0};
77-
baggage.forEach(
78-
(key, baggageEntry) -> {
79-
if (!isValidBaggageKey(key)) {
80-
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid key");
81-
return;
82-
}
83-
if (!isValidBaggageValue(baggageEntry.getValue())) {
84-
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid value");
85-
return;
86-
}
87-
if (!isValidBaggageMetadata(baggageEntry.getMetadata().getValue())) {
88-
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid metadata");
89-
return;
90-
}
91-
if (entryCount[0] >= MAX_BAGGAGE_ENTRIES) {
92-
return;
93-
}
94-
String encodedValue = encodeValue(baggageEntry.getValue());
95-
String metadataValue = baggageEntry.getMetadata().getValue();
96-
String metadata =
97-
(metadataValue != null && !metadataValue.isEmpty()) ? metadataValue : null;
98-
// Exit early if adding this entry causes the total length to exceed the limit
99-
// encodedEntryLength includes a trailing comma; the final string trims exactly one,
100-
// so the net contribution to the final length is entryLength - 1.
101-
if (headerContent.length() + encodedEntryLength(key, encodedValue, metadata) - 1
102-
> MAX_BAGGAGE_BYTES) {
103-
return;
104-
}
105-
headerContent.append(key).append("=").append(encodedValue);
106-
if (metadata != null) {
107-
headerContent.append(";").append(metadata);
108-
}
109-
headerContent.append(",");
110-
entryCount[0]++;
111-
});
77+
baggage.forEach((key, baggageEntry) -> {
78+
if (!isValidBaggageKey(key)) {
79+
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid key");
80+
return;
81+
}
82+
if (!isValidBaggageValue(baggageEntry.getValue())) {
83+
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid value");
84+
return;
85+
}
86+
if (!isValidBaggageMetadata(baggageEntry.getMetadata().getValue())) {
87+
LOGGER.log(Level.WARNING, "Skipping baggage entry with invalid metadata");
88+
return;
89+
}
90+
if (entryCount[0] >= MAX_BAGGAGE_ENTRIES) {
91+
return;
92+
}
93+
String encodedValue = encodeValue(baggageEntry.getValue());
94+
String metadataValue = baggageEntry.getMetadata().getValue();
95+
String metadata = (metadataValue != null && !metadataValue.isEmpty()) ? metadataValue : null;
96+
// Exit early if adding this entry causes the total length to exceed the limit
97+
// encodedEntryLength includes a trailing comma; the final string trims exactly one,
98+
// so the net contribution to the final length is entryLength - 1.
99+
if (headerContent.length() + encodedEntryLength(key, encodedValue, metadata) - 1
100+
> MAX_BAGGAGE_BYTES) {
101+
return;
102+
}
103+
headerContent.append(key).append("=").append(encodedValue);
104+
if (metadata != null) {
105+
headerContent.append(";").append(metadata);
106+
}
107+
headerContent.append(",");
108+
entryCount[0]++;
109+
});
112110

113111
if (headerContent.length() == 0) {
114112
return "";

‎api/all/src/main/java/io/opentelemetry/api/common/ArrayBackedAttributesBuilder.java‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,8 @@ public <T> AttributesBuilder remove(AttributeKey<T> key) {
189189
if (key.getKey().isEmpty()) {
190190
return this;
191191
}
192-
return removeIf(
193-
entryKey ->
194-
key.getKey().equals(entryKey.getKey()) && key.getType().equals(entryKey.getType()));
192+
return removeIf(entryKey ->
193+
key.getKey().equals(entryKey.getKey()) && key.getType().equals(entryKey.getType()));
195194
}
196195

197196
@Override

‎api/all/src/main/java/io/opentelemetry/api/trace/propagation/internal/W3CTraceContextEncoding.java‎

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,13 +78,12 @@ public static String encodeTraceState(TraceState traceState) {
7878
return "";
7979
}
8080
StringBuilder builder = new StringBuilder(TRACESTATE_MAX_SIZE);
81-
traceState.forEach(
82-
(key, value) -> {
83-
if (builder.length() != 0) {
84-
builder.append(TRACESTATE_ENTRY_DELIMITER);
85-
}
86-
builder.append(key).append(TRACESTATE_KEY_VALUE_DELIMITER).append(value);
87-
});
81+
traceState.forEach((key, value) -> {
82+
if (builder.length() != 0) {
83+
builder.append(TRACESTATE_ENTRY_DELIMITER);
84+
}
85+
builder.append(key).append(TRACESTATE_KEY_VALUE_DELIMITER).append(value);
86+
});
8887
return builder.toString();
8988
}
9089
}

‎api/all/src/test/java/io/opentelemetry/api/logs/ValueTest.java‎

Lines changed: 61 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -33,90 +33,82 @@ class ValueTest {
3333
@Test
3434
void value_OfString() {
3535
assertThat(Value.of("foo"))
36-
.satisfies(
37-
value -> {
38-
assertThat(value.getType()).isEqualTo(ValueType.STRING);
39-
assertThat(value.getValue()).isEqualTo("foo");
40-
assertThat(value).hasSameHashCodeAs(Value.of("foo"));
41-
});
36+
.satisfies(value -> {
37+
assertThat(value.getType()).isEqualTo(ValueType.STRING);
38+
assertThat(value.getValue()).isEqualTo("foo");
39+
assertThat(value).hasSameHashCodeAs(Value.of("foo"));
40+
});
4241
}
4342

4443
@Test
4544
void value_OfBoolean() {
4645
assertThat(Value.of(true))
47-
.satisfies(
48-
value -> {
49-
assertThat(value.getType()).isEqualTo(ValueType.BOOLEAN);
50-
assertThat(value.getValue()).isEqualTo(true);
51-
assertThat(value).hasSameHashCodeAs(Value.of(true));
52-
});
46+
.satisfies(value -> {
47+
assertThat(value.getType()).isEqualTo(ValueType.BOOLEAN);
48+
assertThat(value.getValue()).isEqualTo(true);
49+
assertThat(value).hasSameHashCodeAs(Value.of(true));
50+
});
5351
}
5452

5553
@Test
5654
void value_OfLong() {
5755
assertThat(Value.of(1L))
58-
.satisfies(
59-
value -> {
60-
assertThat(value.getType()).isEqualTo(ValueType.LONG);
61-
assertThat(value.getValue()).isEqualTo(1L);
62-
assertThat(value).hasSameHashCodeAs(Value.of(1L));
63-
});
56+
.satisfies(value -> {
57+
assertThat(value.getType()).isEqualTo(ValueType.LONG);
58+
assertThat(value.getValue()).isEqualTo(1L);
59+
assertThat(value).hasSameHashCodeAs(Value.of(1L));
60+
});
6461
}
6562

6663
@Test
6764
void value_OfDouble() {
6865
assertThat(Value.of(1.1))
69-
.satisfies(
70-
value -> {
71-
assertThat(value.getType()).isEqualTo(ValueType.DOUBLE);
72-
assertThat(value.getValue()).isEqualTo(1.1);
73-
assertThat(value).hasSameHashCodeAs(Value.of(1.1));
74-
});
66+
.satisfies(value -> {
67+
assertThat(value.getType()).isEqualTo(ValueType.DOUBLE);
68+
assertThat(value.getValue()).isEqualTo(1.1);
69+
assertThat(value).hasSameHashCodeAs(Value.of(1.1));
70+
});
7571
}
7672

7773
@Test
7874
void value_OfByteArray() {
7975
assertThat(Value.of(new byte[] {'a', 'b'}))
80-
.satisfies(
81-
value -> {
82-
assertThat(value.getType()).isEqualTo(ValueType.BYTES);
83-
ByteBuffer buf = value.getValue();
84-
// ValueBytes returns read only view of ByteBuffer
85-
assertThatThrownBy(buf::array).isInstanceOf(ReadOnlyBufferException.class);
86-
byte[] bytes = new byte[buf.remaining()];
87-
buf.get(bytes);
88-
assertThat(bytes).isEqualTo(new byte[] {'a', 'b'});
89-
assertThat(value).hasSameHashCodeAs(Value.of(new byte[] {'a', 'b'}));
90-
});
76+
.satisfies(value -> {
77+
assertThat(value.getType()).isEqualTo(ValueType.BYTES);
78+
ByteBuffer buf = value.getValue();
79+
// ValueBytes returns read only view of ByteBuffer
80+
assertThatThrownBy(buf::array).isInstanceOf(ReadOnlyBufferException.class);
81+
byte[] bytes = new byte[buf.remaining()];
82+
buf.get(bytes);
83+
assertThat(bytes).isEqualTo(new byte[] {'a', 'b'});
84+
assertThat(value).hasSameHashCodeAs(Value.of(new byte[] {'a', 'b'}));
85+
});
9186
}
9287

9388
@Test
9489
void value_OfvalueArray() {
9590
assertThat(Value.of(Value.of(true), Value.of(1L)))
96-
.satisfies(
97-
value -> {
98-
assertThat(value.getType()).isEqualTo(ValueType.ARRAY);
99-
assertThat(value.getValue()).isEqualTo(Arrays.asList(Value.of(true), Value.of(1L)));
100-
assertThat(value).hasSameHashCodeAs(Value.of(Value.of(true), Value.of(1L)));
101-
});
91+
.satisfies(value -> {
92+
assertThat(value.getType()).isEqualTo(ValueType.ARRAY);
93+
assertThat(value.getValue()).isEqualTo(Arrays.asList(Value.of(true), Value.of(1L)));
94+
assertThat(value).hasSameHashCodeAs(Value.of(Value.of(true), Value.of(1L)));
95+
});
10296
}
10397

10498
@Test
10599
@SuppressWarnings("DoubleBraceInitialization")
106100
void value_OfKeyValueList() {
107101
assertThat(Value.of(KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))))
108-
.satisfies(
109-
value -> {
110-
assertThat(value.getType()).isEqualTo(ValueType.KEY_VALUE_LIST);
111-
assertThat(value.getValue())
112-
.isEqualTo(
113-
Arrays.asList(
114-
KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
115-
assertThat(value)
116-
.hasSameHashCodeAs(
117-
Value.of(
118-
KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
119-
});
102+
.satisfies(value -> {
103+
assertThat(value.getType()).isEqualTo(ValueType.KEY_VALUE_LIST);
104+
assertThat(value.getValue())
105+
.isEqualTo(
106+
Arrays.asList(
107+
KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
108+
assertThat(value)
109+
.hasSameHashCodeAs(
110+
Value.of(KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
111+
});
120112

121113
assertThat(
122114
Value.of(
@@ -126,23 +118,22 @@ void value_OfKeyValueList() {
126118
put("long", Value.of(1L));
127119
}
128120
}))
129-
.satisfies(
130-
value -> {
131-
assertThat(value.getType()).isEqualTo(ValueType.KEY_VALUE_LIST);
132-
assertThat(value.getValue())
133-
.isEqualTo(
134-
Arrays.asList(
135-
KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
136-
assertThat(value)
137-
.hasSameHashCodeAs(
138-
Value.of(
139-
new LinkedHashMap<String, Value<?>>() {
140-
{
141-
put("bool", Value.of(true));
142-
put("long", Value.of(1L));
143-
}
144-
}));
145-
});
121+
.satisfies(value -> {
122+
assertThat(value.getType()).isEqualTo(ValueType.KEY_VALUE_LIST);
123+
assertThat(value.getValue())
124+
.isEqualTo(
125+
Arrays.asList(
126+
KeyValue.of("bool", Value.of(true)), KeyValue.of("long", Value.of(1L))));
127+
assertThat(value)
128+
.hasSameHashCodeAs(
129+
Value.of(
130+
new LinkedHashMap<String, Value<?>>() {
131+
{
132+
put("bool", Value.of(true));
133+
put("long", Value.of(1L));
134+
}
135+
}));
136+
});
146137
}
147138

148139
@Test

‎api/incubator/src/test/java/io/opentelemetry/api/incubator/logs/ExtendedLogsBridgeApiUsageTest.java‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,8 @@ void loggerEnabled() {
6868
// omitted from the results even if logs were emitted. The check if enabled simply avoids
6969
// unnecessary computation.
7070
assertThat(exporter.getFinishedLogRecordItems())
71-
.allSatisfy(
72-
logRecordData ->
73-
assertThat(logRecordData.getInstrumentationScopeInfo().getName())
74-
.isEqualTo("loggerA"));
71+
.allSatisfy(logRecordData ->
72+
assertThat(logRecordData.getInstrumentationScopeInfo().getName()).isEqualTo("loggerA"));
7573
}
7674

7775
private static final Random random = new Random();

0 commit comments

Comments
 (0)