From 22adefcbd06b8096fbfc62c32f173fee9729c8d8 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Sun, 28 Apr 2024 13:56:53 +0300 Subject: [PATCH] fix(deps): update errorproneversion to v2.27.0 (main) (minor) (#11238) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Lauri Tulmin --- dependencyManagement/build.gradle.kts | 2 +- .../MethodSpanAttributesExtractorTest.java | 9 ++++---- .../code/CodeSpanNameExtractorTest.java | 14 ++++++------ ...tpExperimentalAttributesExtractorTest.java | 9 ++++---- ...wardedHostAddressAndPortExtractorTest.java | 22 +++++++++---------- .../http/ForwardedUrlSchemeProviderTest.java | 10 ++++----- ...HttpServerAddressAndPortExtractorTest.java | 8 +++---- .../reactive/v1_0/HibernateReactiveTest.java | 8 +++---- .../v1_0/FailedRequestWithUrlMakerTest.java | 2 ++ 9 files changed, 43 insertions(+), 41 deletions(-) diff --git a/dependencyManagement/build.gradle.kts b/dependencyManagement/build.gradle.kts index 6ab225facc0f..34678d3368c4 100644 --- a/dependencyManagement/build.gradle.kts +++ b/dependencyManagement/build.gradle.kts @@ -40,7 +40,7 @@ val DEPENDENCY_BOMS = listOf( val autoServiceVersion = "1.1.1" val autoValueVersion = "1.10.4" -val errorProneVersion = "2.26.1" +val errorProneVersion = "2.27.0" val byteBuddyVersion = "1.14.14" val asmVersion = "9.7" val jmhVersion = "1.37" diff --git a/instrumentation-annotations-support/src/test/java/io/opentelemetry/instrumentation/api/annotation/support/MethodSpanAttributesExtractorTest.java b/instrumentation-annotations-support/src/test/java/io/opentelemetry/instrumentation/api/annotation/support/MethodSpanAttributesExtractorTest.java index d21bdac92fd1..8e5a7af6d4ed 100644 --- a/instrumentation-annotations-support/src/test/java/io/opentelemetry/instrumentation/api/annotation/support/MethodSpanAttributesExtractorTest.java +++ b/instrumentation-annotations-support/src/test/java/io/opentelemetry/instrumentation/api/annotation/support/MethodSpanAttributesExtractorTest.java @@ -41,14 +41,13 @@ class MethodSpanAttributesExtractorTest { @BeforeEach void setup() { lenient() - .doAnswer( + .when(cache.computeIfAbsent(any(), any())) + .thenAnswer( invocation -> { Method m = invocation.getArgument(0); Function fn = invocation.getArgument(1); return fn.apply(m); - }) - .when(cache) - .computeIfAbsent(any(), any()); + }); } @Test @@ -123,6 +122,7 @@ void doesNotExtractAttributeForMethodWithNullArgument() { } @Test + @SuppressWarnings("MockitoDoSetup") void appliesCachedBindings() { AttributeBindings bindings = mock(AttributeBindings.class); when(bindings.isEmpty()).thenReturn(false); @@ -143,6 +143,7 @@ void appliesCachedBindings() { } @Test + @SuppressWarnings("MockitoDoSetup") void doesNotApplyCachedEmptyBindings() { AttributeBindings bindings = mock(AttributeBindings.class); when(bindings.isEmpty()).thenReturn(true); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/code/CodeSpanNameExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/code/CodeSpanNameExtractorTest.java index b0a965085465..fba84a21d697 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/code/CodeSpanNameExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/code/CodeSpanNameExtractorTest.java @@ -6,7 +6,7 @@ package io.opentelemetry.instrumentation.api.incubator.semconv.code; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; import io.opentelemetry.instrumentation.api.instrumenter.SpanNameExtractor; import org.junit.jupiter.api.Test; @@ -23,8 +23,8 @@ void shouldExtractFullSpanName() { // given Object request = new Object(); - doReturn(TestClass.class).when(getter).getCodeClass(request); - doReturn("doSomething").when(getter).getMethodName(request); + when(getter.getCodeClass(request)).thenAnswer(invocation -> TestClass.class); + when(getter.getMethodName(request)).thenReturn("doSomething"); SpanNameExtractor underTest = CodeSpanNameExtractor.create(getter); @@ -41,8 +41,8 @@ void shouldExtractFullSpanNameForAnonymousClass() { AnonymousBaseClass anon = new AnonymousBaseClass() {}; Object request = new Object(); - doReturn(anon.getClass()).when(getter).getCodeClass(request); - doReturn("doSomething").when(getter).getMethodName(request); + when(getter.getCodeClass(request)).thenAnswer(invocation -> anon.getClass()); + when(getter.getMethodName(request)).thenReturn("doSomething"); SpanNameExtractor underTest = CodeSpanNameExtractor.create(getter); @@ -59,8 +59,8 @@ void shouldExtractFullSpanNameForLambda() { Runnable lambda = () -> {}; Object request = new Object(); - doReturn(lambda.getClass()).when(getter).getCodeClass(request); - doReturn("doSomething").when(getter).getMethodName(request); + when(getter.getCodeClass(request)).thenAnswer(invocation -> lambda.getClass()); + when(getter.getMethodName(request)).thenReturn("doSomething"); SpanNameExtractor underTest = CodeSpanNameExtractor.create(getter); diff --git a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/http/HttpExperimentalAttributesExtractorTest.java b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/http/HttpExperimentalAttributesExtractorTest.java index 29d3f92b0cc1..5a9fdf112ded 100644 --- a/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/http/HttpExperimentalAttributesExtractorTest.java +++ b/instrumentation-api-incubator/src/test/java/io/opentelemetry/instrumentation/api/incubator/semconv/http/HttpExperimentalAttributesExtractorTest.java @@ -8,7 +8,7 @@ import static io.opentelemetry.sdk.testing.assertj.OpenTelemetryAssertions.assertThat; import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.entry; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; import io.opentelemetry.api.common.Attributes; import io.opentelemetry.api.common.AttributesBuilder; @@ -43,10 +43,9 @@ void runTest( HttpCommonAttributesGetter getter, AttributesExtractor extractor) { - doReturn(singletonList("123")).when(getter).getHttpRequestHeader("request", "content-length"); - doReturn(singletonList("42")) - .when(getter) - .getHttpResponseHeader("request", "response", "content-length"); + when(getter.getHttpRequestHeader("request", "content-length")).thenReturn(singletonList("123")); + when(getter.getHttpResponseHeader("request", "response", "content-length")) + .thenReturn(singletonList("42")); AttributesBuilder attributes = Attributes.builder(); extractor.onStart(attributes, Context.root(), "request"); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedHostAddressAndPortExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedHostAddressAndPortExtractorTest.java index 5a9dfe193f26..e738bdec5408 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedHostAddressAndPortExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedHostAddressAndPortExtractorTest.java @@ -10,7 +10,7 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.params.provider.Arguments.arguments; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; import io.opentelemetry.instrumentation.api.semconv.network.internal.AddressAndPort; import java.util.List; @@ -39,7 +39,7 @@ class ForwardedHostAddressAndPortExtractorTest { @ArgumentsSource(ForwardedArgs.class) void shouldParseForwarded( List headers, @Nullable String expectedAddress, @Nullable Integer expectedPort) { - doReturn(headers).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, REQUEST); @@ -84,8 +84,8 @@ public Stream provideArguments(ExtensionContext extensionCo @ArgumentsSource(HostArgs.class) void shouldParseForwardedHost( List headers, @Nullable String expectedAddress, @Nullable Integer expectedPort) { - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); - doReturn(headers).when(getter).getHttpRequestHeader(REQUEST, "x-forwarded-host"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, "x-forwarded-host")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, REQUEST); @@ -98,9 +98,9 @@ void shouldParseForwardedHost( @ArgumentsSource(HostArgs.class) void shouldParsePseudoAuthority( List headers, @Nullable String expectedAddress, @Nullable Integer expectedPort) { - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "x-forwarded-host"); - doReturn(headers).when(getter).getHttpRequestHeader(REQUEST, ":authority"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, "x-forwarded-host")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, ":authority")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, REQUEST); @@ -113,10 +113,10 @@ void shouldParsePseudoAuthority( @ArgumentsSource(HostArgs.class) void shouldParseHost( List headers, @Nullable String expectedAddress, @Nullable Integer expectedPort) { - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "x-forwarded-host"); - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, ":authority"); - doReturn(headers).when(getter).getHttpRequestHeader(REQUEST, "host"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, "x-forwarded-host")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, ":authority")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, "host")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, REQUEST); diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedUrlSchemeProviderTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedUrlSchemeProviderTest.java index 268fa452237d..524603fc698c 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedUrlSchemeProviderTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/ForwardedUrlSchemeProviderTest.java @@ -12,7 +12,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.eq; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; import java.util.List; import java.util.stream.Stream; @@ -38,14 +38,14 @@ class ForwardedUrlSchemeProviderTest { @Test void noHeaders() { - doReturn(emptyList()).when(getter).getHttpRequestHeader(eq(REQUEST), any()); + when(getter.getHttpRequestHeader(eq(REQUEST), any())).thenReturn(emptyList()); assertThat(underTest.apply(REQUEST)).isNull(); } @ParameterizedTest @ArgumentsSource(ForwardedHeaderValues.class) void parseForwardedHeader(List values, String expectedScheme) { - doReturn(values).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(values); assertThat(underTest.apply(REQUEST)).isEqualTo(expectedScheme); } @@ -74,8 +74,8 @@ public Stream provideArguments(ExtensionContext extensionCo @ParameterizedTest @ArgumentsSource(ForwardedProtoHeaderValues.class) void parseForwardedProtoHeader(List values, String expectedScheme) { - doReturn(emptyList()).when(getter).getHttpRequestHeader(REQUEST, "forwarded"); - doReturn(values).when(getter).getHttpRequestHeader(REQUEST, "x-forwarded-proto"); + when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader(REQUEST, "x-forwarded-proto")).thenReturn(values); assertThat(underTest.apply(REQUEST)).isEqualTo(expectedScheme); } diff --git a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAddressAndPortExtractorTest.java b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAddressAndPortExtractorTest.java index 6388c04d4e3b..7589f89ed8ff 100644 --- a/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAddressAndPortExtractorTest.java +++ b/instrumentation-api/src/test/java/io/opentelemetry/instrumentation/api/semconv/http/HttpServerAddressAndPortExtractorTest.java @@ -10,7 +10,7 @@ import static java.util.Collections.singletonList; import static org.assertj.core.api.Assertions.assertThat; import static org.junit.jupiter.params.provider.Arguments.arguments; -import static org.mockito.Mockito.doReturn; +import static org.mockito.Mockito.when; import io.opentelemetry.instrumentation.api.semconv.network.internal.AddressAndPort; import java.util.List; @@ -36,7 +36,7 @@ class HttpServerAddressAndPortExtractorTest { @ParameterizedTest @ArgumentsSource(ForwardedArgs.class) void shouldParseForwarded(List headers, @Nullable String expectedAddress) { - doReturn(headers).when(getter).getHttpRequestHeader("request", "forwarded"); + when(getter.getHttpRequestHeader("request", "forwarded")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, "request"); @@ -92,8 +92,8 @@ public Stream provideArguments(ExtensionContext extensionCo @ParameterizedTest @ArgumentsSource(ForwardedForArgs.class) void shouldParseForwardedFor(List headers, @Nullable String expectedAddress) { - doReturn(emptyList()).when(getter).getHttpRequestHeader("request", "forwarded"); - doReturn(headers).when(getter).getHttpRequestHeader("request", "x-forwarded-for"); + when(getter.getHttpRequestHeader("request", "forwarded")).thenReturn(emptyList()); + when(getter.getHttpRequestHeader("request", "x-forwarded-for")).thenReturn(headers); AddressAndPort sink = new AddressAndPort(); underTest.extract(sink, "request"); diff --git a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java index fda567f2bbd8..c9a21d0dfde0 100644 --- a/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java +++ b/instrumentation/hibernate/hibernate-reactive-1.0/javaagent/src/hibernateReactive1Test/java/io/opentelemetry/javaagent/instrumentation/hibernate/reactive/v1_0/HibernateReactiveTest.java @@ -148,7 +148,7 @@ void testStage() throws Exception { .find(Value.class, 1L) .thenAccept(value -> testing.runWithSpan("callback", () -> {})); }) - .whenComplete((value, throwable) -> complete(result, value, throwable)))); + .whenComplete((value, throwable) -> complete(result, null, throwable)))); result.get(30, TimeUnit.SECONDS); assertTrace(); @@ -173,7 +173,7 @@ void testStageWithStatelessSession() throws Exception { .get(Value.class, 1L) .thenAccept(value -> testing.runWithSpan("callback", () -> {})); }) - .whenComplete((value, throwable) -> complete(result, value, throwable)))); + .whenComplete((value, throwable) -> complete(result, null, throwable)))); result.get(30, TimeUnit.SECONDS); assertTrace(); @@ -198,7 +198,7 @@ void testStageSessionWithTransaction() throws Exception { .withTransaction(transaction -> session.find(Value.class, 1L)) .thenAccept(value -> testing.runWithSpan("callback", () -> {})); }) - .whenComplete((value, throwable) -> complete(result, value, throwable)))); + .whenComplete((value, throwable) -> complete(result, null, throwable)))); result.get(30, TimeUnit.SECONDS); assertTrace(); @@ -223,7 +223,7 @@ void testStageStatelessSessionWithTransaction() throws Exception { .withTransaction(transaction -> session.get(Value.class, 1L)) .thenAccept(value -> testing.runWithSpan("callback", () -> {})); }) - .whenComplete((value, throwable) -> complete(result, value, throwable)))); + .whenComplete((value, throwable) -> complete(result, null, throwable)))); result.get(30, TimeUnit.SECONDS); assertTrace(); diff --git a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/FailedRequestWithUrlMakerTest.java b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/FailedRequestWithUrlMakerTest.java index 25ccb781c950..f5fe58794b2b 100644 --- a/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/FailedRequestWithUrlMakerTest.java +++ b/instrumentation/reactor/reactor-netty/reactor-netty-1.0/javaagent-unit-tests/src/test/java/io/opentelemetry/javaagent/instrumentation/reactornetty/v1_0/FailedRequestWithUrlMakerTest.java @@ -53,6 +53,7 @@ void shouldPrependBaseUrl(String baseUrl) { } @Test + @SuppressWarnings("MockitoDoSetup") void shouldPrependRemoteAddress() { when(config.baseUrl()).thenReturn("/"); when(config.uri()).thenReturn("/docs"); @@ -68,6 +69,7 @@ void shouldPrependRemoteAddress() { @ParameterizedTest @ArgumentsSource(DefaultPortsArguments.class) + @SuppressWarnings("MockitoDoSetup") void shouldSkipDefaultPorts(int port, boolean isSecure) { when(config.baseUrl()).thenReturn("/"); when(config.uri()).thenReturn("/docs");