synchronized public void shutdown() { try { flush(); } catch (InterruptedException | TransportException e) { logger.warn("caught error while flushing", e); } this.pool.shutdown(); }
synchronized public void shutdown() { try { flush(); } catch (InterruptedException | TransportException e) { logger.warn("caught error while flushing", e); } this.pool.shutdown(); }
@Test(expected = TransportException.class) public void testExceptionEscalation() throws TransportException, InterruptedException { DummyTransporter mockDummyTransporter = mock(DummyTransporter.class); DummyTransporterFactory tfactory = new DummyTransporterFactory(); tfactory.transporter = mockDummyTransporter; doThrow(new TransportException("expected exception in test")).when(mockDummyTransporter) .sendBatch(any(DummyTransportBuffer.class)); IpcSenderService ipc = new IpcSenderService(tfactory); ipc.add(mock(InternalEvent.class)); /* * Expect shutdown to throw a TransportException when a child thread also throws as * TransportException */ ipc.flush(); }
@Test(expected = InterruptedException.class) public void testInterruptedExceptionOnShutdown() throws Throwable { BaseHandler.CONFIG_FILE = "/config/handler_config.json"; List<DummyEvent> events = new ArrayList<DummyEvent>(1); events.add(new DummyEvent("foo", 0)); TestContext context = new TestContext(); context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag"); handler.init(context); IpcSenderService spy = spy(handler.getIpcService()); handler.setIpcService(spy); doThrow(new InterruptedException("expected")).when(spy).flush(); try { handler.handler(events, context); } catch (Exception e) { throw e.getCause().getCause(); } }
@Test(expected = TransportException.class) public void testGeneralTransportExceptionOnShutdown() throws Throwable { BaseHandler.CONFIG_FILE = "/config/handler_config.json"; List<DummyEvent> events = new ArrayList<DummyEvent>(1); events.add(new DummyEvent("foo", 0)); TestContext context = new TestContext(); context.setInvokedFunctionArn("arn:aws:lambda:us-east-1:123:function:test:tag"); handler.init(context); IpcSenderService spy = spy(handler.getIpcService()); handler.setIpcService(spy); doThrow(new TransportException("expected")).when(spy).flush(); try { handler.handler(events, context); } catch (Exception e) { throw e.getCause().getCause(); } }
this.getIpcService().flush(); } catch (TransportException e) { throw new HandlerException("encounted TransportException while shutting down ipcService", e);
this.getIpcService().flush(); } catch (TransportException e) { throw new HandlerException("encounted TransportException while shutting down ipcService", e);
ipc.flush();
ipc.flush();
ipc.flush();
ipc.flush(); } catch (TransportException e) {