Potential fix for ONOS-4521.

- Assumption is that problem is triggered, when response is already
  received before setting the completion stage to capture execution thread.

Change-Id: I17fdc82be1f6083ed3075858433b347b2caed4cf
(cherry picked from commit 2cb8d3e9774b01648cc5ef4dc8ade101c8811480)
diff --git a/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManagerTest.java b/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManagerTest.java
index 84fd2cd..118c67a 100644
--- a/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManagerTest.java
+++ b/core/store/dist/src/test/java/org/onosproject/store/cluster/messaging/impl/NettyMessagingManagerTest.java
@@ -133,8 +133,16 @@
         AtomicReference<String> handlerThreadName = new AtomicReference<>();
         AtomicReference<String> completionThreadName = new AtomicReference<>();
 
+        final CountDownLatch latch = new CountDownLatch(1);
+
         BiFunction<Endpoint, byte[], byte[]> handler = (ep, data) -> {
             handlerThreadName.set(Thread.currentThread().getName());
+            try {
+                latch.await();
+            } catch (InterruptedException e1) {
+                Thread.currentThread().interrupt();
+                fail("InterruptedException");
+            }
             return "hello there".getBytes();
         };
         netty2.registerHandler("test-subject", handler, handlerExecutor);
@@ -146,6 +154,7 @@
         response.whenComplete((r, e) -> {
             completionThreadName.set(Thread.currentThread().getName());
         });
+        latch.countDown();
 
         // Verify that the message was request handling and response completion happens on the correct thread.
         assertTrue(Arrays.equals("hello there".getBytes(), response.join()));