Source:
public StreamingResponseBody streamEvents( @PathVariable("subscription_id") final String subscriptionId, @RequestParam(value = "max_uncommitted_events", required = false, defaultValue = "10") final int maxUncommittedSize, @RequestParam(value = "batch_limit", required = false, defaultValue = "1") final int batchLimit, @Nullable @RequestParam(value = "stream_limit", required = false) final Long streamLimit, @RequestParam(value = "batch_flush_timeout", required = false, defaultValue = "30") final int batchTimeout, @Nullable @RequestParam(value = "stream_timeout", required = false) final Long streamTimeout, @Nullable @RequestParam(value = "stream_keep_alive_limit", required = false) final Integer streamKeepAliveLimit, final HttpServletRequest request, final HttpServletResponse response, final Client client) throws IOException { return outputStream -> { Counter consumerCounter = null; if (!featureToggleService.isFeatureEnabled(HIGH_LEVEL_API)) { response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } final String metricName = metricNameForSubscription(subscriptionId, CONSUMERS_COUNT_METRIC_NAME); 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(Response.Status.FORBIDDEN, "Application or event type is blocked")); return; } final StreamParameters streamParameters = StreamParameters.of(batchLimit, streamLimit, batchTimeout, streamTimeout, streamKeepAliveLimit, maxUncommittedSize, nakadiSettings.getDefaultCommitTimeoutSeconds(), client.getClientId()); streamer = subscriptionStreamerFactory.build(subscriptionId, streamParameters, output, connectionReady, blacklistService); streamer.stream(); } catch (final InterruptedException ex) { LOG.warn("Interrupted while streaming with " + streamer, ex); Thread.currentThread().interrupt(); } catch (final Exception e) { output.onException(e); } finally { if (consumerCounter != null) { consumerCounter.dec(); } outputStream.close(); } }; }

Target:
public StreamingResponseBody streamEvents( @PathVariable("subscription_id") final String subscriptionId, @RequestParam(value = "max_uncommitted_events", required = false, defaultValue = "10") final int maxUncommittedSize, @RequestParam(value = "batch_limit", required = false, defaultValue = "1") final int batchLimit, @Nullable @RequestParam(value = "stream_limit", required = false) final Long streamLimit, @RequestParam(value = "batch_flush_timeout", required = false, defaultValue = "30") final int batchTimeout, @Nullable @RequestParam(value = "stream_timeout", required = false) final Long streamTimeout, @Nullable @RequestParam(value = "stream_keep_alive_limit", required = false) final Integer streamKeepAliveLimit, final HttpServletRequest request, final HttpServletResponse response, final Client client) throws IOException { return outputStream -> { if (!featureToggleService.isFeatureEnabled(HIGH_LEVEL_API)) { response.setStatus(HttpServletResponse.SC_NOT_IMPLEMENTED); return; } 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(Response.Status.FORBIDDEN, "Application or event type is blocked")); return; } final StreamParameters streamParameters = StreamParameters.of(batchLimit, streamLimit, batchTimeout, streamTimeout, streamKeepAliveLimit, maxUncommittedSize, nakadiSettings.getDefaultCommitTimeoutSeconds(), client.getClientId()); streamer = subscriptionStreamerFactory.build(subscriptionId, streamParameters, output, connectionReady, blacklistService); streamer.stream(); } catch (final InterruptedException ex) { LOG.warn("Interrupted while streaming with " + streamer, ex); Thread.currentThread().interrupt(); } catch (final Exception e) { output.onException(e); } finally { consumerCounter.dec(); outputStream.close(); } }; }