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

exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi.git


The following commit(s) were added to refs/heads/main by this push:
     new 1f87c16ab8 NIFI-12019 Improved reliability of 
TestSynchronousFileWatcher
1f87c16ab8 is described below

commit 1f87c16ab8473e98df5c31a4932c0ff92c7d031a
Author: Mike Moser <mose...@apache.org>
AuthorDate: Thu Sep 21 16:55:54 2023 +0000

    NIFI-12019 Improved reliability of TestSynchronousFileWatcher
    
    This closes #7770
    
    Signed-off-by: David Handermann <exceptionfact...@apache.org>
---
 .../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());
     }

Reply via email to