Source:
private StreamingResponseBody stream(final String subscriptionId, final HttpServletRequest request, final HttpServletResponse response, final Client client, final StreamParameters streamParameters, final Span parentSubscriptionSpan) { final String flowId = FlowIdUtils.peek(); return outputStream -> { TracingService.activateSpan(parentSubscriptionSpan, false) .setOperationName("stream_events_request") .setTag("subscription.id", subscriptionId) .log(String.format("Stream Parameters: batchLimitEvents: {}," + " batchTimeout:{}, streamTimeout: {}, maxUncommittedMessages: {}", streamParameters.batchLimitEvents, streamParameters.batchTimeoutMillis, streamParameters.streamTimeoutMillis, streamParameters.maxUncommittedMessages)); FlowIdUtils.push(flowId); final String metricName = metricNameForSubscription(subscriptionId, CONSUMERS_COUNT_METRIC_NAME); final Counter consumerCounter = metricRegistry.counter(metricName); consumerCounter.inc(); final AtomicBoolean connectionReady = closedConnectionsCrutch.listenForConnectionClose(request); SubscriptionStreamer streamer = null; final SubscriptionOutputImpl output = new SubscriptionOutputImpl(response, outputStream); try { if (blacklistService.isSubscriptionConsumptionBlocked(subscriptionId, client.getClientId())) { writeProblemResponse(response, outputStream, Problem.valueOf(FORBIDDEN, "Application or event type is blocked")); return; } final Subscription subscription = subscriptionDbRepository.getSubscription(subscriptionId); subscriptionValidationService.validatePartitionsToStream(subscription, streamParameters.getPartitions()); streamer = subscriptionStreamerFactory.build(subscription, streamParameters, output, connectionReady, blacklistService, parentSubscriptionSpan); streamer.stream(); } catch (final InterruptedException ex) { LOG.warn("Interrupted while streaming with " + streamer, ex); Thread.currentThread().interrupt(); } catch (final RuntimeException e) { output.onException(e); } finally { consumerCounter.dec(); outputStream.close(); } }; }

Target:
private StreamingResponseBody stream(final String subscriptionId, final HttpServletRequest request, final HttpServletResponse response, final Client client, final StreamParameters streamParameters, final Span parentSubscriptionSpan) { final String flowId = FlowIdUtils.peek(); return outputStream -> { FlowIdUtils.push(flowId); final String metricName = metricNameForSubscription(subscriptionId, CONSUMERS_COUNT_METRIC_NAME); final Counter consumerCounter = metricRegistry.counter(metricName); consumerCounter.inc(); final AtomicBoolean connectionReady = closedConnectionsCrutch.listenForConnectionClose(request); SubscriptionStreamer streamer = null; final SubscriptionOutputImpl output = new SubscriptionOutputImpl(response, outputStream); try { if (blacklistService.isSubscriptionConsumptionBlocked(subscriptionId, client.getClientId())) { writeProblemResponse(response, outputStream, Problem.valueOf(FORBIDDEN, "Application or event type is blocked")); return; } final Subscription subscription = subscriptionDbRepository.getSubscription(subscriptionId); subscriptionValidationService.validatePartitionsToStream(subscription, streamParameters.getPartitions()); streamer = subscriptionStreamerFactory.build(subscription, streamParameters, output, connectionReady, blacklistService, parentSubscriptionSpan); streamer.stream(); } catch (final InterruptedException ex) { LOG.warn("Interrupted while streaming with " + streamer, ex); Thread.currentThread().interrupt(); } catch (final RuntimeException e) { output.onException(e); } finally { consumerCounter.dec(); outputStream.close(); } }; }