Announcement Announcement Module
No announcement yet.
Thread safety issue with WeavingTransformer when using a SchedulerFactoryBean? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Thread safety issue with WeavingTransformer when using a SchedulerFactoryBean?

    Hello all,

    I'm trying to determine if an issue we're experiencing in our web app is a result of a bug in some Spring code (we're on 3.2.3), or in Tomcat (7.0.26), or if (and this seems most likely) we are doing something incorrectly that is triggering the problem. The symptom we sporadically see is a ConcurrentModificationException at startup which is apparently caused by WeavingTransformer.addTransformer being called while WeavingTransformer.transformIfNecessary is iterating through the transformers list in another thread.

    We have a large Spring context that we are bringing up in our app where we have added this configuration to our beans XML to support our JPA provider which requires weaving:

    We also have an org.springframework.scheduling.quartz.SchedulerFac toryBean that is firing up a quartz instance, and the thread where that is happening is one of the two that are bumping heads here when we're unlucky enough to have the ConcurrentModificationException manifest. The QuartzScheduler seems to always be the thread iterating through the transformers when I can get things to blow up in my development environment.

    I've observed in the debugger that there is only one instance of WeavingTransformer that the TomcatInstrumentableClassLoader is calling, so it is clearly unsafe that it be calling addTransformer and transformIfNecessary concurrently given that WeavingTransformer.transformers is a plain old ArrayList. It comes down to who is doing it wrong:
    1) Our app: is there a rule of thumb that we are violating in some way?
    2) Tomcat: Maybe TomcatInstrumentableClassLoader needs to be smarter/synchronized when it calls WeavingTransformer?
    3) Spring: Maybe WeavingTransformer needs to better support concurrency?

    Does our configuration at least sound sane? Is there more info that it would be helpful for me to provide? And if we're *not* doing something wrong here, where do I file the bug?


  • #2
    This question is probably a better candidate for StackOverflow, perhaps with the "spring" tag.

    Could you post your question there?
    In case this is really a bug, you can file it in our JIRA instance:

    The forums are moving to stackoverflow, a page explaining all this will be available there in a few days: