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

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


The following commit(s) were added to refs/heads/master by this push:
     new 0f10010  NIFI-6199: Fixed problematic unit tests that did not properly 
wait for async tasks to complete before making assertions
0f10010 is described below

commit 0f10010683674e43c3118085d33f75930fd82676
Author: Mark Payne <[email protected]>
AuthorDate: Tue Apr 9 10:32:07 2019 -0400

    NIFI-6199: Fixed problematic unit tests that did not properly wait for 
async tasks to complete before making assertions
    
    This closes #3421.
    
    Signed-off-by: Bryan Bende <[email protected]>
---
 .../nifi/controller/service/ServiceStateTransition.java      |  2 +-
 .../controller/scheduling/TestStandardProcessScheduler.java  | 12 ++++--------
 2 files changed, 5 insertions(+), 9 deletions(-)

diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
index f35550a..754ef1d 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/main/java/org/apache/nifi/controller/service/ServiceStateTransition.java
@@ -99,7 +99,7 @@ public class ServiceStateTransition {
         writeLock.lock();
         try {
             state = ControllerServiceState.DISABLED;
-            disabledFutures.stream().forEach(future -> future.complete(null));
+            disabledFutures.forEach(future -> future.complete(null));
         } finally {
             writeLock.unlock();
         }
diff --git 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
index 242c0ad..29bf93e 100644
--- 
a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
+++ 
b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestStandardProcessScheduler.java
@@ -91,6 +91,7 @@ import java.util.Random;
 import java.util.UUID;
 import java.util.concurrent.ConcurrentHashMap;
 import java.util.concurrent.ConcurrentMap;
+import java.util.concurrent.ExecutionException;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Executors;
 import java.util.concurrent.Future;
@@ -246,7 +247,7 @@ public class TestStandardProcessScheduler {
     }
 
     @Test(timeout = 60000)
-    public void 
testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws 
InterruptedException {
+    public void 
testDisableControllerServiceWithProcessorTryingToStartUsingIt() throws 
InterruptedException, ExecutionException {
         final String uuid = UUID.randomUUID().toString();
         final Processor proc = new ServiceReferencingProcessor();
         proc.initialize(new StandardProcessorInitializationContext(uuid, null, 
null, null, KerberosConfig.NOT_CONFIGURED));
@@ -280,13 +281,8 @@ public class TestStandardProcessScheduler {
         scheduler.stopProcessor(procNode);
         assertTrue(service.isActive());
         assertSame(service.getState(), ControllerServiceState.ENABLING);
-        scheduler.disableControllerService(service);
-        assertSame(service.getState(), ControllerServiceState.DISABLING);
+        scheduler.disableControllerService(service).get();
         assertFalse(service.isActive());
-
-        while (service.getState() != ControllerServiceState.DISABLED) {
-            Thread.sleep(5L);
-        }
         assertSame(service.getState(), ControllerServiceState.DISABLED);
     }
 
@@ -356,7 +352,7 @@ public class TestStandardProcessScheduler {
                 @Override
                 public void run() {
                     try {
-                        scheduler.enableControllerService(serviceNode);
+                        scheduler.enableControllerService(serviceNode).get();
                         assertTrue(serviceNode.isActive());
                     } catch (final Exception e) {
                         e.printStackTrace();

Reply via email to