@@ -670,12 +670,15 @@ void validatePipeline(Map<DiscoveryNode, IngestInfo> ingestInfos, String pipelin
670670 }
671671
672672 private record IngestPipelinesExecutionResult (boolean success , boolean kept , Exception exception , String failedIndex ) {}
673+
673674 private static IngestPipelinesExecutionResult successResult () {
674675 return new IngestPipelinesExecutionResult (true , true , null , null );
675676 }
677+
676678 private static IngestPipelinesExecutionResult discardResult () {
677679 return new IngestPipelinesExecutionResult (true , false , null , null );
678680 }
681+
679682 private static IngestPipelinesExecutionResult failAndStoreFor (String index , Exception e ) {
680683 return new IngestPipelinesExecutionResult (false , true , e , index );
681684 }
@@ -726,43 +729,40 @@ protected void doRun() {
726729 final IngestDocument ingestDocument = newIngestDocument (indexRequest , documentParsingObserver );
727730 // the document listener gives us three-way logic: a document can fail processing (1), or it can
728731 // be successfully processed. a successfully processed document can be kept (2) or dropped (3).
729- final ActionListener <IngestPipelinesExecutionResult > documentListener = ActionListener .runAfter (new ActionListener <>() {
730- @ Override
731- public void onResponse (IngestPipelinesExecutionResult result ) {
732- assert result != null ;
733- if (result .success ) {
734- if (result .kept == false ) {
735- onDropped .accept (slot );
732+ final ActionListener <IngestPipelinesExecutionResult > documentListener = ActionListener .runAfter (
733+ new ActionListener <>() {
734+ @ Override
735+ public void onResponse (IngestPipelinesExecutionResult result ) {
736+ assert result != null ;
737+ if (result .success ) {
738+ if (result .kept == false ) {
739+ onDropped .accept (slot );
740+ }
741+ } else {
742+ // We were given a failure result in the onResponse method, so we must store the failure
743+ // Recover the original document state, track a failed ingest, and pass it along
744+ updateIndexRequestMetadata (indexRequest , ingestDocument .getOriginalMetadata ());
745+ totalMetrics .ingestFailed ();
746+ onStoreFailure .apply (slot , result .failedIndex , result .exception );
736747 }
737- } else {
738- // We were given a failure result in the onResponse method, so we must store the failure
739- // Recover the original document state, track a failed ingest, and pass it along
740- updateIndexRequestMetadata (indexRequest , ingestDocument .getOriginalMetadata ());
741- totalMetrics .ingestFailed ();
742- onStoreFailure .apply (slot , result .failedIndex , result .exception );
743748 }
744- }
745749
746- @ Override
747- public void onFailure (Exception e ) {
748- totalMetrics .ingestFailed ();
749- onFailure .accept (slot , e );
750+ @ Override
751+ public void onFailure (Exception e ) {
752+ totalMetrics .ingestFailed ();
753+ onFailure .accept (slot , e );
754+ }
755+ },
756+ () -> {
757+ // regardless of success or failure, we always stop the ingest "stopwatch" and release the ref to indicate
758+ // that we're finished with this document
759+ final long ingestTimeInNanos = System .nanoTime () - startTimeInNanos ;
760+ totalMetrics .postIngest (ingestTimeInNanos );
761+ ref .close ();
750762 }
751- }, () -> {
752- // regardless of success or failure, we always stop the ingest "stopwatch" and release the ref to indicate
753- // that we're finished with this document
754- final long ingestTimeInNanos = System .nanoTime () - startTimeInNanos ;
755- totalMetrics .postIngest (ingestTimeInNanos );
756- ref .close ();
757- });
758-
759- executePipelines (
760- pipelines ,
761- indexRequest ,
762- ingestDocument ,
763- shouldStoreFailure ,
764- documentListener
765763 );
764+
765+ executePipelines (pipelines , indexRequest , ingestDocument , shouldStoreFailure , documentListener );
766766 indexRequest .setPipelinesHaveRun ();
767767
768768 assert actionRequest .index () != null ;
0 commit comments