Repository: nifi
Updated Branches:
  refs/heads/master 758e44682 -> 03f4c0fc4


NIFI-5011: Fixed threading bug in TestFileSystemRepository
This closes #2578.

Signed-off-by: Mark Payne <[email protected]>


Project: http://git-wip-us.apache.org/repos/asf/nifi/repo
Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/03f4c0fc
Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/03f4c0fc
Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/03f4c0fc

Branch: refs/heads/master
Commit: 03f4c0fc475558cadbc3a821e375a4ed8092689e
Parents: 758e446
Author: Mark Payne <[email protected]>
Authored: Fri Mar 23 14:33:53 2018 -0400
Committer: Mark Payne <[email protected]>
Committed: Fri Mar 23 15:46:17 2018 -0400

----------------------------------------------------------------------
 .../repository/TestFileSystemRepository.java      | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nifi/blob/03f4c0fc/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
----------------------------------------------------------------------
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
index 7cc6e9b..3ecff71 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/repository/TestFileSystemRepository.java
@@ -148,14 +148,20 @@ public class TestFileSystemRepository {
         String message = "The value of 
nifi.content.repository.archive.cleanup.frequency property "
                 + "is set to '1 millis' which is below the allowed minimum of 
1 second (1000 milliseconds). "
                 + "Minimum value of 1 sec will be used as scheduling interval 
for archive cleanup task.";
-        for (ILoggingEvent event : testAppender.list) {
-            String actualMessage = event.getFormattedMessage();
-            if (actualMessage.equals(message)) {
-                assertEquals(event.getLevel(), Level.WARN);
-                messageFound = true;
-                break;
+
+        // Must synchronize on testAppender, because the call to append() is 
synchronized and this synchronize
+        // keyword guards testAppender.list. Since we are accessing 
testAppender.list, we must do so in a thread-safe manner.
+        synchronized (testAppender) {
+            for (ILoggingEvent event : testAppender.list) {
+                String actualMessage = event.getFormattedMessage();
+                if (actualMessage.equals(message)) {
+                    assertEquals(event.getLevel(), Level.WARN);
+                    messageFound = true;
+                    break;
+                }
             }
         }
+
         assertTrue(messageFound);
     }
 

Reply via email to