You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2022/06/20 19:42:05 UTC

[camel] 02/03: CAMEL-18210: camel-core - Pooled exchanges in batch consumer may use an exchange concurrently

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git

commit ce776919f9b245b1ea67438bfbbe7298a0afe611
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Mon Jun 20 21:36:23 2022 +0200

    CAMEL-18210: camel-core - Pooled exchanges in batch consumer may use an exchange concurrently
---
 .../processor/BatchConsumerPooledExchangeTest.java      | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/BatchConsumerPooledExchangeTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/BatchConsumerPooledExchangeTest.java
index 0c5b017e2c2..4d44889707b 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/BatchConsumerPooledExchangeTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/BatchConsumerPooledExchangeTest.java
@@ -16,6 +16,7 @@
  */
 package org.apache.camel.processor;
 
+import java.util.concurrent.TimeUnit;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.concurrent.atomic.AtomicReference;
 
@@ -29,6 +30,7 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.engine.PooledExchangeFactory;
 import org.apache.camel.impl.engine.PooledProcessorExchangeFactory;
 import org.apache.camel.spi.PooledObjectFactory;
+import org.awaitility.Awaitility;
 import org.junit.jupiter.api.BeforeEach;
 import org.junit.jupiter.api.Test;
 
@@ -43,6 +45,7 @@ public class BatchConsumerPooledExchangeTest extends ContextTestSupport {
     @Override
     protected CamelContext createCamelContext() throws Exception {
         ExtendedCamelContext ecc = (ExtendedCamelContext) super.createCamelContext();
+
         ecc.setExchangeFactory(new PooledExchangeFactory());
         ecc.setProcessorExchangeFactory(new PooledProcessorExchangeFactory());
         ecc.getExchangeFactory().setStatisticsEnabled(true);
@@ -74,12 +77,14 @@ public class BatchConsumerPooledExchangeTest extends ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        PooledObjectFactory.Statistics stat
-                = context.adapt(ExtendedCamelContext.class).getExchangeFactoryManager().getStatistics();
-        assertEquals(1, stat.getCreatedCounter());
-        assertEquals(2, stat.getAcquiredCounter());
-        assertEquals(3, stat.getReleasedCounter());
-        assertEquals(0, stat.getDiscardedCounter());
+        Awaitility.waitAtMost(2, TimeUnit.SECONDS).untilAsserted(() -> {
+            PooledObjectFactory.Statistics stat
+                    = context.adapt(ExtendedCamelContext.class).getExchangeFactoryManager().getStatistics();
+            assertEquals(1, stat.getCreatedCounter());
+            assertEquals(2, stat.getAcquiredCounter());
+            assertEquals(3, stat.getReleasedCounter());
+            assertEquals(0, stat.getDiscardedCounter());
+        });
     }
 
     @Override