Source:
<code>public void accept(final MetricsQuery query) { if (RANDOM.nextDouble() > _checkFraction) { return; } if (!query.getStartTime().isPresent()) { LOGGER.trace() .setMessage("not consistency-checking because no start time present") .addData("query", query) .log(); return; } if (!query.getEndTime().isPresent()) { LOGGER.trace() .setMessage("not consistency-checking because no end time present") .addData("query", query) .log(); return; } LOGGER.trace() .setMessage("maybe sending for consistency check?") .addData("query", query) .log(); final Instant startTime = query.getStartTime().get(); final Instant endTime = query.getEndTime().get(); query.getMetrics().stream() .map(Metric::getName) .map(RollupMetric::fromRollupMetricName) <START> .forEach(rollupMetricMaybe -> rollupMetricMaybe.ifPresent(rollupMetric -> { checkerTasks(startTime, endTime, rollupMetric) <END> .forEach(task -> { LOGGER.trace() .setMessage("sending for consistency check") .addData("task", task) .addData("query", query) .log(); try { Patterns.ask(_consistencyChecker, task, Duration.ofSeconds(1)).toCompletableFuture().get(); } catch (final InterruptedException | ExecutionException e) { if (!(e.getCause() instanceof ConsistencyChecker.BufferFull)) { LOGGER.error() .setMessage("unexpected exception sending task to consistency checker") .setThrowable(e) .addData("task", task) .addData("query", query) .log(); } } }); }) ); }</code><technical_language>get rid of 3 levels of indentation with: suggestion .flatMap(rollupMetric -> rollupMetric.map(rm -> checkerTasks(startTime, endTime, rm)).orElse(Stream.empty()))</technical_language>

Target:
public void accept(final MetricsQuery query) { _periodicMetrics.recordCounter(QUERY_RECEIVED, 1); if (RANDOM.nextDouble() > _checkFraction) { _periodicMetrics.recordCounter(DROPPED_QUERY_NOT_SAMPLED, 1); return; } if (!query.getStartTime().isPresent()) { _periodicMetrics.recordCounter(DROPPED_QUERY_NO_TIME_BOUNDARY, 1); LOGGER.trace() .setMessage("not consistency-checking because no start time present") .addData("query", query) .log(); return; } _periodicMetrics.recordCounter(QUERY_SELECTED_FOR_CHECK, 1); LOGGER.trace() .setMessage("maybe sending for consistency check?") .addData("query", query) .log(); final Instant startTime = query.getStartTime().get(); final Instant endTime = query.getEndTime().orElse(Instant.now()); query.getMetrics().stream() .map(Metric::getName) .map(RollupMetric::fromRollupMetricName) .forEach(rollupMetricMaybe -> { rollupMetricMaybe.ifPresent(rollupMetric -> { checkerTasks(startTime, endTime, rollupMetric) .forEach(task -> { LOGGER.trace() .setMessage("sending for consistency check") .addData("task", task) .addData("query", query) .log(); try { Patterns.ask(_consistencyChecker, task, Duration.ofSeconds(1)).toCompletableFuture().get(); _periodicMetrics.recordCounter(TASK_SENT_FOR_CHECK, 1); } catch (final InterruptedException | ExecutionException e) { _periodicMetrics.recordCounter(DROPPED_TASK_ENQUEUE_FAILED, 1); if (!(e.getCause() instanceof ConsistencyChecker.BufferFull)) { LOGGER.error() .setMessage("unexpected exception sending task to consistency checker") .setThrowable(e) .addData("task", task) .addData("query", query) .log(); } } }); }); if (!rollupMetricMaybe.isPresent()) { _periodicMetrics.recordCounter(DROPPED_METRIC_NOT_ROLLUP, 1); } } ); }