Uploaded image for project: 'OpenWebBeans'
  1. OpenWebBeans
  2. OWB-1013

Race condition in Instance injection

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.2.6
    • 1.5.0
    • Injection and Lookup
    • None

    Description

      OpenWebBeans is prone to flip instances of javax.enterprise.inject.Instance in multi-threaded environments.

      It is possible for multiple threads to access InstanceProducer at the same time with the same creational context. If that happens, it is not verified that these threads get the correct injectionPoint out of the injectionPoints stack in the shared CreationalContextImpl.

      Please see attached example source (with comments included). It'll require a debugger because it's quite tricky to get the threads into proper timing. Start main method of class de.cewe.race.Main. It constructs a simple SE container and executes two threads which will trigger the issue.

      Set breakpoints at:

      • de.cewe.race.CDIMain, line 46 (System.out.println)
      • org.apache.webbeans.portable.InstanceProducer, line 65 (getInjectionPoint)

      Wait until threads "RunnableA" and "RunnableB" reached the second breakpoint. Then let RunnableA finish. It will trigger a ClassCastException. For your own convenience, activate the second breakpoint after first one is reached. It reduces debugger noise during startup.

      Attachments

        1. race.diff
          2 kB
          Tobias Stoeckmann
        2. instance-race.zip
          7 kB
          Tobias Stoeckmann

        Activity

          People

            arne Arne Limburg
            tstoeckmann Tobias Stoeckmann
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: