Uploaded image for project: 'Seam 2'
  1. Seam 2
  2. JBSEAM-4997

Deadlock with components using factories of each other

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.3.0.BETA2
    • Fix Version/s: 2.3.0.CR1
    • Component/s: Core
    • Labels:
      None
    • Steps to Reproduce:
      Hide

      1. Uncomment the @Ignore annotation on the interleavingFactories method in seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java
      2. run

      mvn clean verify -Darquillian=jbossas-managed-7 -Dtest=org.jboss.seam.test.integration.FactoryLockTest

      3. Notice the deadlock in the interleavingFactories test

      Show
      1. Uncomment the @Ignore annotation on the interleavingFactories method in seam-integration-tests/src/test/java/org/jboss/seam/test/integration/FactoryLockTest.java 2. run mvn clean verify -Darquillian=jbossas-managed-7 -Dtest=org.jboss.seam.test.integration.FactoryLockTest 3. Notice the deadlock in the interleavingFactories test

      Description

      The patch in JBSEAM-4861 introduced a potential deadlock with components using each other factories, such as in the following sample:

      @Scope(ScopeType.APPLICATION)
      @Name("factoryLock.knitFactory")
      public static class KnitFactory
      {
         @Factory(value="factoryLock.knitPurl", scope=ScopeType.SESSION)
         public String getDoubleKnit() {
            return "knit(" + (String)Component.getInstance("factoryLock.purl") + ")";
         }
            
         @Factory(value="factoryLock.knit", scope=ScopeType.SESSION)
         public String getKnit() {
            return "knit";
         }
      }
         
      @Scope(ScopeType.APPLICATION)
      @Name("factoryLock.purlFactory")
      public static class PurlFactory
      {
         @Factory(value="factoryLock.purlKnit", scope=ScopeType.SESSION)
         public String getDoublePurl() {
            return "purl(" + (String)Component.getInstance("factoryLock.knit") + ")";
         }
            
         @Factory(value="factoryLock.purl", scope=ScopeType.SESSION)
         public String getPurl() {
            return "purl";
         }
      }
      

      this may cause a deadlock if two different requests in the same session ask for #

      {factoryLock.knitPurl}

      and #

      {factoryLock.purlKnit}

      respectively.

      The problem is that different threads may lock the components in different order.

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  manaRH Marek Novotny
                  Reporter:
                  maschmid Marek Schmidt
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  2 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: