diff --git a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/TestClusterCommunicationService.java b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/TestClusterCommunicationService.java index 791a488d7b..b7a1b89270 100644 --- a/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/TestClusterCommunicationService.java +++ b/core/store/primitives/src/test/java/org/onosproject/store/primitives/resources/impl/TestClusterCommunicationService.java @@ -127,8 +127,8 @@ public class TestClusterCommunicationService implements ClusterCommunicationServ public void addSubscriber( MessageSubject subject, Function decoder, - - Function> handler, Function encoder) { + Function> handler, + Function encoder) { subscribers.put(subject, message -> { CompletableFuture future = new CompletableFuture<>(); try { @@ -153,12 +153,16 @@ public class TestClusterCommunicationService implements ClusterCommunicationServ Consumer handler, Executor executor) { subscribers.put(subject, message -> { - try { - handler.accept(decoder.apply(message)); - } catch (Exception e) { - return Futures.exceptionalFuture(new MessagingException.RemoteHandlerFailure()); - } - return Futures.completedFuture(null); + CompletableFuture future = new CompletableFuture<>(); + executor.execute(() -> { + try { + handler.accept(decoder.apply(message)); + future.complete(null); + } catch (Exception e) { + future.completeExceptionally(new MessagingException.RemoteHandlerFailure()); + } + }); + return future; }); }