@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } } }
private <T extends Future<?>> void invokeOperationComplete( GenericFutureListener<T> listener, T future) throws Exception { try (SafeCloseable ignored = pushIfAbsent()) { listener.operationComplete(future); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } } }
@Override public void operationComplete(ChannelFuture future) throws Exception { handler.operationComplete(future); }
@Override public void operationComplete(ChannelFuture future) throws Exception { handler.operationComplete(future); }
@SuppressWarnings("unchecked") private <T extends Future<? super Void>> void notifyListener(GenericFutureListener<T> listener) { try { listener.operationComplete((T) this); } catch (Exception e) { throw new RuntimeException(e); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } }
@SuppressWarnings({ "unchecked", "rawtypes" }) private static void notifyListener0(Future future, GenericFutureListener l) { try { l.operationComplete(future); } catch (Throwable t) { if (logger.isWarnEnabled()) { logger.warn("An exception was thrown by " + l.getClass().getName() + ".operationComplete()", t); } } }
public void finish(boolean success) { this.success = success; listeners.forEach(listener -> { try { listener.operationComplete(this); } catch (Exception e) { // do nothing } }); } }
@Override public void channelInactive(final ChannelHandlerContext ctx) throws Exception { super.channelInactive(ctx); long entries = 0; LOG.debug("Channel shutdown, flushing queue..."); final Future<Void> result = ctx.newFailedFuture(new RejectedExecutionException("Channel disconnected")); while (true) { final MessageHolder<?> e = queue.poll(); if (e == null) { break; } e.takeListener().operationComplete(result); entries++; } LOG.debug("Flushed {} queue entries", entries); }
@Override protected void encode(ChannelHandlerContext ctx, UdpMessageListenerWrapper wrapper, List<Object> out) throws Exception { LOG.trace("Encoding"); try { ByteBuf buffer = PooledByteBufAllocator.DEFAULT.buffer(); serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), buffer, wrapper.getMsg()); out.add(new DatagramPacket(buffer, wrapper.getAddress())); } catch(Exception e) { LOG.warn("Message serialization failed: {}", e.getMessage()); Future<Void> newFailedFuture = ctx.newFailedFuture(e); wrapper.getListener().operationComplete(newFailedFuture); return; } }
private void verifyCloseFutureListener(GenericFutureListener closeFutureListener) throws Exception { // If the double-check ScheduledFuture is not done then it cancels it. reset(doubleCheckScheduledFutureMock); doReturn(false).when(doubleCheckScheduledFutureMock).isDone(); closeFutureListener.operationComplete(null); verify(doubleCheckScheduledFutureMock).isDone(); verify(doubleCheckScheduledFutureMock).cancel(false); verifyNoMoreInteractions(doubleCheckScheduledFutureMock); // And when the double-check ScheduledFuture is done, then nothing happens. reset(doubleCheckScheduledFutureMock); doReturn(true).when(doubleCheckScheduledFutureMock).isDone(); closeFutureListener.operationComplete(null); verify(doubleCheckScheduledFutureMock).isDone(); verifyNoMoreInteractions(doubleCheckScheduledFutureMock); }
@Test public void finalizeChannelPipeline_should_send_event_to_metricsListener_for_failure_response_and_flush_context() throws Exception { // given ChannelFuture responseWriterChannelFuture = mock(ChannelFuture.class); state.setResponseWriterFinalChunkChannelFuture(responseWriterChannelFuture); HttpProcessingState stateSpy = spy(state); doReturn(stateSpy).when(stateAttributeMock).get(); ChannelFuture responseWriteFutureResult = mock(ChannelFuture.class); doReturn(false).when(responseWriteFutureResult).isSuccess(); Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isFalse(); // when handler.finalizeChannelPipeline(ctxMock, null, stateSpy, null); // then ArgumentCaptor<GenericFutureListener> channelFutureListenerArgumentCaptor = ArgumentCaptor.forClass(GenericFutureListener.class); verify(responseWriterChannelFuture).addListener(channelFutureListenerArgumentCaptor.capture()); GenericFutureListener futureListener = channelFutureListenerArgumentCaptor.getValue(); assertThat(futureListener, notNullValue()); futureListener.operationComplete(responseWriteFutureResult); verify(metricsListenerMock).onEvent(ServerMetricsEvent.RESPONSE_WRITE_FAILED, null); verify(ctxMock).flush(); Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isTrue(); }
@Test public void finalizeChannelPipeline_should_send_event_to_metricsListener_for_successful_response_and_flush_context() throws Exception { // given ChannelFuture responseWriterChannelFuture = mock(ChannelFuture.class); state.setResponseWriterFinalChunkChannelFuture(responseWriterChannelFuture); HttpProcessingState stateSpy = spy(state); doReturn(stateSpy).when(stateAttributeMock).get(); ChannelFuture responseWriteFutureResult = mock(ChannelFuture.class); doReturn(true).when(responseWriteFutureResult).isSuccess(); Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isFalse(); // when handler.finalizeChannelPipeline(ctxMock, null, stateSpy, null); // then ArgumentCaptor<GenericFutureListener> channelFutureListenerArgumentCaptor = ArgumentCaptor.forClass(GenericFutureListener.class); verify(responseWriterChannelFuture).addListener(channelFutureListenerArgumentCaptor.capture()); GenericFutureListener futureListener = channelFutureListenerArgumentCaptor.getValue(); assertThat(futureListener, notNullValue()); futureListener.operationComplete(responseWriteFutureResult); verify(metricsListenerMock).onEvent(eq(ServerMetricsEvent.RESPONSE_SENT), any(HttpProcessingState.class)); verify(ctxMock).flush(); Assertions.assertThat(stateSpy.isRequestMetricsRecordedOrScheduled()).isTrue(); }
listener.operationComplete(getFutureForCase(true, false, null)); listener.operationComplete(getFutureForCase(false, true, null)); listener.operationComplete(getFutureForCase(false, false, normalFutureFailure)); listener.operationComplete(getFutureForCase(false, false, null));
@Override protected void encode(final ChannelHandlerContext ctx, final MessageListenerWrapper wrapper, final ByteBuf out) throws Exception { LOG.trace("Encoding"); try { serializationFactory.messageToBuffer(wrapper.getMsg().getVersion(), out, wrapper.getMsg()); if(wrapper.getMsg() instanceof FlowModInput){ statisticsCounters.incrementCounter(CounterEventTypes.DS_FLOW_MODS_SENT); } statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_SUCCESS); } catch(final Exception e) { LOG.warn("Message serialization failed ", e); statisticsCounters.incrementCounter(CounterEventTypes.DS_ENCODE_FAIL); if (wrapper.getListener() != null) { final Future<Void> newFailedFuture = ctx.newFailedFuture(e); wrapper.getListener().operationComplete(newFailedFuture); } out.clear(); return; } }