Skip to content

Commit

Permalink
fix(deps): update errorproneversion to v2.27.0 (main) (minor) (#11238)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Lauri Tulmin <[email protected]>
  • Loading branch information
renovate[bot] and laurit authored Apr 28, 2024
1 parent 528c976 commit 22adefc
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion dependencyManagement/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,13 @@ class MethodSpanAttributesExtractorTest {
@BeforeEach
void setup() {
lenient()
.doAnswer(
.when(cache.computeIfAbsent(any(), any()))
.thenAnswer(
invocation -> {
Method m = invocation.getArgument(0);
Function<Method, AttributeBindings> fn = invocation.getArgument(1);
return fn.apply(m);
})
.when(cache)
.computeIfAbsent(any(), any());
});
}

@Test
Expand Down Expand Up @@ -123,6 +122,7 @@ void doesNotExtractAttributeForMethodWithNullArgument() {
}

@Test
@SuppressWarnings("MockitoDoSetup")
void appliesCachedBindings() {
AttributeBindings bindings = mock(AttributeBindings.class);
when(bindings.isEmpty()).thenReturn(false);
Expand All @@ -143,6 +143,7 @@ void appliesCachedBindings() {
}

@Test
@SuppressWarnings("MockitoDoSetup")
void doesNotApplyCachedEmptyBindings() {
AttributeBindings bindings = mock(AttributeBindings.class);
when(bindings.isEmpty()).thenReturn(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<Object> underTest = CodeSpanNameExtractor.create(getter);

Expand All @@ -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<Object> underTest = CodeSpanNameExtractor.create(getter);

Expand All @@ -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<Object> underTest = CodeSpanNameExtractor.create(getter);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -43,10 +43,9 @@ void runTest(
HttpCommonAttributesGetter<String, String> getter,
AttributesExtractor<String, String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -39,7 +39,7 @@ class ForwardedHostAddressAndPortExtractorTest {
@ArgumentsSource(ForwardedArgs.class)
void shouldParseForwarded(
List<String> 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);
Expand Down Expand Up @@ -84,8 +84,8 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo
@ArgumentsSource(HostArgs.class)
void shouldParseForwardedHost(
List<String> 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);
Expand All @@ -98,9 +98,9 @@ void shouldParseForwardedHost(
@ArgumentsSource(HostArgs.class)
void shouldParsePseudoAuthority(
List<String> 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);
Expand All @@ -113,10 +113,10 @@ void shouldParsePseudoAuthority(
@ArgumentsSource(HostArgs.class)
void shouldParseHost(
List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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<String> values, String expectedScheme) {
doReturn(values).when(getter).getHttpRequestHeader(REQUEST, "forwarded");
when(getter.getHttpRequestHeader(REQUEST, "forwarded")).thenReturn(values);
assertThat(underTest.apply(REQUEST)).isEqualTo(expectedScheme);
}

Expand Down Expand Up @@ -74,8 +74,8 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo
@ParameterizedTest
@ArgumentsSource(ForwardedProtoHeaderValues.class)
void parseForwardedProtoHeader(List<String> 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);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -36,7 +36,7 @@ class HttpServerAddressAndPortExtractorTest {
@ParameterizedTest
@ArgumentsSource(ForwardedArgs.class)
void shouldParseForwarded(List<String> 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");
Expand Down Expand Up @@ -92,8 +92,8 @@ public Stream<? extends Arguments> provideArguments(ExtensionContext extensionCo
@ParameterizedTest
@ArgumentsSource(ForwardedForArgs.class)
void shouldParseForwardedFor(List<String> 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ void shouldPrependBaseUrl(String baseUrl) {
}

@Test
@SuppressWarnings("MockitoDoSetup")
void shouldPrependRemoteAddress() {
when(config.baseUrl()).thenReturn("/");
when(config.uri()).thenReturn("/docs");
Expand All @@ -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");
Expand Down

0 comments on commit 22adefc

Please sign in to comment.