Rename unused try-with-resources scope variables (#3201)
This commit is contained in:
parent
cefaecab3f
commit
f9dcd03b4b
|
@ -18,7 +18,7 @@ public final class Worker {
|
||||||
/** Simulate work for the give number of milliseconds. */
|
/** Simulate work for the give number of milliseconds. */
|
||||||
public static void doWork(long workTimeMillis) {
|
public static void doWork(long workTimeMillis) {
|
||||||
Span span = tracer.spanBuilder("work").startSpan();
|
Span span = tracer.spanBuilder("work").startSpan();
|
||||||
try (Scope scope = span.makeCurrent()) {
|
try (Scope ignored = span.makeCurrent()) {
|
||||||
if (span != null) {
|
if (span != null) {
|
||||||
span.setAttribute("work-time", workTimeMillis);
|
span.setAttribute("work-time", workTimeMillis);
|
||||||
span.setAttribute("info", "interesting stuff");
|
span.setAttribute("info", "interesting stuff");
|
||||||
|
|
|
@ -66,12 +66,10 @@ public final class JettyPerftest {
|
||||||
|
|
||||||
private static void scheduleWork(long workTimeMillis) {
|
private static void scheduleWork(long workTimeMillis) {
|
||||||
Span span = tracer.spanBuilder("work").startSpan();
|
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("work-time", workTimeMillis);
|
span.setAttribute("info", "interesting stuff");
|
||||||
span.setAttribute("info", "interesting stuff");
|
span.setAttribute("additionalInfo", "interesting stuff");
|
||||||
span.setAttribute("additionalInfo", "interesting stuff");
|
|
||||||
}
|
|
||||||
if (workTimeMillis > 0) {
|
if (workTimeMillis > 0) {
|
||||||
Worker.doWork(workTimeMillis);
|
Worker.doWork(workTimeMillis);
|
||||||
}
|
}
|
||||||
|
|
|
@ -181,7 +181,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
|
||||||
if (parentContext == null) {
|
if (parentContext == null) {
|
||||||
completeDelegate(result);
|
completeDelegate(result);
|
||||||
} else {
|
} else {
|
||||||
try (Scope scope = parentContext.makeCurrent()) {
|
try (Scope ignored = parentContext.makeCurrent()) {
|
||||||
completeDelegate(result);
|
completeDelegate(result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -195,7 +195,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
|
||||||
if (parentContext == null) {
|
if (parentContext == null) {
|
||||||
failDelegate(ex);
|
failDelegate(ex);
|
||||||
} else {
|
} else {
|
||||||
try (Scope scope = parentContext.makeCurrent()) {
|
try (Scope ignored = parentContext.makeCurrent()) {
|
||||||
failDelegate(ex);
|
failDelegate(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -209,7 +209,7 @@ public class ApacheHttpAsyncClientInstrumentation implements TypeInstrumentation
|
||||||
if (parentContext == null) {
|
if (parentContext == null) {
|
||||||
cancelDelegate();
|
cancelDelegate();
|
||||||
} else {
|
} else {
|
||||||
try (Scope scope = parentContext.makeCurrent()) {
|
try (Scope ignored = parentContext.makeCurrent()) {
|
||||||
cancelDelegate();
|
cancelDelegate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,28 +29,28 @@ public class SubscriberWrapper implements Subscriber<Object> {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Subscription subscription) {
|
public void onSubscribe(Subscription subscription) {
|
||||||
try (Scope ignore = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
delegate.onSubscribe(subscription);
|
delegate.onSubscribe(subscription);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(Object o) {
|
public void onNext(Object o) {
|
||||||
try (Scope ignore = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
delegate.onNext(o);
|
delegate.onNext(o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onError(Throwable throwable) {
|
public void onError(Throwable throwable) {
|
||||||
try (Scope ignore = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
delegate.onError(throwable);
|
delegate.onError(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onComplete() {
|
public void onComplete() {
|
||||||
try (Scope ignore = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
delegate.onComplete();
|
delegate.onComplete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
||||||
public Object onCompleted() throws Exception {
|
public Object onCompleted() throws Exception {
|
||||||
tracer().end(context, builder.build());
|
tracer().end(context, builder.build());
|
||||||
|
|
||||||
try (Scope scope = parentContext.makeCurrent()) {
|
try (Scope ignored = parentContext.makeCurrent()) {
|
||||||
return delegate.onCompleted();
|
return delegate.onCompleted();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ public class AsyncHandlerWrapper implements AsyncHandler {
|
||||||
public void onThrowable(Throwable throwable) {
|
public void onThrowable(Throwable throwable) {
|
||||||
tracer().endExceptionally(context, throwable);
|
tracer().endExceptionally(context, throwable);
|
||||||
|
|
||||||
try (Scope scope = parentContext.makeCurrent()) {
|
try (Scope ignored = parentContext.makeCurrent()) {
|
||||||
delegate.onThrowable(throwable);
|
delegate.onThrowable(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public class TracedDelegatingConsumer implements Consumer {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
Context context = tracer().startDeliverySpan(queue, envelope, properties, body);
|
Context context = tracer().startDeliverySpan(queue, envelope, properties, body);
|
||||||
|
|
||||||
try (Scope scope = context.makeCurrent()) {
|
try (Scope ignored = context.makeCurrent()) {
|
||||||
// Call delegate.
|
// Call delegate.
|
||||||
delegate.handleDelivery(consumerTag, envelope, properties, body);
|
delegate.handleDelivery(consumerTag, envelope, properties, body);
|
||||||
tracer().end(context);
|
tracer().end(context);
|
||||||
|
|
|
@ -102,14 +102,14 @@ public class AdviceUtils {
|
||||||
@Override
|
@Override
|
||||||
public void onSubscribe(Subscription subscription) {
|
public void onSubscribe(Subscription subscription) {
|
||||||
this.subscription = subscription;
|
this.subscription = subscription;
|
||||||
try (Scope scope = otelContext.makeCurrent()) {
|
try (Scope ignored = otelContext.makeCurrent()) {
|
||||||
subscriber.onSubscribe(this);
|
subscriber.onSubscribe(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNext(T t) {
|
public void onNext(T t) {
|
||||||
try (Scope scope = otelContext.makeCurrent()) {
|
try (Scope ignored = otelContext.makeCurrent()) {
|
||||||
subscriber.onNext(t);
|
subscriber.onNext(t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,7 +36,7 @@ public class ExceptionHandlerWrapper implements Handler<Throwable> {
|
||||||
|
|
||||||
tracer().endExceptionally(contexts.context, throwable);
|
tracer().endExceptionally(contexts.context, throwable);
|
||||||
|
|
||||||
try (Scope scope = contexts.parentContext.makeCurrent()) {
|
try (Scope ignored = contexts.parentContext.makeCurrent()) {
|
||||||
callHandler(throwable);
|
callHandler(throwable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue