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

Long running producer called multiple times in the same context

    Details

      Description

      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());
         }
      }
      

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  jharting Jozef Hartinger
                  Reporter:
                  maschmid Marek Schmidt
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  4 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: