Fix most lint warnings. (#5180)

* Fix most lint warnings.

* Fix test
This commit is contained in:
Anuraag Agrawal 2022-01-20 18:28:45 +09:00 committed by GitHub
parent d017d5f18a
commit e6e2190f68
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 19 additions and 35 deletions

0
.attach_pid876 Normal file
View File

View File

@ -74,7 +74,10 @@ class MessagingAttributesExtractorTest {
entry(SemanticAttributes.MESSAGING_MESSAGE_PAYLOAD_COMPRESSED_SIZE_BYTES, 10L));
expectedEntries.add(entry(SemanticAttributes.MESSAGING_OPERATION, operation.operationName()));
assertThat(startAttributes.build()).containsOnly(expectedEntries.toArray(new MapEntry[0]));
@SuppressWarnings({"unchecked", "rawtypes"})
MapEntry<? extends AttributeKey<?>, ?>[] expectedEntriesArr =
expectedEntries.toArray(new MapEntry[0]);
assertThat(startAttributes.build()).containsOnly(expectedEntriesArr);
assertThat(endAttributes.build())
.containsOnly(entry(SemanticAttributes.MESSAGING_MESSAGE_ID, "42"));

View File

@ -10,7 +10,7 @@ import java.util.concurrent.Callable;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
public class AkkaAsyncChild extends ForkJoinTask implements Runnable, Callable {
public class AkkaAsyncChild extends ForkJoinTask<Object> implements Runnable, Callable<Object> {
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
private final AtomicBoolean blockThread;

View File

@ -20,7 +20,7 @@ import org.junit.jupiter.api.extension.RegisterExtension;
class TracingRequestHandlerTest {
private static Response<SendMessageResult> response(Request request) {
private static Response<SendMessageResult> response(Request<?> request) {
return new Response<>(new SendMessageResult(), new HttpResponse(request, new HttpGet()));
}

View File

@ -63,7 +63,7 @@ public class FieldMapperTest {
MethodHandleFactory methodHandleFactory = new MethodHandleFactory();
Serializer serializer = mock(Serializer.class);
FieldMapper underTest = new FieldMapper(serializer, methodHandleFactory);
Map<String, Collection<WriteRequest>> items = new HashMap();
Map<String, Collection<WriteRequest>> items = new HashMap<>();
BatchWriteItemRequest sdkRequest = BatchWriteItemRequest.builder().requestItems(items).build();
given(serializer.serialize(items)).willReturn("firstTable,secondTable");
@ -83,7 +83,7 @@ public class FieldMapperTest {
MethodHandleFactory methodHandleFactory = new MethodHandleFactory();
Serializer serializer = mock(Serializer.class);
FieldMapper underTest = new FieldMapper(serializer, methodHandleFactory);
Map<String, Collection<ItemCollectionMetrics>> items = new HashMap();
Map<String, Collection<ItemCollectionMetrics>> items = new HashMap<>();
BatchWriteItemResponse sdkResponse =
BatchWriteItemResponse.builder()
.consumedCapacity(ConsumedCapacity.builder().build())

View File

@ -10,7 +10,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.ForkJoinTask;
import java.util.concurrent.atomic.AtomicBoolean;
public class JavaAsyncChild extends ForkJoinTask implements Runnable, Callable {
public class JavaAsyncChild extends ForkJoinTask<Object> implements Runnable, Callable<Object> {
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
private final AtomicBoolean blockThread;

View File

@ -29,6 +29,8 @@ dependencies {
testImplementation("org.springframework.cloud:spring-cloud-sleuth-core:2.2.4.RELEASE") {
isTransitive = false
}
// For some annotations used by sleuth
testCompileOnly("org.springframework:spring-core:4.3.30.RELEASE")
}
tasks {

View File

@ -12,9 +12,9 @@ import io.opentelemetry.api.GlobalOpenTelemetry;
import io.opentelemetry.sdk.OpenTelemetrySdk;
import io.opentelemetry.sdk.metrics.SdkMeterProvider;
import io.opentelemetry.sdk.metrics.data.MetricData;
import io.opentelemetry.sdk.metrics.testing.InMemoryMetricReader;
import io.opentelemetry.sdk.testing.assertj.MetricAssertions;
import io.opentelemetry.sdk.testing.assertj.MetricDataAssert;
import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader;
import java.util.Collection;
import java.util.function.Consumer;
import org.junit.jupiter.api.AfterAll;
@ -37,7 +37,8 @@ class AbstractMetricsTest {
GlobalOpenTelemetry.resetForTest();
}
protected void waitAndAssertMetrics(Consumer<MetricDataAssert>... assertions) {
@SafeVarargs
protected final void waitAndAssertMetrics(Consumer<MetricDataAssert>... assertions) {
await()
.untilAsserted(
() -> {

View File

@ -10,7 +10,7 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicBoolean;
import scala.concurrent.forkjoin.ForkJoinTask;
public class ScalaAsyncChild extends ForkJoinTask implements Runnable, Callable {
public class ScalaAsyncChild extends ForkJoinTask<Object> implements Runnable, Callable<Object> {
private static final Tracer tracer = GlobalOpenTelemetry.getTracer("test");
private final AtomicBoolean blockThread;

View File

@ -15,7 +15,9 @@ dependencies {
library("io.vertx:vertx-core:3.0.0")
compileOnly("io.vertx:vertx-codegen:3.0.0")
testCompileOnly("io.vertx:vertx-codegen:3.0.0")
compileOnly("io.vertx:vertx-docgen:3.0.0")
testCompileOnly("io.vertx:vertx-docgen:3.0.0")
compileOnly("com.google.auto.value:auto-value-annotations")
annotationProcessor("com.google.auto.value:auto-value")

View File

@ -15,6 +15,7 @@ dependencies {
library("io.vertx:vertx-core:4.0.0")
compileOnly("io.vertx:vertx-codegen:4.0.0")
testCompileOnly("io.vertx:vertx-codegen:4.0.0")
implementation(project(":instrumentation:vertx:vertx-http-client:vertx-http-client-common:javaagent"))

View File

@ -53,19 +53,4 @@ public final class CallDepth {
public int decrementAndGet() {
return --this.depth;
}
/**
* Get current call depth. This method may be used by vendor distributions to extend existing
* instrumentations.
*/
@Deprecated
public int get() {
return depth;
}
/** Reset the call depth to its initial value. */
@Deprecated
public void reset() {
depth = 0;
}
}

View File

@ -19,17 +19,6 @@ class CallDepthTest {
assertThat(CallDepth.forClass(String.class).getAndIncrement()).isOne();
assertThat(CallDepth.forClass(Integer.class).getAndIncrement()).isOne();
CallDepth.forClass(String.class).reset();
assertThat(CallDepth.forClass(Integer.class).getAndIncrement()).isEqualTo(2);
CallDepth.forClass(Integer.class).reset();
assertThat(CallDepth.forClass(String.class).getAndIncrement()).isZero();
assertThat(CallDepth.forClass(Integer.class).getAndIncrement()).isZero();
assertThat(CallDepth.forClass(String.class).getAndIncrement()).isOne();
assertThat(CallDepth.forClass(Integer.class).getAndIncrement()).isOne();
assertThat(CallDepth.forClass(String.class).decrementAndGet()).isOne();
assertThat(CallDepth.forClass(Integer.class).decrementAndGet()).isOne();

View File

@ -39,6 +39,7 @@ dependencies {
annotationProcessor("com.google.auto.service:auto-service")
compileOnly("com.google.auto.service:auto-service-annotations")
testCompileOnly("com.google.auto.service:auto-service-annotations")
// Used by byte-buddy but not brought in as a transitive dependency.
compileOnly("com.google.code.findbugs:annotations")