Rename unused try-with-resources scope variables
MODIFY
benchmark-integration/jetty-perftest/src/main/java/io/opentelemetry/perftest/Worker.java
benchmark-integration/jetty-perftest/src/main/java/io/opentelemetry/perftest/Worker.java
@@ -18,7 +18,7 @@ public final class Worker {
/** Simulate work for the give number of milliseconds. */
public static void doWork(long workTimeMillis) {
Span span = tracer.spanBuilder("work").startSpan();
- try (Scope scope = span.makeCurrent()) {
+ try (Scope ignored = span.makeCurrent()) {
if (span != null) {
span.setAttribute("work-time", workTimeMillis);
span.setAttribute("info", "interesting stuff");

MODIFY
benchmark-integration/jetty-perftest/src/main/java/io/opentelemetry/perftest/jetty/JettyPerftest.java
benchmark-integration/jetty-perftest/src/main/java/io/opentelemetry/perftest/jetty/JettyPerftest.java
@@ -66,12 +66,10 @@ public final class JettyPerftest {
private static void scheduleWork(long workTimeMillis) {
Span span = tracer.spanBuilder("work").startSpan();
- try (Scope scope = span.makeCurrent()) {
- if (span != null) {
+ try (Scope ignored = span.makeCurrent()) {
span.setAttribute("work-time", workTimeMillis);
span.setAttribute("info", "interesting stuff");
span.setAttribute("additionalInfo", "interesting stuff");
- }
if (workTimeMillis > 0) {
Worker.doWork(workTimeMillis);
}

MODIFY
instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java
instrumentation/apache-httpasyncclient-4.1/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/apachehttpasyncclient/ApacheHttpAsyncClientInstrumentation.java
@@ -181,7 +181,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
if (parentContext == null) {
completeDelegate(result);
} else {
- try (Scope scope = parentContext.makeCurrent()) {
+ try (Scope ignored = parentContext.makeCurrent()) {
completeDelegate(result);
}
}
@@ -195,7 +195,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
if (parentContext == null) {
failDelegate(ex);
} else {
- try (Scope scope = parentContext.makeCurrent()) {
+ try (Scope ignored = parentContext.makeCurrent()) {
failDelegate(ex);
}
}
@@ -209,7 +209,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
if (parentContext == null) {
cancelDelegate();
} else {
- try (Scope scope = parentContext.makeCurrent()) {
+ try (Scope ignored = parentContext.makeCurrent()) {
cancelDelegate();
}
}

MODIFY
instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/SubscriberWrapper.java
instrumentation/armeria-1.3/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/armeria/v1_3/SubscriberWrapper.java
@@ -29,28 +29,28 @@ public class SubscriberWrapper implements Subscriber<Object> {
@Override
public void onSubscribe(Subscription subscription) {
- try (Scope ignore = context.makeCurrent()) {
+ try (Scope ignored = context.makeCurrent()) {
delegate.onSubscribe(subscription);
}
}
@Override
public void onNext(Object o) {
- try (Scope ignore = context.makeCurrent()) {
+ try (Scope ignored = context.makeCurrent()) {
delegate.onNext(o);
}
}
@Override
public void onError(Throwable throwable) {
- try (Scope ignore = context.makeCurrent()) {
+ try (Scope ignored = context.makeCurrent()) {
delegate.onError(throwable);
}
}
@Override
public void onComplete() {
- try (Scope ignore = context.makeCurrent()) {
+ try (Scope ignored = context.makeCurrent()) {
delegate.onComplete();
}
}

MODIFY
instrumentation/play-ws/play-ws-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/v1_0/AsyncHandlerWrapper.java
instrumentation/play-ws/play-ws-1.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/playws/v1_0/AsyncHandlerWrapper.java
@@ -51,7 +51,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
public Object onCompleted() throws Exception {
tracer().end(context, builder.build());
- try (Scope scope = parentContext.makeCurrent()) {
+ try (Scope ignored = parentContext.makeCurrent()) {
return delegate.onCompleted();
}
}
@@ -60,7 +60,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
public void onThrowable(Throwable throwable) {
tracer().endExceptionally(context, throwable);
- try (Scope scope = parentContext.makeCurrent()) {
+ try (Scope ignored = parentContext.makeCurrent()) {
delegate.onThrowable(throwable);
}
}

MODIFY
instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/TracedDelegatingConsumer.java
instrumentation/rabbitmq-2.7/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/rabbitmq/TracedDelegatingConsumer.java
@@ -64,7 +64,7 @@ public class TracedDelegatingConsumer implements Consumer {
throws IOException {
Context context = tracer().startDeliverySpan(queue, envelope, properties, body);
- try (Scope scope = context.makeCurrent()) {
+ try (Scope ignored = context.makeCurrent()) {
// Call delegate.
delegate.handleDelivery(consumerTag, envelope, properties, body);
tracer().end(context);

MODIFY
instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/AdviceUtils.java
instrumentation/spring/spring-webflux-5.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/spring/webflux/server/AdviceUtils.java
@@ -102,14 +102,14 @@ public class AdviceUtils {
@Override
public void onSubscribe(Subscription subscription) {
this.subscription = subscription;
- try (Scope scope = otelContext.makeCurrent()) {
+ try (Scope ignored = otelContext.makeCurrent()) {
subscriber.onSubscribe(this);
}
}
@Override
public void onNext(T t) {
- try (Scope scope = otelContext.makeCurrent()) {
+ try (Scope ignored = otelContext.makeCurrent()) {
subscriber.onNext(t);
}
}

MODIFY
instrumentation/vertx-web-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/ExceptionHandlerWrapper.java
instrumentation/vertx-web-3.0/javaagent/src/main/java/io/opentelemetry/javaagent/instrumentation/vertx/client/ExceptionHandlerWrapper.java
@@ -36,7 +36,7 @@ public class ExceptionHandlerWrapper implements Handler<Throwable> {
tracer().endExceptionally(contexts.context, throwable);
- try (Scope scope = contexts.parentContext.makeCurrent()) {
+ try (Scope ignored = contexts.parentContext.makeCurrent()) {
callHandler(throwable);
}
}

Rename unused try-with-resources scope variables (#3201)