@Component JavaDelegate and concurrency


The online documentation about java delegate says that

Each time a delegation class referencing activity is executed, a separate instance of this class will be created.

But this is obviously no the case for @Component classes from the spring boot examples

I’ve ran into some concurrency issues because I was using instance variables in my JavaDelegates so I’ve started looking for some better way to integrate the process engine with spring components so that I could rely on “separate instance of this class will be created”, but couldn’t find any. I know this is an “issue” with spring and not the process engine, but I would be interested in some design pattern to overcome this limitation(use ThreadLocal variables, don’t use instance variables at all and only pass what I need in parameters …?).