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

gnodet pushed a commit to branch camel-4.18.x
in repository https://gitbox.apache.org/repos/asf/camel.git


The following commit(s) were added to refs/heads/camel-4.18.x by this push:
     new 8958aa46a90d [backport camel-4.18.x] CAMEL-26596: camel-file - the 
file consumer starts its scheduler only once (#29205)
8958aa46a90d is described below

commit 8958aa46a90d8831e86aa21abd31bf4a471bcd57
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Nov 5 08:49:31 2026 +0100

    [backport camel-4.18.x] CAMEL-26596: camel-file - the file consumer starts 
its scheduler only once (#29205)
---
 .../apache/camel/component/file/FileConsumer.java    |  2 --
 .../file/FileConsumerCustomSchedulerTest.java        | 20 ++++++++++++++++----
 2 files changed, 16 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
 
b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
index b3ae33f19bc9..e67237043609 100644
--- 
a/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
+++ 
b/components/camel-file/src/main/java/org/apache/camel/component/file/FileConsumer.java
@@ -452,8 +452,6 @@ public class FileConsumer extends GenericFileConsumer<File> 
implements ResumeAwa
                 startScheduler();
             }
         }
-
-        super.doStart();
     }
 
     private void tryCreateDirectory(File file) throws FileNotFoundException {
diff --git 
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
 
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
index 9f20d342351b..8ec902240e7b 100644
--- 
a/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
+++ 
b/core/camel-core/src/test/java/org/apache/camel/component/file/FileConsumerCustomSchedulerTest.java
@@ -30,7 +30,6 @@ import org.apache.camel.spi.ScheduledPollConsumerScheduler;
 import org.junit.jupiter.api.Test;
 
 import static org.junit.jupiter.api.Assertions.assertEquals;
-import static org.junit.jupiter.api.Assertions.assertTrue;
 
 public class FileConsumerCustomSchedulerTest extends ContextTestSupport {
 
@@ -53,9 +52,10 @@ public class FileConsumerCustomSchedulerTest extends 
ContextTestSupport {
 
         assertMockEndpointsSatisfied();
 
-        // the scheduler is only run once, and we can configure its properties
-        // (camel may run the scheduler once during startup so the value is +1)
-        assertTrue(scheduler.getCounter() <= 2);
+        // the scheduler is only scheduled, started and run once, and we can 
configure its properties
+        assertEquals(1, scheduler.getScheduled());
+        assertEquals(1, scheduler.getStarted());
+        assertEquals(1, scheduler.getCounter());
         assertEquals("bar", scheduler.getFoo());
     }
 
@@ -75,6 +75,8 @@ public class FileConsumerCustomSchedulerTest extends 
ContextTestSupport {
         private CamelContext camelContext;
         private TimerTask timerTask;
         private final LongAdder counter = new LongAdder();
+        private final LongAdder scheduled = new LongAdder();
+        private final LongAdder started = new LongAdder();
         private String foo;
 
         @Override
@@ -84,6 +86,7 @@ public class FileConsumerCustomSchedulerTest extends 
ContextTestSupport {
 
         @Override
         public void scheduleTask(final Runnable task) {
+            scheduled.increment();
             this.timerTask = new TimerTask() {
                 @Override
                 public void run() {
@@ -102,6 +105,14 @@ public class FileConsumerCustomSchedulerTest extends 
ContextTestSupport {
             return counter.intValue();
         }
 
+        public int getScheduled() {
+            return scheduled.intValue();
+        }
+
+        public int getStarted() {
+            return started.intValue();
+        }
+
         public String getFoo() {
             return foo;
         }
@@ -112,6 +123,7 @@ public class FileConsumerCustomSchedulerTest extends 
ContextTestSupport {
 
         @Override
         public void startScheduler() {
+            started.increment();
             Timer timer = new Timer();
             timer.schedule(timerTask, 10);
         }

Reply via email to