This is an automated email from the ASF dual-hosted git repository.
davsclaus 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 e957e02a6f7 File Changed ReadLock Strategy with minAge only looks for
lastModified (#10131)
e957e02a6f7 is described below
commit e957e02a6f73daed34e7e912951763d383064a9c
Author: David Voit <[email protected]>
AuthorDate: Mon May 22 17:20:57 2023 +0200
File Changed ReadLock Strategy with minAge only looks for lastModified
(#10131)
If a file is copied with the original lastModified date, files are
processes instantly.
Also the file change detection is disabled if a copy takes more than minAge
time.
Instead of comparing startTime with lastModified on each iteration we are
comparing it with now().
If files are created anew this should be the same behaviour, and files
copied with preserved lastModifed are still correctly checked.
---
.../strategy/FileChangedExclusiveReadLockStrategy.java | 14 ++++++--------
1 file changed, 6 insertions(+), 8 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 c3d01f0880f..b1e04b4273e 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,7 +17,6 @@
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;
@@ -58,7 +57,7 @@ public class FileChangedExclusiveReadLockStrategy extends
MarkerFileExclusiveRea
long lastModified = Long.MIN_VALUE;
long length = Long.MIN_VALUE;
StopWatch watch = new StopWatch();
- long startTime = (new Date()).getTime();
+ long startTime = System.currentTimeMillis();
while (!exclusive) {
// timeout check
@@ -81,16 +80,15 @@ public class FileChangedExclusiveReadLockStrategy extends
MarkerFileExclusiveRea
long newLastModified = target.lastModified();
long newLength = target.length();
- long newOlderThan = startTime + watch.taken() - minAge;
+ long minTriggerTime = startTime + minAge;
+ long currentTime = System.currentTimeMillis();
LOG.trace("Previous last modified: {}, new last modified: {}",
lastModified, newLastModified);
LOG.trace("Previous length: {}, new length: {}", length,
newLength);
- LOG.trace("New older than threshold: {}", newOlderThan);
+ LOG.trace("Min File Trigger Time: {}", minTriggerTime);
- // CHECKSTYLE:OFF
- if (newLength >= minLength && ((minAge == 0 && newLastModified ==
lastModified && newLength == length)
- || (minAge != 0 && newLastModified < newOlderThan))) {
- // CHECKSTYLE:ON
+ if (newLength >= minLength && currentTime >= minTriggerTime
+ && newLastModified == lastModified && newLength == length) {
LOG.trace("Read lock acquired.");
exclusive = true;
} else {