@Test(expected = RuntimeException.class) public void exceptionOnStartIsThrown() { prepareSequentialExecutorService(); given(objectMapper.reader()).willThrow(new IOException()); backgroundRpcListener.start(inputStream); }
@Override public void start(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputStream may not be null"); if (listener != null) { log.info("Already listening, ignoring"); return; } listener = executorService.submit(() -> { try { log.info("Started listening on stream"); listenForMessages(inputStream); } catch (IOException e) { log.error("Listening to messages failed!", e); throw new RuntimeException(e); } }); }
BackgroundRpcListener implements RpcListener { @Override public void start(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputStream may not be null"); if (listener != null) { log.info("Already listening, ignoring"); return; } listener = executorService.submit(() -> { try { log.info("Started listening on stream"); listenForMessages(inputStream); } catch (IOException e) { log.error("Listening to messages failed!", e); throw new RuntimeException(e); } }); } }
BackgroundRpcListener implements RpcListener { @Override public void start(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputStream may not be null"); if (listener != null) { log.info("Already listening, ignoring"); return; } listener = executorService.submit(() -> { try { log.info("Started listening on stream"); listenForMessages(inputStream); } catch (IOException e) { log.error("Listening to messages failed!", e); throw new RuntimeException(e); } }); } BackgroundRpcListener(ExecutorService executorService, ObjectMapper responseObjectMapper); }
BackgroundRpcListener implements RpcListener { @Override public void start(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputStream may not be null"); if (listener != null) { log.info("Already listening, ignoring"); return; } listener = executorService.submit(() -> { try { log.info("Started listening on stream"); listenForMessages(inputStream); } catch (IOException e) { log.error("Listening to messages failed!", e); throw new RuntimeException(e); } }); } BackgroundRpcListener(ExecutorService executorService, ObjectMapper responseObjectMapper); @Override void start(InputStream inputStream); @Override void stop(); @Override void listenForResponse(int id, ResponseCallback callback); @Override void listenForNotifications(NotificationCallback callback); @Override void listenForRequests(RequestCallback callback); }
BackgroundRpcListener implements RpcListener { @Override public void start(InputStream inputStream) { Objects.requireNonNull(inputStream, "inputStream may not be null"); if (listener != null) { log.info("Already listening, ignoring"); return; } listener = executorService.submit(() -> { try { log.info("Started listening on stream"); listenForMessages(inputStream); } catch (IOException e) { log.error("Listening to messages failed!", e); throw new RuntimeException(e); } }); } BackgroundRpcListener(ExecutorService executorService, ObjectMapper responseObjectMapper); @Override void start(InputStream inputStream); @Override void stop(); @Override void listenForResponse(int id, ResponseCallback callback); @Override void listenForNotifications(NotificationCallback callback); @Override void listenForRequests(RequestCallback callback); static final Logger log; }