@@ -615,41 +615,36 @@ class AppSecRequestContextSpecification extends DDSpecification {
615615 def context = new AppSecRequestContext ()
616616 def numThreads = 3
617617 def startLatch = new java.util.concurrent.CountDownLatch (1 )
618- def doneLatch = new java.util.concurrent.CountDownLatch (numThreads)
619618
620619 when :
621620 // Simulate concurrent updates from multiple threads
622621 def executorService = java.util.concurrent.Executors . newFixedThreadPool(numThreads)
623- def tasks = []
622+ def futures = []
624623
625- tasks << executorService. submit({
624+ futures << executorService. submit({
626625 startLatch. await() // Wait for all threads to be ready
627626 context. reportDerivatives([' attr1' : [' value' : ' value1' ]])
628627 context. reportDerivatives([' attr2' : [' value' : ' value2' ]])
629- doneLatch. countDown()
630628 })
631629
632- tasks << executorService. submit({
630+ futures << executorService. submit({
633631 startLatch. await() // Wait for all threads to be ready
634632 context. reportDerivatives([' attr3' : [' value' : ' value3' ]])
635633 context. reportDerivatives([' attr4' : [' value' : ' value4' ]])
636- doneLatch. countDown()
637634 })
638635
639- tasks << executorService. submit({
636+ futures << executorService. submit({
640637 startLatch. await() // Wait for all threads to be ready
641638 context. reportDerivatives([' attr5' : [' value' : ' value5' ]])
642639 context. reportDerivatives([' attr6' : [' value' : ' value6' ]])
643- doneLatch. countDown()
644640 })
645641
646642 // Release all threads at once to maximize concurrent execution
647643 startLatch. countDown()
648644
649- // Wait for all tasks to complete
650- doneLatch . await( 5 , java.util.concurrent.TimeUnit . SECONDS )
645+ // Wait for all tasks to complete using the futures
646+ futures . each { it . get() }
651647 executorService. shutdown()
652- executorService. awaitTermination(5 , java.util.concurrent.TimeUnit . SECONDS )
653648
654649 then :
655650 // Verify all attributes were added despite concurrent access
0 commit comments