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

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

commit aba086ff476e9a1bc5ddc017f366293484bbd832
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Thu Aug 8 11:36:34 2024 +0200

    Revert "File Changed ReadLock Strategy with minAge only looks for 
lastModified (#10131)"
    
    This reverts commit 850d3eaefb503892572192e82d48f381a550eb23.
---
 .../strategy/FileChangedExclusiveReadLockStrategy.java     | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git 
a/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileChangedExclusiveReadLockStrategy.java
 
b/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileChangedExclusiveReadLockStrategy.java
index b1e04b4273e..c3d01f0880f 100644
--- 
a/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileChangedExclusiveReadLockStrategy.java
+++ 
b/components/camel-file/src/main/java/org/apache/camel/component/file/strategy/FileChangedExclusiveReadLockStrategy.java
@@ -17,6 +17,7 @@
 package org.apache.camel.component.file.strategy;
 
 import java.io.File;
+import java.util.Date;
 
 import org.apache.camel.Exchange;
 import org.apache.camel.LoggingLevel;
@@ -57,7 +58,7 @@ public class FileChangedExclusiveReadLockStrategy extends 
MarkerFileExclusiveRea
         long lastModified = Long.MIN_VALUE;
         long length = Long.MIN_VALUE;
         StopWatch watch = new StopWatch();
-        long startTime = System.currentTimeMillis();
+        long startTime = (new Date()).getTime();
 
         while (!exclusive) {
             // timeout check
@@ -80,15 +81,16 @@ public class FileChangedExclusiveReadLockStrategy extends 
MarkerFileExclusiveRea
 
             long newLastModified = target.lastModified();
             long newLength = target.length();
-            long minTriggerTime = startTime + minAge;
-            long currentTime = System.currentTimeMillis();
+            long newOlderThan = startTime + watch.taken() - minAge;
 
             LOG.trace("Previous last modified: {}, new last modified: {}", 
lastModified, newLastModified);
             LOG.trace("Previous length: {}, new length: {}", length, 
newLength);
-            LOG.trace("Min File Trigger Time: {}", minTriggerTime);
+            LOG.trace("New older than threshold: {}", newOlderThan);
 
-            if (newLength >= minLength && currentTime >= minTriggerTime
-                && newLastModified == lastModified && newLength == length) {
+            // CHECKSTYLE:OFF
+            if (newLength >= minLength && ((minAge == 0 && newLastModified == 
lastModified && newLength == length)
+                    || (minAge != 0 && newLastModified < newOlderThan))) {
+            // CHECKSTYLE:ON
                 LOG.trace("Read lock acquired.");
                 exclusive = true;
             } else {

Reply via email to