This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch camel-4.0.x in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/camel-4.0.x by this push: new 1a815dcc6d8 Revert "File Changed ReadLock Strategy with minAge only looks for lastModified (#10131)" 1a815dcc6d8 is described below commit 1a815dcc6d8fe4fa6035d89188ec53f693d98a89 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Sat Oct 21 12:21:08 2023 +0200 Revert "File Changed ReadLock Strategy with minAge only looks for lastModified (#10131)" This reverts commit e957e02a6f73daed34e7e912951763d383064a9c. --- .../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 1bf34e8b0c5..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 {