下面随机调用getParentCustomers
还是getAccountManagers
先。当它运行时,它工作正常。但是,无论哪个被称为 second,都会将 a 传递给null
它。这些方法都不会以任何方式改变传入的值。我猜想有一些关于上下文的东西,这些是从原始指针response.salesChannels
在任务之间丢失的情况中调用的。
Map response = [
salesChannels: null,
accountManagers: null,
parentCustomers: null,
isrs: null,
operatingUnits: null,
businessUnits: null
]
def t1 = task {
response.salesChannels = salesChannelApiService.get(salesChannel)
def t1a = task {
response.parentCustomers = salesChannelTransformService.getParentCustomers(response.salesChannels)
}
def t1b = task {
response.accountManagers = salesChannelTransformService.getAccountManagers(response.salesChannels)
}
waitAll([t1a, t1b])
}
def t2 = task {
//... other stuff
}
def t3 = task {
//... other stuff
}
waitAll([t1, t2, t3])
return response
我什至尝试修改内部结构以利用onComplete
。
...
onComplete([task {
return salesChannelApiService.get(salesChannel)
}], { salesChannels ->
response.salesChannels = salesChannels
def t1a = task {
response.parentCustomers = salesChannelTransformService.getParentCustomers(salesChannels)
}
def t1b = task {
response.accountManagers = salesChannelTransformService.getAccountManagers(salesChannels)
}
waitAll([t1a, t1b])
})
...
但是,我仍然得到相同的结果。
注意:这也是随机的。有时它工作正常 - 将相同的列表传递给两种方法。但是,当它破裂时,总是先触发第二个。
对此有什么想法吗?