org.springframework.cloud.dataflow.completion

## Class StacktraceFingerprintingRecoveryStrategy<E extends Exception>

- java.lang.Object
- - org.springframework.cloud.dataflow.completion.StacktraceFingerprintingRecoveryStrategy<E>

- All Implemented Interfaces:
    RecoveryStrategy<E>
  Direct Known Subclasses:
    AppsAfterDoublePipeRecoveryStrategy, AppsAfterPipeRecoveryStrategy, ConfigurationPropertyValueHintRecoveryStrategy, UnfinishedConfigurationPropertyNameRecoveryStrategy

      public abstract class StacktraceFingerprintingRecoveryStrategy<E extends Exception>
      extends Object
      implements RecoveryStrategy<E>

  A recovery strategy that will trigger if the parser failure is similar to that of some sample unfinished stream definition. The match is decided by analyzing the top frames of the stack trace emitted by the parser when it encounters the ill formed input. Multiple fingerprints are supported, as the control flow in the parser code may be different depending on the form of the expression. For example, for the rule `stream = module (| module)*` , the pseudo code for the parser may look like

       stream() {
         module();  (1)
         while(moreInput()) {
           swallowPipe();
           module();  (2)
         }
       }

  In that setup, whether we're dealing with the first module, or a subsequent module, stack frames would be different (see (1) and (2)).
  Author:
    Eric Bottard

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected StreamDefinitionService` | `streamDefinitionService`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `StacktraceFingerprintingRecoveryStrategy(Class<E> exceptionClass, StreamDefinitionService streamDefinitionService, String... samples)` Construct a new StacktraceFingerprintingRecoveryStrategy given the parser, and the expected exception class to be thrown for sample fragments of a stream definition that is to be parsed.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `shouldTrigger(String dslStart, Exception exception)` Whether this completion should be triggered.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface org.springframework.cloud.dataflow.completion.RecoveryStrategy

      `addProposals`

- - ### Field Detail

    - #### streamDefinitionService

          protected StreamDefinitionService streamDefinitionService

  - ### Constructor Detail

    - #### StacktraceFingerprintingRecoveryStrategy

          public StacktraceFingerprintingRecoveryStrategy(Class<E> exceptionClass,
                                                          StreamDefinitionService streamDefinitionService,
                                                          String... samples)

      Construct a new StacktraceFingerprintingRecoveryStrategy given the parser, and the expected exception class to be thrown for sample fragments of a stream definition that is to be parsed.
      Parameters:
        `exceptionClass` - the expected exception that results from parsing the sample fragment stream definitions. Stack frames from the thrown exception are used to store the fingerprint of this exception thrown by the parser.
        `streamDefinitionService` - the service to handle stream definition
        `samples` - the sample fragments of stream definitions.

  - ### Method Detail

    - #### shouldTrigger

          public boolean shouldTrigger(String dslStart,
                                       Exception exception)

      Description copied from interface: `RecoveryStrategy`
      Whether this completion should be triggered.
      Specified by:
        `shouldTrigger` in interface `RecoveryStrategy<E extends Exception>`
      Parameters:
        `dslStart` - the partial DSL text
        `exception` - the exception thrown when parsing the DSL text
      Returns:
        if proposals to complete the DSL should be provided

Copyright © 2021 Pivotal Software, Inc.. All rights reserved.