From 96cf3a019433047151305e2a8ed041e4a59b5feb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 19 Sep 2025 21:48:58 +0000 Subject: [PATCH 1/4] fix(deps): update errorproneversion to v2.42.0 --- dependencyManagement/build.gradle.kts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index 101e6ce36f3..d2e080311c4 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -9,7 +9,7 @@ rootProject.extra["versions"] = dependencyVersions val autoValueVersion = "1.11.0" -val errorProneVersion = "2.41.0" +val errorProneVersion = "2.42.0" val jmhVersion = "1.37" // Mockito 5.x.x requires Java 11 https://github.com/mockito/mockito/releases/tag/v5.0.0 val mockitoVersion = "4.11.0" From 2b0eab545ab767ea706b606807409c3c7ee9b3d5 Mon Sep 17 00:00:00 2001 From: jwatson Date: Mon, 22 Sep 2025 13:00:46 -0700 Subject: [PATCH 2/4] deal with new errorprone arrays-for-varargs constraints --- .../io/opentelemetry/api/common/AttributesTest.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/all/src/test/java/io/opentelemetry/api/common/AttributesTest.java b/api/all/src/test/java/io/opentelemetry/api/common/AttributesTest.java index 1200dac1b14..dcc6f701e5a 100644 --- a/api/all/src/test/java/io/opentelemetry/api/common/AttributesTest.java +++ b/api/all/src/test/java/io/opentelemetry/api/common/AttributesTest.java @@ -421,10 +421,14 @@ void nullsAreNoOps() { builder.put("long", 10); builder.put("double", 1.0); builder.put("bool", true); - builder.put("arrayString", new String[] {"string"}); - builder.put("arrayLong", new long[] {10L}); - builder.put("arrayDouble", new double[] {1.0}); - builder.put("arrayBool", new boolean[] {true}); + String[] strings = {"string"}; + builder.put("arrayString", strings); + long[] longs = {10L}; + builder.put("arrayLong", longs); + double[] doubles = {1.0}; + builder.put("arrayDouble", doubles); + boolean[] booleans = {true}; + builder.put("arrayBool", booleans); assertThat(builder.build().size()).isEqualTo(9); // note: currently these are no-op calls; that behavior is not required, so if it needs to From 3b3b92cc8ba727ea8e5a4572e3d04b16fc5da891 Mon Sep 17 00:00:00 2001 From: jwatson Date: Mon, 22 Sep 2025 13:16:05 -0700 Subject: [PATCH 3/4] more single-element arrays --- .../opentelemetry/sdk/trace/SdkSpanTest.java | 118 +++++++++--------- 1 file changed, 59 insertions(+), 59 deletions(-) diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java index d5c40fcccbf..f43bee950e9 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java @@ -15,6 +15,7 @@ import static io.opentelemetry.api.common.AttributeKey.stringKey; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.equalTo; +import static java.util.Collections.singletonList; import static java.util.stream.Collectors.joining; import static org.assertj.core.api.Assertions.assertThatCode; import static org.assertj.core.api.Assertions.assertThatThrownBy; @@ -135,7 +136,7 @@ void nothingChangedAfterEnd() { spanData, Attributes.empty(), Collections.emptyList(), - Collections.singletonList(link), + singletonList(link), SPAN_NAME, START_EPOCH_NANOS, START_EPOCH_NANOS, @@ -161,14 +162,14 @@ void onEnding_spanStillMutable() { AtomicBoolean endedStateInProcessor = new AtomicBoolean(); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - assertThat(sp.hasEnded()).isFalse(); - sp.end(); // should have no effect, nested end should be detected - endedStateInProcessor.set(sp.hasEnded()); - sp.setAttribute(dummyAttrib, "bar"); - return null; - }) + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + assertThat(sp.hasEnded()).isFalse(); + sp.end(); // should have no effect, nested end should be detected + endedStateInProcessor.set(sp.hasEnded()); + sp.setAttribute(dummyAttrib, "bar"); + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -187,21 +188,21 @@ void onEnding_concurrentModificationsPrevented() { AttributeKey concurrentAttrib = AttributeKey.stringKey("concurrent_foo"); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - Thread concurrent = - new Thread( - () -> { - sp.setAttribute(concurrentAttrib, "concurrent_bar"); - }); - concurrent.start(); - concurrent.join(); + Thread concurrent = + new Thread( + () -> { + sp.setAttribute(concurrentAttrib, "concurrent_bar"); + }); + concurrent.start(); + concurrent.join(); - sp.setAttribute(syncAttrib, "sync_bar"); + sp.setAttribute(syncAttrib, "sync_bar"); - return null; - }) + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -217,13 +218,13 @@ void onEnding_latencyPinned() { AtomicLong spanLatencyInProcessor = new AtomicLong(); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - testClock.advance(Duration.ofSeconds(100)); - spanLatencyInProcessor.set(sp.getLatencyNanos()); - return null; - }) + testClock.advance(Duration.ofSeconds(100)); + spanLatencyInProcessor.set(sp.getLatencyNanos()); + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -251,8 +252,8 @@ void toSpanData_ActiveSpan() { verifySpanData( spanData, expectedAttributes, - Collections.singletonList(event), - Collections.singletonList(link), + singletonList(event), + singletonList(link), SPAN_NEW_NAME, START_EPOCH_NANOS, 0, @@ -282,8 +283,8 @@ void toSpanData_EndedSpan() { verifySpanData( spanData, expectedAttributes, - Collections.singletonList(event), - Collections.singletonList(link), + singletonList(event), + singletonList(link), SPAN_NEW_NAME, START_EPOCH_NANOS, testClock.now(), @@ -306,7 +307,7 @@ void toSpanData_immutableEvents() { SpanData spanData = span.toSpanData(); assertThatThrownBy( - () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) + () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) .isInstanceOf(UnsupportedOperationException.class); } @@ -317,7 +318,7 @@ void toSpanData_immutableEvents_ended() { SpanData spanData = span.toSpanData(); assertThatThrownBy( - () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) + () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) .isInstanceOf(UnsupportedOperationException.class); } @@ -466,7 +467,8 @@ void getAttributes_Empty() { } @Test - @SuppressWarnings("deprecation") // Testing deprecated code + @SuppressWarnings("deprecation") + // Testing deprecated code void getInstrumentationLibraryInfo() { SdkSpan span = createTestSpan(SpanKind.CLIENT); try { @@ -552,13 +554,10 @@ void setAttribute() { span.setAttribute(doubleArrayKey("NullArrayDoubleKey"), null); span.setAttribute(booleanArrayKey("NullArrayBooleanKey"), null); // These should be maintained - span.setAttribute(longArrayKey("ArrayWithNullLongKey"), Arrays.asList(new Long[] {null})); - span.setAttribute( - stringArrayKey("ArrayWithNullStringKey"), Arrays.asList(new String[] {null})); - span.setAttribute( - doubleArrayKey("ArrayWithNullDoubleKey"), Arrays.asList(new Double[] {null})); - span.setAttribute( - booleanArrayKey("ArrayWithNullBooleanKey"), Arrays.asList(new Boolean[] {null})); + span.setAttribute(longArrayKey("ArrayWithNullLongKey"), singletonList(null)); + span.setAttribute(stringArrayKey("ArrayWithNullStringKey"), singletonList(null)); + span.setAttribute(doubleArrayKey("ArrayWithNullDoubleKey"), singletonList(null)); + span.setAttribute(booleanArrayKey("ArrayWithNullBooleanKey"), singletonList(null)); } finally { span.end(); } @@ -691,10 +690,10 @@ void setAllAttributes() { .put(doubleArrayKey("NullArrayDoubleKey"), (Double[]) null) .put(booleanArrayKey("NullArrayBooleanKey"), (Boolean[]) null) // These should be maintained - .put(longArrayKey("ArrayWithNullLongKey"), Arrays.asList(new Long[] {null})) - .put(stringArrayKey("ArrayWithNullStringKey"), Arrays.asList(new String[] {null})) - .put(doubleArrayKey("ArrayWithNullDoubleKey"), Arrays.asList(new Double[] {null})) - .put(booleanArrayKey("ArrayWithNullBooleanKey"), Arrays.asList(new Boolean[] {null})) + .put(longArrayKey("ArrayWithNullLongKey"), singletonList(null)) + .put(stringArrayKey("ArrayWithNullStringKey"), singletonList(null)) + .put(doubleArrayKey("ArrayWithNullDoubleKey"), singletonList(null)) + .put(booleanArrayKey("ArrayWithNullBooleanKey"), singletonList(null)) .build(); try { @@ -1315,7 +1314,7 @@ public void setExceptionAttributes( SpanLimits.getDefault(), parentSpanId, null, - Collections.singletonList(link), + singletonList(link), exceptionAttributeResolver); span.recordException(new IllegalStateException("error")); @@ -1374,8 +1373,8 @@ void onStartOnEndNotRequired() { SpanKind.INTERNAL, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), spanLimits, @@ -1405,7 +1404,8 @@ void setStatus(Consumer spanConsumer, StatusData expectedSpanData) { private static Stream setStatusArgs() { return Stream.of( // Default status is UNSET - Arguments.of(spanConsumer(span -> {}), StatusData.unset()), + Arguments.of(spanConsumer(span -> { + }), StatusData.unset()), // Simple cases Arguments.of(spanConsumer(span -> span.setStatus(StatusCode.OK)), StatusData.ok()), Arguments.of(spanConsumer(span -> span.setStatus(StatusCode.ERROR)), StatusData.error()), @@ -1462,7 +1462,7 @@ private SdkSpan createTestSpanWithAttributes(Map attribute SpanLimits.getDefault(), null, attributesMap, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1472,7 +1472,7 @@ private SdkSpan createTestRootSpan() { SpanLimits.getDefault(), SpanId.getInvalid(), null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1482,7 +1482,7 @@ private SdkSpan createTestSpan(SpanKind kind) { SpanLimits.getDefault(), parentSpanId, null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1492,7 +1492,7 @@ private SdkSpan createTestSpan(SpanLimits config) { config, parentSpanId, null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1513,8 +1513,8 @@ private SdkSpan createTestSpan( kind, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), config, @@ -1601,8 +1601,8 @@ void testAsSpanData() { kind, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), spanLimits, @@ -1611,7 +1611,7 @@ void testAsSpanData() { clock, resource, attributesWithCapacity, - Collections.singletonList(link1), + singletonList(link1), 1, 0); long startEpochNanos = clock.now(); @@ -1638,7 +1638,7 @@ void testAsSpanData() { result, attributesWithCapacity, events, - Collections.singletonList(link1), + singletonList(link1), name, startEpochNanos, endEpochNanos, From a8a950804c8ea54bd853790d31a26846b2789fb7 Mon Sep 17 00:00:00 2001 From: jwatson Date: Mon, 22 Sep 2025 13:30:43 -0700 Subject: [PATCH 4/4] spotless --- .../opentelemetry/sdk/trace/SdkSpanTest.java | 73 +++++++++---------- 1 file changed, 36 insertions(+), 37 deletions(-) diff --git a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java index f43bee950e9..c9d546f5486 100644 --- a/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java +++ b/sdk/trace/src/test/java/io/opentelemetry/sdk/trace/SdkSpanTest.java @@ -162,14 +162,14 @@ void onEnding_spanStillMutable() { AtomicBoolean endedStateInProcessor = new AtomicBoolean(); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - assertThat(sp.hasEnded()).isFalse(); - sp.end(); // should have no effect, nested end should be detected - endedStateInProcessor.set(sp.hasEnded()); - sp.setAttribute(dummyAttrib, "bar"); - return null; - }) + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + assertThat(sp.hasEnded()).isFalse(); + sp.end(); // should have no effect, nested end should be detected + endedStateInProcessor.set(sp.hasEnded()); + sp.setAttribute(dummyAttrib, "bar"); + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -188,21 +188,21 @@ void onEnding_concurrentModificationsPrevented() { AttributeKey concurrentAttrib = AttributeKey.stringKey("concurrent_foo"); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - Thread concurrent = - new Thread( - () -> { - sp.setAttribute(concurrentAttrib, "concurrent_bar"); - }); - concurrent.start(); - concurrent.join(); + Thread concurrent = + new Thread( + () -> { + sp.setAttribute(concurrentAttrib, "concurrent_bar"); + }); + concurrent.start(); + concurrent.join(); - sp.setAttribute(syncAttrib, "sync_bar"); + sp.setAttribute(syncAttrib, "sync_bar"); - return null; - }) + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -218,13 +218,13 @@ void onEnding_latencyPinned() { AtomicLong spanLatencyInProcessor = new AtomicLong(); doAnswer( - invocation -> { - ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); + invocation -> { + ReadWriteSpan sp = invocation.getArgument(0, ReadWriteSpan.class); - testClock.advance(Duration.ofSeconds(100)); - spanLatencyInProcessor.set(sp.getLatencyNanos()); - return null; - }) + testClock.advance(Duration.ofSeconds(100)); + spanLatencyInProcessor.set(sp.getLatencyNanos()); + return null; + }) .when(spanProcessor) .onEnding(any()); @@ -307,7 +307,7 @@ void toSpanData_immutableEvents() { SpanData spanData = span.toSpanData(); assertThatThrownBy( - () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) + () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) .isInstanceOf(UnsupportedOperationException.class); } @@ -318,7 +318,7 @@ void toSpanData_immutableEvents_ended() { SpanData spanData = span.toSpanData(); assertThatThrownBy( - () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) + () -> spanData.getEvents().add(EventData.create(1000, "test", Attributes.empty()))) .isInstanceOf(UnsupportedOperationException.class); } @@ -468,7 +468,7 @@ void getAttributes_Empty() { @Test @SuppressWarnings("deprecation") - // Testing deprecated code + // Testing deprecated code void getInstrumentationLibraryInfo() { SdkSpan span = createTestSpan(SpanKind.CLIENT); try { @@ -1373,8 +1373,8 @@ void onStartOnEndNotRequired() { SpanKind.INTERNAL, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), spanLimits, @@ -1404,8 +1404,7 @@ void setStatus(Consumer spanConsumer, StatusData expectedSpanData) { private static Stream setStatusArgs() { return Stream.of( // Default status is UNSET - Arguments.of(spanConsumer(span -> { - }), StatusData.unset()), + Arguments.of(spanConsumer(span -> {}), StatusData.unset()), // Simple cases Arguments.of(spanConsumer(span -> span.setStatus(StatusCode.OK)), StatusData.ok()), Arguments.of(spanConsumer(span -> span.setStatus(StatusCode.ERROR)), StatusData.error()), @@ -1513,8 +1512,8 @@ private SdkSpan createTestSpan( kind, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), config, @@ -1601,8 +1600,8 @@ void testAsSpanData() { kind, parentSpanId != null ? Span.wrap( - SpanContext.create( - traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) + SpanContext.create( + traceId, parentSpanId, TraceFlags.getDefault(), TraceState.getDefault())) : Span.getInvalid(), Context.root(), spanLimits,