@Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception { if (!disabled && shouldKillIdleChannelNowSupplier.get()) { String reason = (isActiveDownstreamCallTimer) ? "Throwing call timeout error because the active downstream call took longer than the " + "allowed timeout value." : "Closing downstream channel because it was sitting unused for too long between calls."; AsyncNettyHelper.runnableWithTracingAndMdc( () -> logger.debug("{} custom_handler_id={}, idle_timeout_millis={}, worker_channel_throwing_error={}", reason, customHandlerIdForLogs, idleTimeoutMillis, ctx.channel().toString()), traceStackForLogging, mdcInfoForLogging ).run(); throw new DownstreamIdleChannelTimeoutException(idleTimeoutMillis, ctx.channel()); } }
@Override protected void channelIdle(ChannelHandlerContext ctx, IdleStateEvent evt) throws Exception { if (!disabled && shouldKillIdleChannelNowSupplier.get()) { String reason = (isActiveDownstreamCallTimer) ? "Throwing call timeout error because the active downstream call took longer than the " + "allowed timeout value." : "Closing downstream channel because it was sitting unused for too long between calls."; AsyncNettyHelper.runnableWithTracingAndMdc( () -> logger.debug("{} custom_handler_id={}, idle_timeout_millis={}, worker_channel_throwing_error={}", reason, customHandlerIdForLogs, idleTimeoutMillis, ctx.channel().toString()), traceStackForLogging, mdcInfoForLogging ).run(); throw new DownstreamIdleChannelTimeoutException(idleTimeoutMillis, ctx.channel()); } }
@Test public void should_honor_constructor_params() { //given long timeoutValue = 42; Channel channelMock = mock(Channel.class); String uuid = UUID.randomUUID().toString(); doReturn(uuid).when(channelMock).toString(); //when DownstreamIdleChannelTimeoutException ex = new DownstreamIdleChannelTimeoutException(timeoutValue, channelMock); //then assertThat(ex.timeoutValueMillis, is(timeoutValue)); assertThat(ex.channelId, is(uuid)); }
@Test public void shouldHandleAsyncDownstreamCallTimedOut() { verifyExceptionHandled(new DownstreamIdleChannelTimeoutException(4242, null), singletonError(testProjectApiErrors.getTemporaryServiceProblemApiError())); }