HIGUCHI Yuta
Committed by Ray Milkey

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
......@@ -133,8 +133,16 @@ public class NettyMessagingManagerTest {
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 @@ public class NettyMessagingManagerTest {
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()));
......