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 2023/08/10 15:23:02 UTC

[camel] branch flaky updated: CAMEL-19684: Attempt to fix some flaky test

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

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


The following commit(s) were added to refs/heads/flaky by this push:
     new a8acaca91b6 CAMEL-19684: Attempt to fix some flaky test
a8acaca91b6 is described below

commit a8acaca91b6ce3d67eaa891872bd8f513c6a78f6
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Aug 10 17:22:49 2023 +0200

    CAMEL-19684: Attempt to fix some flaky test
---
 .../camel/impl/engine/PooledExchangeFactory.java   | 12 -----------
 .../management/ManagedPooledExchangeTest.java      | 25 ++++++++++++----------
 2 files changed, 14 insertions(+), 23 deletions(-)

diff --git a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
index 7573dacd18a..7468e4f9c58 100644
--- a/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
+++ b/core/camel-base-engine/src/main/java/org/apache/camel/impl/engine/PooledExchangeFactory.java
@@ -41,18 +41,6 @@ public final class PooledExchangeFactory extends PrototypeExchangeFactory {
         super(consumer);
     }
 
-    @Override
-    protected void doBuild() throws Exception {
-        super.doBuild();
-        // force creating and load the class during build time so the JVM does not
-        // load the class on first exchange to be created
-        DefaultPooledExchange dummy = new DefaultPooledExchange(camelContext);
-        // force message init to load classes
-        dummy.getIn();
-        dummy.getIn().getHeaders();
-        LOG.trace("Warming up PooledExchangeFactory loaded class: {}", dummy.getClass().getName());
-    }
-
     @Override
     public ExchangeFactory newExchangeFactory(Consumer consumer) {
         PooledExchangeFactory answer = new PooledExchangeFactory(consumer);
diff --git a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
index c9044595bc1..ee47b4b5737 100644
--- a/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
+++ b/core/camel-management/src/test/java/org/apache/camel/management/ManagedPooledExchangeTest.java
@@ -29,6 +29,7 @@ import org.apache.camel.ServiceStatus;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.impl.engine.PooledExchangeFactory;
+import org.awaitility.Awaitility;
 import org.junit.jupiter.api.Test;
 import org.junit.jupiter.api.condition.DisabledOnOs;
 import org.junit.jupiter.api.condition.OS;
@@ -85,21 +86,23 @@ public class ManagedPooledExchangeTest extends ManagementTestSupport {
         Integer cap = (Integer) mbeanServer.getAttribute(on, "Capacity");
         assertEquals(123, cap.intValue());
 
-        // also only 1 exchange pooled
-        con = (Integer) mbeanServer.getAttribute(on, "TotalPooled");
-        assertEquals(1, con.intValue());
+        Awaitility.await().untilAsserted(() -> {
+            Long num = (Long) mbeanServer.getAttribute(on, "TotalCreated");
+            assertEquals(1, num.intValue());
+
+            num = (Long) mbeanServer.getAttribute(on, "TotalAcquired");
+            assertEquals(2, num.intValue());
 
-        Long num = (Long) mbeanServer.getAttribute(on, "TotalCreated");
-        assertEquals(1, num.intValue());
+            num = (Long) mbeanServer.getAttribute(on, "TotalReleased");
+            assertEquals(3, num.intValue());
 
-        num = (Long) mbeanServer.getAttribute(on, "TotalAcquired");
-        assertEquals(2, num.intValue());
+            num = (Long) mbeanServer.getAttribute(on, "TotalDiscarded");
+            assertEquals(0, num.intValue());
 
-        num = (Long) mbeanServer.getAttribute(on, "TotalReleased");
-        assertEquals(3, num.intValue());
+            Integer num2 = (Integer) mbeanServer.getAttribute(on, "TotalPooled");
+            assertEquals(1, num2.intValue());
+        });
 
-        num = (Long) mbeanServer.getAttribute(on, "TotalDiscarded");
-        assertEquals(0, num.intValue());
     }
 
     @Override