The following randomly calls getParentCustomers
or getAccountManagers
first. When it does it works fine. However, whichever one gets called second passes a null
into it. Neither of these methods mutates the incoming values in any way. I am guessing there is something about the context that these are called from that the original pointer to response.salesChannels
gets lost between tasks.
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
I even tried to modify the internals to leverage onComplete
instead.
...
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])
})
...
However, I still end up with the same result.
NOTE: This is random too. Sometimes it works fine - passing the same list to both methods. But when it breaks, it is always whichever one that fires second.
Any thoughts on this?