You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by or...@apache.org on 2022/06/15 09:42:21 UTC
[camel] branch main updated: (chores) camel-core: fix flaky test
This is an automated email from the ASF dual-hosted git repository.
orpiske pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 71520e10047 (chores) camel-core: fix flaky test
71520e10047 is described below
commit 71520e10047cd9ae0636c02582c5093fa745144a
Author: Otavio Rodolfo Piske <an...@gmail.com>
AuthorDate: Wed Jun 15 10:17:43 2022 +0200
(chores) camel-core: fix flaky test
The confirms are handled in a separate thread, so it's necessary to
ensure the operations on increment variable in the test are atomic
and its value is up-to-date for other threads.
---
.../camel/processor/aggregator/AggregateCompletionOnlyTwoTest.java | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompletionOnlyTwoTest.java b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompletionOnlyTwoTest.java
index fbf2346d74d..244c5d4d7f8 100644
--- a/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompletionOnlyTwoTest.java
+++ b/core/camel-core/src/test/java/org/apache/camel/processor/aggregator/AggregateCompletionOnlyTwoTest.java
@@ -17,6 +17,7 @@
package org.apache.camel.processor.aggregator;
import java.util.Set;
+import java.util.concurrent.atomic.AtomicInteger;
import org.apache.camel.CamelContext;
import org.apache.camel.ContextTestSupport;
@@ -67,7 +68,7 @@ public class AggregateCompletionOnlyTwoTest extends ContextTestSupport {
private int add;
private int get;
private int remove;
- private int confirm;
+ private AtomicInteger confirm = new AtomicInteger(0);
@Override
public Exchange add(CamelContext camelContext, String key, Exchange exchange) {
@@ -89,7 +90,7 @@ public class AggregateCompletionOnlyTwoTest extends ContextTestSupport {
@Override
public void confirm(CamelContext camelContext, String exchangeId) {
- confirm++;
+ confirm.incrementAndGet();
super.confirm(camelContext, exchangeId);
}
@@ -111,7 +112,7 @@ public class AggregateCompletionOnlyTwoTest extends ContextTestSupport {
}
public int getConfirm() {
- return confirm;
+ return confirm.get();
}
}
}