Fix Ratpack tests that got broken by ExecutorInstrumentation refactoring
It turns out closing continuation also closes parent span. This is not very good in cases when we end up not using continuation if continuation in a state has already been setup. This patch provides way to close continuation in a way that doesn't affect parent scope.
This commit is contained in:
parent
4ec5ca394c
commit
2e8dc9d08f
|
|
@ -66,6 +66,7 @@ public final class ExecutorInstrumentation extends Instrumenter.Default {
|
|||
"scala.concurrent.impl.ExecutionContextImpl$$anon$3",
|
||||
"akka.dispatch.MessageDispatcher",
|
||||
"akka.dispatch.Dispatcher",
|
||||
"akka.dispatch.Dispatcher$LazyExecutorServiceDelegate",
|
||||
"akka.actor.ActorSystemImpl$$anon$1",
|
||||
"akka.dispatch.ForkJoinExecutorConfigurator$AkkaForkJoinPool",
|
||||
"akka.dispatch.forkjoin.ForkJoinPool",
|
||||
|
|
@ -347,7 +348,7 @@ public final class ExecutorInstrumentation extends Instrumenter.Default {
|
|||
if (state.setContinuation(continuation)) {
|
||||
log.debug("created continuation {} from scope {}, state: {}", continuation, scope, state);
|
||||
} else {
|
||||
continuation.close();
|
||||
continuation.close(false);
|
||||
}
|
||||
return state;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,7 +32,19 @@ public interface TraceScope {
|
|||
*/
|
||||
TraceScope activate();
|
||||
|
||||
/** Cancel the continuation. */
|
||||
/**
|
||||
* Cancel the continuation. This also closes parent scope.
|
||||
*
|
||||
* <p>FIXME: the fact that this is closing parent scope is confusing, we should review this in
|
||||
* new API.
|
||||
*/
|
||||
void close();
|
||||
|
||||
/**
|
||||
* Close the continuation.
|
||||
*
|
||||
* @param closeContinuationScope true iff parent scope should also be closed
|
||||
*/
|
||||
void close(boolean closeContinuationScope);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -128,9 +128,18 @@ public class ContinuableScope implements Scope, TraceScope {
|
|||
|
||||
@Override
|
||||
public void close() {
|
||||
close(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close(final boolean closeContinuationScope) {
|
||||
if (used.compareAndSet(false, true)) {
|
||||
trace.cancelContinuation(this);
|
||||
if (closeContinuationScope) {
|
||||
ContinuableScope.this.close();
|
||||
} else {
|
||||
openCount.decrementAndGet();
|
||||
}
|
||||
} else {
|
||||
log.debug("Failed to close continuation {}. Already used.", this);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue