Uploaded image for project: 'Weld'
  1. Weld
  2. WELD-1155

Long running producer called multiple times in the same context

XMLWordPrintable

      SessionScoped Producers are called multiple times in the same session if a second request in the same session comes before the first one finishes.

      The first request is thus processed with an outdated instance, as it will be replaced by the produce of the other request.

      public class ShoppingCartProducer
      {
         private static AtomicInteger ai = new AtomicInteger();
         
         @Produces
         @SessionScoped
         public ShoppingCart getShoppingCart() {
            System.out.println("getShoppingCart producer");
            
            try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); }
            
            return new ShoppingCart("cart" + ai.incrementAndGet());
         }
      }
      

        1. helloworld.tar.gz
          5 kB
          Marek Schmidt
        2. jboss-as-helloworld.war
          10 kB
          Marek Schmidt

              rhn-engineering-jharting Jozef Hartinger
              maschmid@redhat.com Marek Schmidt
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Created:
                Updated:
                Resolved: