Is retainAll() thread safe?


I’m troubleshooting some session swapping which I think is because of threads. Could using Java’s retainAll() and toList() methods cause thread problems, that is, are they thread safe?

<cfset local.productCategories.retainAll(local.posCategories) />
<cfset item.productCategoryIDs = local.productCategories.toList() />

OS: Ubuntu Linux, 64bit
Java Version: 1.8.0_152
Tomcat Version: 8.5.24
Lucee Version:

those arrays array appear to be only local, so threading shouldn’t even be an issue?

Hi Zack, it was a red herring on my part; the enclosing code was a CFC in the Application scope, so I think what I saw was a race condition with sessions getting swapped. Some loop indexes in the CFC needed to be var scoped. But, then I just chucked it all and moved the instantiated CFC to the session scope.