@Override
    public boolean registerAllRequestsProcessedListener(NotificationListener listener)
            throws IOException {
        return super.registerAllRequestsProcessedListener(listener);
    }
@Test
    void testConcurrentSubscribeAndHandleRequest() throws Exception {
        final ExecutorService executor = Executors.newFixedThreadPool(2);

        final TestNotificationListener listener = new TestNotificationListener();

        final Callable<Boolean> subscriber =
                () -> writer.registerAllRequestsProcessedListener(listener);

        final Callable<Void> requestHandler =
                () -> {
                    handleRequest();
                    return null;
                };

        try {
            // Repeat this to provoke races
            for (int i = 0; i < 50000; i++) {
                listener.reset();

                addRequest();

                Future<Void> handleRequestFuture = executor.submit(requestHandler);
                Future<Boolean> subscribeFuture = executor.submit(subscriber);

                handleRequestFuture.get();

                boolean subscribed = subscribeFuture.get();
                assertThat(listener.getNumberOfNotifications())
                        .withFailMessage(
                                subscribed
                                        ? "Race: Successfully subscribed, but was never notified."
                                        : "Race: Never subscribed successfully, but was notified.")
                        .isEqualTo(subscribed ? 1 : 0);
            }
        } finally {
            executor.shutdownNow();
        }
    }