As some said already, it was caused by a seperate tread 'modifying' products
(as it was a cached instance).
I've changed the implementation of Product.findActiveByFilter
to return a new ArrayList<Product>(products);
instead of a reference to the cached value, when no filters are applied (thus no filtered result is given back).
public static List<Product> findActiveByFilter(ArrayList<FilterPair> filters) {
List<Product> products = getCachedAllProductsByFirstSupplier();
if (products == null) {
products = new ArrayList<Product>();
}
if(filters.size() > 0) {
List<Product> productsFiltered = new ArrayList<Product>(products);
// ... MANY checks here for the filters ...
return productsFiltered;
}
return new ArrayList<Product>(products); // Do not give cached copy, was 'return products;'
}
There were 2 calls to the findActiveByFilter, called by the website. The first one did include a filter, but the second one did not (so the first one was still busy, while the second one returned directly).