Hi Dan, The initialization and usage of a function is handled by the runtime by a single thread. Can you share more details? For example: 1. Any Stacktrace 2. How does your StatefulFunctionProvider looks like? Do you cache a single function instance, or return a new one in the provider ? 3. Are your functions keep any non PersistedValue state?
Thanks, Igal On Saturday, January 11, 2020, Dan Pettersson <dan.pettersso...@gmail.com> wrote: > Hi all, > > I have had some race problems in method StatefulMatchFunction. > ensureInitialized. > > The quick solution would be to introduce a double checked locking: > > private void ensureInitialized() { > if (!setup) { > synchronized (this) { > if (!setup) { > configure(matcher); > setup = true; > } > } > } > } > > But this solution would force us to make the setup variable to volatile, > which would/can decrease the read performance in this performance critical > code.. > > Any thoughts on how to solve this in a clever way would be appreciated. > > Regards > Dan >