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 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" 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..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 @@ -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, @@ -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(), @@ -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")); @@ -1462,7 +1461,7 @@ private SdkSpan createTestSpanWithAttributes(Map attribute SpanLimits.getDefault(), null, attributesMap, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1472,7 +1471,7 @@ private SdkSpan createTestRootSpan() { SpanLimits.getDefault(), SpanId.getInvalid(), null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1482,7 +1481,7 @@ private SdkSpan createTestSpan(SpanKind kind) { SpanLimits.getDefault(), parentSpanId, null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1492,7 +1491,7 @@ private SdkSpan createTestSpan(SpanLimits config) { config, parentSpanId, null, - Collections.singletonList(link), + singletonList(link), ExceptionAttributeResolver.getDefault()); } @@ -1611,7 +1610,7 @@ void testAsSpanData() { clock, resource, attributesWithCapacity, - Collections.singletonList(link1), + singletonList(link1), 1, 0); long startEpochNanos = clock.now(); @@ -1638,7 +1637,7 @@ void testAsSpanData() { result, attributesWithCapacity, events, - Collections.singletonList(link1), + singletonList(link1), name, startEpochNanos, endEpochNanos,