mirror of https://github.com/apache/nifi.git
Adjusting onRemoved methods for both JsonPath processors to clean up entries on exit.
This commit is contained in:
parent
5a2a8fc6be
commit
484687a67b
|
@ -86,7 +86,7 @@ public abstract class AbstractJsonPathProcessor extends AbstractProcessor {
|
|||
return JSON_PROVIDER.toJson(jsonPathResult);
|
||||
}
|
||||
|
||||
protected abstract static class JsonPathValidator implements Validator {
|
||||
abstract static class JsonPathValidator implements Validator {
|
||||
|
||||
@Override
|
||||
public ValidationResult validate(final String subject, final String input, final ValidationContext context) {
|
||||
|
|
|
@ -182,7 +182,7 @@ public class EvaluateJsonPath extends AbstractJsonPathProcessor {
|
|||
* isStale()
|
||||
*/
|
||||
@OnRemoved
|
||||
public void onRemoved() {
|
||||
public void onRemoved(ProcessContext processContext) {
|
||||
for (PropertyDescriptor propertyDescriptor : getPropertyDescriptors()) {
|
||||
if (propertyDescriptor.isDynamic()) {
|
||||
cachedJsonPathMap.remove(propertyDescriptor.getName());
|
||||
|
|
|
@ -26,6 +26,7 @@ import org.apache.nifi.annotation.behavior.SideEffectFree;
|
|||
import org.apache.nifi.annotation.behavior.SupportsBatching;
|
||||
import org.apache.nifi.annotation.documentation.CapabilityDescription;
|
||||
import org.apache.nifi.annotation.documentation.Tags;
|
||||
import org.apache.nifi.annotation.lifecycle.OnRemoved;
|
||||
import org.apache.nifi.components.PropertyDescriptor;
|
||||
import org.apache.nifi.flowfile.FlowFile;
|
||||
import org.apache.nifi.logging.ProcessorLog;
|
||||
|
@ -111,6 +112,17 @@ public class SplitJson extends AbstractJsonPathProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides cleanup of the map for any JsonPath values that may have been created. This will remove common values
|
||||
* shared between multiple instances, but will be regenerated when the next validation cycle occurs as a result of
|
||||
* isStale()
|
||||
*/
|
||||
@OnRemoved
|
||||
public void onRemoved(ProcessContext processContext) {
|
||||
String jsonPathExpression = processContext.getProperty(ARRAY_JSON_PATH_EXPRESSION).getValue();
|
||||
JSON_PATH_MAP.remove(jsonPathExpression);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTrigger(final ProcessContext processContext, final ProcessSession processSession) {
|
||||
final FlowFile original = processSession.get();
|
||||
|
|
Loading…
Reference in New Issue