diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/op/OpAccumulatorClosure.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/op/OpAccumulatorClosure.groovy index cbb29a4004..d60306dc89 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/op/OpAccumulatorClosure.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/op/OpAccumulatorClosure.groovy @@ -36,7 +36,7 @@ class OpAccumulatorClosure extends OpClosure { } @Override - protected OperatorRun runInstance() { + protected OperatorRun allocateRun() { return getPreviousRun() } } diff --git a/modules/nextflow/src/main/groovy/nextflow/extension/op/OpClosure.groovy b/modules/nextflow/src/main/groovy/nextflow/extension/op/OpClosure.groovy index 55f9f53f9c..efca7f304d 100644 --- a/modules/nextflow/src/main/groovy/nextflow/extension/op/OpClosure.groovy +++ b/modules/nextflow/src/main/groovy/nextflow/extension/op/OpClosure.groovy @@ -36,7 +36,7 @@ class OpClosure extends Closure implements OpContext { private final Closure target - private final ThreadLocal runPerThread = ThreadLocal.withInitial(()->new OperatorRun()) + private final ThreadLocal runPerThread = new ThreadLocal<>() private final Map holder = new ConcurrentHashMap<>() @@ -96,8 +96,9 @@ class OpClosure extends Closure implements OpContext { target.setProperty(propertyName, newValue) } - protected OperatorRun runInstance() { - final result = runPerThread.get() + protected OperatorRun allocateRun() { + final result = new OperatorRun() + runPerThread.set(result) setPreviousRun(result) return result } @@ -105,7 +106,7 @@ class OpClosure extends Closure implements OpContext { @Override Object call(final Object... args) { // when the accumulator flag true, re-use the previous run object - final OperatorRun run = runInstance() + final OperatorRun run = allocateRun() // map the inputs final List inputs = Prov.getTracker().receiveInputs(run, Arrays.asList(args)) final Object result = InvokerHelper.invokeMethod(target, "call", inputs.toArray()) diff --git a/modules/nextflow/src/test/groovy/nextflow/prov/ProvTest.groovy b/modules/nextflow/src/test/groovy/nextflow/prov/ProvTest.groovy index 1330a45b97..2bc9be4c25 100644 --- a/modules/nextflow/src/test/groovy/nextflow/prov/ProvTest.groovy +++ b/modules/nextflow/src/test/groovy/nextflow/prov/ProvTest.groovy @@ -51,7 +51,7 @@ class ProvTest extends Dsl2Spec { upstream.first.name == 'p1' } - def 'should branch two process'() { + def 'should track provenance with branch operator'() { when: dsl_eval(globalConfig(), ''' @@ -258,7 +258,7 @@ class ProvTest extends Dsl2Spec { } - def 'should track provenance two processes and the filter operator'() { + def 'should track provenance with filter operator'() { when: dsl_eval(globalConfig(), '''