This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch support/nifi-1.x
in repository https://gitbox.apache.org/repos/asf/nifi.git
The following commit(s) were added to refs/heads/support/nifi-1.x by this push:
new 9b7dadb214 NIFI-12019 Improved reliability of
TestSynchronousFileWatcher
9b7dadb214 is described below
commit 9b7dadb21414af15a4a8c662617e6d7fd70fa42b
Author: Mike Moser <[email protected]>
AuthorDate: Thu Sep 21 16:55:54 2023 +0000
NIFI-12019 Improved reliability of TestSynchronousFileWatcher
This closes #7770
Signed-off-by: David Handermann <[email protected]>
(cherry picked from commit 1f87c16ab8473e98df5c31a4932c0ff92c7d031a)
---
.../nifi/util/file/monitor/TestSynchronousFileWatcher.java | 9 ++-------
1 file changed, 2 insertions(+), 7 deletions(-)
diff --git
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java
index 4f348f2246..9c7e2b3367 100644
---
a/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java
+++
b/nifi-commons/nifi-utils/src/test/java/org/apache/nifi/util/file/monitor/TestSynchronousFileWatcher.java
@@ -37,9 +37,8 @@ public class TestSynchronousFileWatcher {
Files.copy(new ByteArrayInputStream("Hello,
World!".getBytes("UTF-8")), path, StandardCopyOption.REPLACE_EXISTING);
final UpdateMonitor monitor = new DigestUpdateMonitor();
- final SynchronousFileWatcher watcher = new
SynchronousFileWatcher(path, monitor, 40L);
+ final SynchronousFileWatcher watcher = new
SynchronousFileWatcher(path, monitor, 0L);
assertFalse(watcher.checkAndReset());
- Thread.sleep(41L);
assertFalse(watcher.checkAndReset());
try (FileOutputStream fos = new FileOutputStream(path.toFile())) {
@@ -47,11 +46,7 @@ public class TestSynchronousFileWatcher {
fos.getFD().sync();
}
- // immediately after file changes, but before the next check time is
reached, answer should be false
- assertFalse(watcher.checkAndReset());
-
- // after check time has passed, answer should be true
- Thread.sleep(41L);
+ // file has changed, answer should be true once
assertTrue(watcher.checkAndReset());
assertFalse(watcher.checkAndReset());
}